refactor(map): 统一卡牌购买后的全池刷新逻辑

1.  为装备、物品、技能卡牌组件统一添加CardUsed事件派发
2.  重构MissionCardComp的卡槽管理,改为槽位复用模式
3.  拆分并统一装备、物品、技能卡池的刷新逻辑
4.  移除冗余的UseSkillCard事件监听与处理
5.  整理并缓存各类卡槽组件引用
This commit is contained in:
panFD
2026-07-26 19:19:30 +08:00
parent 24eb72ef99
commit 1593c7ffbf
5 changed files with 918 additions and 4976 deletions

View File

@@ -397,6 +397,9 @@ export class SCardComp extends CCComp {
// 播放购买动画(卡牌放大 + 淡出)
this.playPurchaseAnim();
// 派发 CardUsed 事件,通知 MissionCardComp 刷新技能卡池
oops.message.dispatchEvent(GameEvent.CardUsed, this);
mLogger.log(this.debugMode, "SCardComp", "skill card purchased", {
uuid: this.cardData.uuid,
cost
@@ -411,6 +414,27 @@ export class SCardComp extends CCComp {
}
}
/**
* 接收 MissionCardComp 分发的卡牌并刷新显示。
* @param data 卡牌配置null 时清空显示
* @returns 是否成功接收true = 接收并刷新 UI
*/
applyDrawCard(data: CardConfig | null): boolean {
this.applyCardData(data);
return !!data;
}
/**
* 系统清槽:任务开始/结束时强制重置。
* 清空数据与 UI 并隐藏节点。
*/
clearBySystem() {
this.cardData = null;
this.isPurchased = false;
this.applyEmptyUI();
this.node.active = false;
}
/** ECS 组件移除时销毁节点 */
reset() {
if (this.node && this.node.isValid) {