refactor(英雄管理): 将英雄与金币数据迁移至全局任务数据
- 移除 Hero.ts 中手动维护的 hero_num 计数逻辑 - 在 SingletonModuleComp 的 mission_data 中添加 hero_max_num、hero_extend_max_num 字段 - 重构 MissionCardComp,使其通过 smc.vmdata.mission_data 读写英雄数量、金币等状态 - 新增辅助方法统一数据访问与同步,避免状态分散管理
This commit is contained in:
@@ -150,8 +150,6 @@ export class Hero extends ecs.Entity {
|
||||
}
|
||||
})
|
||||
.start();
|
||||
// 维护关卡内英雄数量统计
|
||||
smc.vmdata.mission_data.hero_num++
|
||||
}
|
||||
|
||||
/** 重置入口:复用 destroy 的释放流程 */
|
||||
@@ -197,10 +195,6 @@ export class BattleEntityLifecycleSystem extends ecs.ComblockSystem
|
||||
if (heroAttrs) {
|
||||
mLogger.log(heroAttrs.debugMode, 'BattleEntityLifecycle', `${label}离开世界: ${heroAttrs.hero_name}`);
|
||||
if (heroAttrs.fac === FacSet.HERO) {
|
||||
const missionData = smc.vmdata?.mission_data;
|
||||
if (missionData) {
|
||||
missionData.hero_num = Math.max(0, (missionData.hero_num ?? 0) - 1);
|
||||
}
|
||||
oops.message.dispatchEvent(GameEvent.HeroDead, {
|
||||
eid: e.eid,
|
||||
model: heroAttrs
|
||||
|
||||
Reference in New Issue
Block a user