新增礼物动画处理日志记录功能,优化了 GiftAnimationManager 和 GiftComboManager 中的连击计数逻辑,确保连击计数的有效性和准确性。同时,增强了日志输出,便于调试和监控动画处理状态,提升用户体验。
This commit is contained in:
@@ -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];
|
||||
});
|
||||
}
|
||||
|
@@ -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)(如果有的话)
|
||||
|
Reference in New Issue
Block a user