refactor(skill): 重构技能触发逻辑,提取统一工具类
将分散在Hero、Mon、HeroAtkSystem、SCastSystem、MissionComp中的技能触发代码统一封装,集中处理触发次数加成、实体合法性校验与技能事件派发,同时新增SkillTriggerType枚举统一管理技能触发类型,简化业务调用并消除重复模板代码。
This commit is contained in:
@@ -9,10 +9,11 @@ import { DamageQueueComp, DamageEvent } from "./DamageQueueComp";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { GameEvent, SkillTriggerType } from "../common/config/GameEvent";
|
||||
import { FieldSkillType } from "../common/config/SkillSet";
|
||||
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { SkillTriggerHelper } from "./SkillTriggerHelper";
|
||||
|
||||
/** 最终伤害数据接口
|
||||
* 用于封装一次攻击计算的所有结果数据
|
||||
@@ -94,18 +95,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
|
||||
/** 检查并触发受击附加技能 (atked) */
|
||||
private checkAndTriggerAtkedSkills(heroAttrs: HeroAttrsComp, heroView: HeroViewComp) {
|
||||
if (!heroAttrs.atked || heroAttrs.atked.length === 0) return;
|
||||
|
||||
heroAttrs.atked.forEach(atkConfig => {
|
||||
if (heroAttrs.atked_count > 0 && heroAttrs.atked_count % atkConfig.t_num === 0) {
|
||||
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
|
||||
s_uuid: atkConfig.s_uuid,
|
||||
heroAttrs: heroAttrs,
|
||||
heroView: heroView,
|
||||
triggerType: 'atked'
|
||||
});
|
||||
}
|
||||
});
|
||||
SkillTriggerHelper.trigger(SkillTriggerType.Atked, heroAttrs, heroView);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,27 +309,9 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
const TAttrsComp = entity.get(HeroAttrsComp);
|
||||
if (!TAttrsComp) return;
|
||||
|
||||
if (TAttrsComp.dead && TAttrsComp.dead.length > 0) {
|
||||
const view = entity.get(HeroViewComp);
|
||||
if (view) {
|
||||
let triggerCount = 1 + HeroAttrsComp.getFieldSkillTotalValue(FieldSkillType.DeadCount);
|
||||
triggerCount = Math.max(1, Math.floor(triggerCount));
|
||||
|
||||
for (let i = 0; i < triggerCount; i++) {
|
||||
TAttrsComp.dead.forEach((uuid: number) => {
|
||||
if (TAttrsComp.fac === FacSet.HERO) {
|
||||
// 【评分系统 - 防御分】统计死亡触发技能的生效次数
|
||||
smc.vmdata.scores.dead_trigger_count++;
|
||||
}
|
||||
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
|
||||
s_uuid: uuid,
|
||||
heroAttrs: TAttrsComp,
|
||||
heroView: view,
|
||||
triggerType: 'dead'
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
const view = entity.get(HeroViewComp);
|
||||
if (view) {
|
||||
SkillTriggerHelper.trigger(SkillTriggerType.Dead, TAttrsComp, view);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user