feat(hero): 添加英雄属性事件处理系统及组件
添加 HeroAttrEvent 组件用于存储属性变更事件队列 添加 HeroAttrEventSystem 系统用于处理属性变更事件并更新角色属性
This commit is contained in:
61
assets/script/game/hero/HeroAttrEventSystem.ts
Normal file
61
assets/script/game/hero/HeroAttrEventSystem.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import { Timer } from "db://oops-framework/core/common/timer/Timer";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { Attrs } from "../common/config/HeroAttrs";
|
||||
import { HeroUpSet } from "../common/config/heroSet";
|
||||
import { HeroSkillsComp } from "./HeroSkills";
|
||||
import { HeroAttrsComp } from "./HeroAttrsComp";
|
||||
import { HeroAttrEvent } from "./HeroAttrEvent";
|
||||
/**
|
||||
* ==================== 英雄属性更新系统 ====================
|
||||
*
|
||||
* 按照 ECS 设计理念:
|
||||
* - System(HeroAttrEventSystem):处理属性更新事件
|
||||
*
|
||||
* 系统职责:
|
||||
* 1. 处理当角色收到attr变更事件时,更新角色属性,并处理动画展示
|
||||
|
||||
*
|
||||
/**
|
||||
* 使用方式:
|
||||
* 在 RootSystem 中注册此系统,它会自动每帧更新所有拥有 HeroAttrsComp 的实体
|
||||
*/
|
||||
@ecs.register('HeroAttrEventSystem')
|
||||
export class HeroAttrEventSystem extends ecs.ComblockSystem
|
||||
implements ecs.IEntityEnterSystem {
|
||||
|
||||
/**
|
||||
* 过滤器:只处理拥有 HeroAttrsComp 的实体
|
||||
*/
|
||||
filter(): ecs.IMatcher {
|
||||
return ecs.allOf(HeroAttrsComp,HeroAttrEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实体首次进入系统时调用(每个实体只调用一次)
|
||||
*/
|
||||
entityEnter(e: ecs.Entity): void {
|
||||
if(!smc.mission.play || smc.mission.pause) return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统首次更新前调用(整个系统只调用一次)
|
||||
*/
|
||||
firstUpdate(): void {
|
||||
console.log("[HeroAttrEventSystem] 系统首次更新");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 启用调试模式(调试时使用)
|
||||
*/
|
||||
enableDebug() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用调试模式(正式运行)
|
||||
*/
|
||||
disableDebug() {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user