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

@@ -9,7 +9,8 @@ import { HeroDisVal, HeroInfo, HType } from "../common/config/heroSet";
import { Attrs } from "../common/config/HeroAttrs";
import { BoxSet, FacSet, FightSet } from "../common/config/GameSet";
import { oops } from "db://oops-framework/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { GameEvent, SkillTriggerType } from "../common/config/GameEvent";
import { SkillTriggerHelper } from "./SkillTriggerHelper";
/**
* ==================== 自动施法系统 ====================
@@ -338,18 +339,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
/** 检查并触发攻击附加技能 (atking) */
private checkAndTriggerAtkingSkills(heroAttrs: HeroAttrsComp, heroView: HeroViewComp) {
if (!heroAttrs.atking || heroAttrs.atking.length === 0) return;
heroAttrs.atking.forEach(atkConfig => {
if (heroAttrs.atk_count > 0 && heroAttrs.atk_count % atkConfig.t_num === 0) {
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
s_uuid: atkConfig.s_uuid,
heroAttrs: heroAttrs,
heroView: heroView,
triggerType: 'atking'
});
}
});
SkillTriggerHelper.trigger(SkillTriggerType.Atking, heroAttrs, heroView);
}
private resolveRepeatCastTargetPos(targetPos: Vec3 | null, castIndex: number): Vec3 | null {