2024-09-05 19:43:01 +08:00
|
|
|
|
//
|
|
|
|
|
// GiftComboManager.h
|
|
|
|
|
// YuMi
|
|
|
|
|
//
|
|
|
|
|
// Created by P on 2024/9/5.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
|
|
|
|
|
#import "GiftInfoModel.h"
|
2024-09-10 15:27:47 +08:00
|
|
|
|
#import "GiftComboView.h"
|
2024-09-05 19:43:01 +08:00
|
|
|
|
|
2024-09-12 14:01:12 +08:00
|
|
|
|
@class GiftReceiveInfoModel, UserInfoModel, GiftReceiveInfoModel, XPGiftCountModel;
|
2024-09-05 19:43:01 +08:00
|
|
|
|
|
|
|
|
|
typedef enum : NSUInteger {
|
|
|
|
|
ComboAction_ShowPanel,
|
2024-09-10 15:27:47 +08:00
|
|
|
|
ComboAction_RemovePanel,
|
2024-09-12 18:49:42 +08:00
|
|
|
|
ComboAction_Error,
|
2024-09-10 15:27:47 +08:00
|
|
|
|
ComboAction_Combo_Count_Update,
|
2024-12-04 21:22:38 +08:00
|
|
|
|
ComboAction_Update_After_Send_Success,
|
|
|
|
|
ComboAction_SendGift_Gold_Update
|
2024-09-05 19:43:01 +08:00
|
|
|
|
} ComboActionType;
|
|
|
|
|
|
2024-09-10 15:27:47 +08:00
|
|
|
|
typedef enum : NSUInteger {
|
|
|
|
|
ComboFlagAction_,
|
|
|
|
|
// ComboAction_RemovePanel,
|
|
|
|
|
// ComboAction_Combo_Count_Update,
|
|
|
|
|
} ComboFlagActionType;
|
|
|
|
|
|
2024-09-05 19:43:01 +08:00
|
|
|
|
|
2025-08-11 14:51:57 +08:00
|
|
|
|
// 通知常量定义
|
2025-08-18 16:24:45 +08:00
|
|
|
|
UIKIT_EXTERN NSString * _Nonnull const kBoomStateForceResetNotification;
|
2025-08-11 14:51:57 +08:00
|
|
|
|
|
2024-09-05 19:43:01 +08:00
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
@interface GiftComboManager : NSObject
|
|
|
|
|
|
2024-12-04 21:22:38 +08:00
|
|
|
|
@property (nonatomic, assign, readonly) BOOL enableCombo;
|
|
|
|
|
//@property(nonatomic, strong, nullable) GiftComboView *comboView;
|
2024-11-11 19:35:21 +08:00
|
|
|
|
@property (nonatomic, strong) GiftReceiveInfoModel *sendGiftReceiveInfo;
|
2024-11-22 13:47:34 +08:00
|
|
|
|
@property(nonatomic, copy) void(^handleComboSuccess)(GiftReceiveInfoModel *receiveModel, NSMutableDictionary *originDic);
|
2024-12-04 21:22:38 +08:00
|
|
|
|
@property(nonatomic, copy) void(^handleRoomUIChanged)(BOOL comboViewDisplay);
|
2024-11-11 19:35:21 +08:00
|
|
|
|
|
2024-09-05 19:43:01 +08:00
|
|
|
|
// 单例方法
|
|
|
|
|
+ (instancetype)sharedManager;
|
|
|
|
|
|
|
|
|
|
- (void)registerActions:(void(^ _Nullable)(ComboActionType type))action;
|
|
|
|
|
|
2025-08-18 16:24:45 +08:00
|
|
|
|
#pragma mark - 新的简化接口
|
2024-09-20 10:46:04 +08:00
|
|
|
|
|
2025-08-18 16:24:45 +08:00
|
|
|
|
// 状态管理
|
|
|
|
|
- (void)activate; // 激活连击功能
|
|
|
|
|
- (void)deactivate; // 停用连击功能
|
|
|
|
|
- (BOOL)isActive; // 检查是否激活
|
|
|
|
|
|
|
|
|
|
// 计数管理
|
|
|
|
|
- (NSInteger)currentCount; // 获取当前连击计数
|
|
|
|
|
- (void)incrementCount; // 增加连击计数
|
|
|
|
|
- (void)reset; // 重置连击状态
|
|
|
|
|
|
|
|
|
|
// 操作控制
|
|
|
|
|
- (void)clear; // 清除连击状态
|
|
|
|
|
- (void)send; // 发送连击礼物
|
|
|
|
|
|
|
|
|
|
// 状态查询
|
|
|
|
|
- (NSDictionary * _Nonnull)stateInfo; // 获取完整状态信息
|
|
|
|
|
- (BOOL)canStartCombo; // 检查是否可以开始连击
|
|
|
|
|
- (void)validateState; // 验证并修复状态
|
|
|
|
|
|
|
|
|
|
// 错误处理
|
|
|
|
|
- (void)handleError:(NSError * _Nonnull)error;
|
|
|
|
|
- (NSString * _Nonnull)lastErrorMessage;
|
|
|
|
|
- (void)clearError;
|
|
|
|
|
|
2024-09-10 15:27:47 +08:00
|
|
|
|
- (void)sendGift;
|
2025-08-11 14:51:57 +08:00
|
|
|
|
- (void)forceBoomStateReset;
|
2024-09-20 10:46:04 +08:00
|
|
|
|
- (BOOL)loadEnable;
|
2024-09-10 15:27:47 +08:00
|
|
|
|
|
2024-09-12 14:01:12 +08:00
|
|
|
|
- (NSInteger)loadTotalGiftNum;
|
2025-08-19 14:39:27 +08:00
|
|
|
|
|
|
|
|
|
// 统一配置方法(替代多个save方法)
|
|
|
|
|
- (void)configureWithGiftInfo:(GiftInfoModel * _Nonnull)giftInfo
|
|
|
|
|
targetUIDs:(NSArray * _Nonnull)UIDs
|
|
|
|
|
roomUID:(NSString * _Nonnull)roomUID
|
|
|
|
|
sessionID:(NSString * _Nonnull)sessionID
|
|
|
|
|
userInfo:(UserInfoModel * _Nonnull)userInfo
|
|
|
|
|
countModel:(XPGiftCountModel * _Nonnull)countModel
|
|
|
|
|
sourceType:(GiftSourceType)sourceType
|
|
|
|
|
sendType:(RoomSendGiftType)sendType
|
|
|
|
|
giftNum:(NSString * _Nonnull)giftNum;
|
2024-09-10 15:27:47 +08:00
|
|
|
|
|
2025-08-18 14:01:57 +08:00
|
|
|
|
// 新增:连击状态检查方法
|
|
|
|
|
- (BOOL)isComboStateValid;
|
2025-08-18 16:24:45 +08:00
|
|
|
|
- (NSDictionary * _Nonnull)getComboStateInfo;
|
2025-08-18 14:01:57 +08:00
|
|
|
|
|
2025-08-28 16:33:38 +08:00
|
|
|
|
// 🔧 新增:状态通知方法
|
|
|
|
|
- (void)setUserComboState:(BOOL)isCombo forUser:(NSString *)uid;
|
|
|
|
|
- (void)clearUserComboState:(NSString *)uid;
|
|
|
|
|
|
2025-08-18 16:24:45 +08:00
|
|
|
|
#pragma mark - 使用示例
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
新的简化接口使用示例:
|
|
|
|
|
|
|
|
|
|
// 1. 激活连击功能
|
|
|
|
|
[[GiftComboManager sharedManager] activate];
|
|
|
|
|
|
|
|
|
|
// 2. 重置连击状态
|
|
|
|
|
[[GiftComboManager sharedManager] reset];
|
|
|
|
|
|
|
|
|
|
// 3. 增加连击计数
|
|
|
|
|
[[GiftComboManager sharedManager] incrementCount];
|
|
|
|
|
|
|
|
|
|
// 4. 获取当前状态
|
|
|
|
|
NSDictionary *state = [[GiftComboManager sharedManager] stateInfo];
|
|
|
|
|
|
|
|
|
|
// 5. 清除连击状态
|
|
|
|
|
[[GiftComboManager sharedManager] clear];
|
|
|
|
|
|
|
|
|
|
迁移建议:
|
|
|
|
|
- enableToCombo:YES -> activate
|
|
|
|
|
- enableToCombo:NO -> deactivate
|
|
|
|
|
- resetCombo -> reset
|
|
|
|
|
- forceRemove -> clear
|
|
|
|
|
- loadComboCount -> currentCount
|
|
|
|
|
- loadComboCountFromSendGiftView -> incrementCount
|
|
|
|
|
- isGiftCombing -> isActive
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
- (NSString * _Nonnull)loadErrorMessage;
|
|
|
|
|
|
|
|
|
|
- (void)receiveGiftInfoForDisplayComboFlags:(GiftReceiveInfoModel * _Nonnull)receiveInfo
|
|
|
|
|
container:(UIView * _Nonnull)container;
|
2025-01-15 19:02:58 +08:00
|
|
|
|
- (void)removeComboFlag;
|
2024-09-05 19:43:01 +08:00
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|