refactor(hero): 将触发技能配置从 HeroInfo 移至 HeroAttrsComp
重构英雄和怪物实体的创建逻辑,将 call、dead、fstart、fend、atking、atked 等触发技能配置从静态 HeroInfo 表复制到 HeroAttrsComp 组件实例中。 修改 SCastSystem、HeroAtkSystem、MissionComp 和 HeroViewComp 中的技能触发逻辑,改为直接读取组件内的配置。 这消除了对全局静态配置的依赖,使技能触发逻辑与实体数据更紧密地绑定,提高了代码的内聚性和可维护性。
This commit is contained in:
@@ -93,10 +93,9 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
|
||||
/** 检查并触发受击附加技能 (atked) */
|
||||
private checkAndTriggerAtkedSkills(heroAttrs: HeroAttrsComp, heroView: HeroViewComp) {
|
||||
const heroInfo = HeroInfo[heroAttrs.hero_uuid];
|
||||
if (!heroInfo || !heroInfo.atked || heroInfo.atked.length === 0) return;
|
||||
if (!heroAttrs.atked || heroAttrs.atked.length === 0) return;
|
||||
|
||||
heroInfo.atked.forEach(atkConfig => {
|
||||
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,
|
||||
@@ -274,11 +273,10 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
TAttrsComp.is_dead = true;
|
||||
|
||||
// 触发死亡技能
|
||||
const heroInfo = HeroInfo[TAttrsComp.hero_uuid];
|
||||
if (heroInfo && heroInfo.dead && heroInfo.dead.length > 0) {
|
||||
if (TAttrsComp.dead && TAttrsComp.dead.length > 0) {
|
||||
const view = entity.get(HeroViewComp);
|
||||
if (view) {
|
||||
heroInfo.dead.forEach((uuid: number) => {
|
||||
TAttrsComp.dead.forEach((uuid: number) => {
|
||||
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
|
||||
s_uuid: uuid,
|
||||
heroAttrs: TAttrsComp,
|
||||
|
||||
Reference in New Issue
Block a user