refactor(skill): 重构技能触发逻辑,提取统一工具类

将分散在Hero、Mon、HeroAtkSystem、SCastSystem、MissionComp中的技能触发代码统一封装,集中处理触发次数加成、实体合法性校验与技能事件派发,同时新增SkillTriggerType枚举统一管理技能触发类型,简化业务调用并消除重复模板代码。
This commit is contained in:
panw
2026-05-21 11:10:27 +08:00
parent 3bfdf1639b
commit fc3f4d7375
8 changed files with 192 additions and 90 deletions

View File

@@ -6,7 +6,8 @@ import { HeroAttrsComp } from "./HeroAttrsComp";
import { HeroViewComp } from "./HeroViewComp";
import { BoxSet, FacSet, FightSet, IndexSet } from "../common/config/GameSet";
import { HeroInfo, HeroPos, resolveFormationTargetX } from "../common/config/heroSet";
import { GameEvent } from "../common/config/GameEvent";
import { GameEvent, SkillTriggerType } from "../common/config/GameEvent";
import { SkillTriggerHelper } from "./SkillTriggerHelper";
import { Attrs} from "../common/config/HeroAttrs";
import { MoveComp } from "./MoveComp";
import { mLogger } from "../common/Logger";
@@ -222,24 +223,7 @@ export class Hero extends ecs.Entity {
}
// 落地后触发 call 技能
if (model && model.call && model.call.length > 0) {
let triggerCount = 1 + HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.SummonCount);
if (model.fac === FacSet.HERO) {
triggerCount += HeroAttrsComp.getTalentValue(TalentType.Summon); // 召唤强化额外次数
}
triggerCount = Math.max(1, Math.floor(triggerCount));
for (let i = 0; i < triggerCount; i++) {
model.call.forEach(uuid => {
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
s_uuid: uuid,
heroAttrs: model,
heroView: view,
triggerType: 'call'
});
});
}
}
SkillTriggerHelper.trigger(SkillTriggerType.Call, model, view);
})
.start();
}