新增礼物动画处理日志记录功能,优化了 GiftAnimationManager 和 GiftComboManager 中的连击计数逻辑,确保连击计数的有效性和准确性。同时,增强了日志输出,便于调试和监控动画处理状态,提升用户体验。

This commit is contained in:
edwinQQQ
2025-08-18 14:01:57 +08:00
parent 3f97b0293e
commit 79f6f45bc1
11 changed files with 359 additions and 40 deletions

View File

@@ -77,43 +77,67 @@
}
- (void)processNextGift {
if (self.giftQueue.count == 0) {
[self stopGiftQueue];
return;
}
GiftReceiveInfoModel *giftInfo = self.giftQueue.firstObject;
if (!giftInfo) return;
//
dispatch_async(self.queue, ^{
if (self.giftQueue.count > 0) {
[self.giftQueue xpSafeRemoveObjectAtIndex:0];
if (self.giftQueue.count == 0) {
NSLog(@"[Combo effect] 📭 动画队列为空,停止处理");
[self stopGiftQueue];
return;
}
});
@kWeakify(self);
dispatch_async(dispatch_get_main_queue(), ^{
@kStrongify(self);
if (self) {
[self distributeGiftAnimation:giftInfo];
GiftReceiveInfoModel *giftInfo = self.giftQueue.firstObject;
if (!giftInfo) {
NSLog(@"[Combo effect] ⚠️ 队列第一个元素为空,跳过处理");
return;
}
//
if (giftInfo.comboCount < 1) {
NSLog(@"[Combo effect] 🚨 动画处理中检测到连击计数异常 - comboCount: %ld", (long)giftInfo.comboCount);
giftInfo.comboCount = 1;
NSLog(@"[Combo effect] 🔧 修复动画连击计数为 1");
}
NSLog(@"[Combo effect] 🎬 开始处理动画 - giftId: %ld, combo: %ld", (long)giftInfo.gift.giftId, (long)giftInfo.comboCount);
// 线
[self.giftQueue xpSafeRemoveObjectAtIndex:0];
NSLog(@"[Combo effect] 📊 移除后动画队列数量: %ld", (long)self.giftQueue.count);
@kWeakify(self);
dispatch_async(dispatch_get_main_queue(), ^{
@kStrongify(self);
if (self) {
[self distributeGiftAnimation:giftInfo];
} else {
NSLog(@"[Combo effect] ⚠️ self已释放跳过动画分发");
}
});
});
}
- (void)distributeGiftAnimation:(GiftReceiveInfoModel *)giftInfo {
NSLog(@"[Combo effect] 🎯 开始分发动画 - uid: %@", giftInfo.uid);
NSArray<NSString *> *targetUids = [self resolveTargetUids:giftInfo];
NSLog(@"[Combo effect] 🎯 目标用户数量: %ld", (long)targetUids.count);
CGPoint startPoint = CGPointZero;
BOOL isComboAnimation = [self shouldUseComboAnimationForSender:giftInfo.uid];
NSLog(@"[Combo effect] 🎯 是否使用连击动画: %@", isComboAnimation ? @"YES" : @"NO");
if (isComboAnimation) {
startPoint = [self comboAnimationStartPoint];
NSLog(@"[Combo effect] 🎯 使用连击动画起点: %@", NSStringFromCGPoint(startPoint));
} else {
startPoint = [self calculateAnimationPoint:giftInfo.uid isEndPoint:NO];
NSLog(@"[Combo effect] 🎯 使用普通动画起点: %@", NSStringFromCGPoint(startPoint));
}
NSTimeInterval delay = isComboAnimation ? self.comboAnimationDelay : self.standardAnimationDelay;
NSLog(@"[Combo effect] 🎯 动画延迟时间: %.2f", delay);
for (NSString *targetUid in targetUids) {
CGPoint endPoint = [self calculateAnimationPoint:targetUid isEndPoint:YES];
NSLog(@"[Combo effect] 🎯 为目标用户 %@ 创建动画 - 终点: %@", targetUid, NSStringFromCGPoint(endPoint));
[self scheduleAnimationWithDelay:delay
giftInfo:giftInfo.gift
startPoint:startPoint
@@ -206,11 +230,15 @@
- (void)enqueueGift:(GiftReceiveInfoModel *)giftInfo {
if (!giftInfo) {
NSLog(@"[Combo effect] ⚠️ 礼物信息为空,跳过动画队列");
return;
}
NSLog(@"[Combo effect] 🎬 添加礼物到动画队列 - giftId: %ld, combo: %ld", (long)giftInfo.gift.giftId, (long)giftInfo.comboCount);
dispatch_async(self.queue, ^{
[self.giftQueue addObject:giftInfo];
NSLog(@"[Combo effect] 📊 动画队列当前数量: %ld", (long)self.giftQueue.count);
[self startGiftQueue];
});
}

View File

@@ -1722,9 +1722,26 @@ UIGestureRecognizerDelegate
return;
}
NSLog(@"[Combo effect] 📨 收到礼物消息 - second: %ld", (long)attachment.second);
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
[receiveInfo giftDataAlignment];
//
if (receiveInfo.comboCount < 1) {
NSLog(@"[Combo effect] 🚨 收到云信消息中连击计数异常 - comboCount: %ld", (long)receiveInfo.comboCount);
// attachment.data
NSNumber *dataComboCount = attachment.data[@"comboCount"];
if (dataComboCount && [dataComboCount integerValue] >= 1) {
NSLog(@"[Combo effect] 🔧 从 attachment.data 修复连击计数 - 修复为: %@", dataComboCount);
receiveInfo.comboCount = [dataComboCount integerValue];
} else {
NSLog(@"[Combo effect] 🔧 设置默认连击计数为 1");
receiveInfo.comboCount = 1;
}
}
NSLog(@"[Combo effect] 📨 礼物消息解析完成 - giftId: %ld, combo: %ld, uid: %@", (long)receiveInfo.gift.giftId, (long)receiveInfo.comboCount, receiveInfo.uid);
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_Gift_LuckySend ||
attachment.second == Custom_Message_Sub_AllMicroLuckySend ||
attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
@@ -1776,6 +1793,7 @@ UIGestureRecognizerDelegate
}
if (receiveInfo.isLuckyBagGift) {
NSLog(@"[Combo effect] 🎁 处理福袋礼物");
[self receiveGiftHandleSendGiftAnimationWith:receiveInfo
attachment:attachment];
[self _handleBagGift:receiveInfo];
@@ -1783,9 +1801,11 @@ UIGestureRecognizerDelegate
if (receiveInfo.gift.notifyFull == 1 &&
attachment.second == Custom_Message_Sub_Gift_Send) {
//
NSLog(@"[Combo effect] 🎁 全服礼物由自己发送,跳过播放");
return;
}
//
NSLog(@"[Combo effect] 🎁 处理普通礼物动画");
[self receiveGiftHandleSendGiftAnimationWith:receiveInfo
attachment:attachment];
// svga/mp4