Files
pixelheros/assets/script/game/hero/HeroAttrEventSystem.ts
panw 05b82a912a perf(英雄属性): 使用脏标签模式优化属性UI更新性能
在 HeroAttrsComp 中添加脏标签标记,仅在属性变化时更新UI
移除 HeroViewComp 中每帧不必要的UI更新调用
添加文档说明优化方案
2025-12-31 14:49:53 +08:00

50 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 设计理念:
* - SystemHeroAttrEventSystem处理属性更新事件
*
* 系统职责:
* 1. 处理当角色收到attr变更事件时更新角色属性并处理动画展示
*/
@ecs.register('HeroAttrEventSystem')
export class HeroAttrEventSystem extends ecs.ComblockSystem
implements ecs.ISystemUpdate, ecs.IEntityEnterSystem {
filter(): ecs.IMatcher {
return ecs.allOf(HeroAttrsComp,HeroAttrEvent);
}
entityEnter(e: ecs.Entity): void {
if(!smc.mission.play || smc.mission.pause) return;
}
update(e: ecs.Entity): void {
if(!smc.mission.play || smc.mission.pause) return;
const model = e.get(HeroAttrsComp);
if (!model || model.is_dead) return;
const event = e.get(HeroAttrEvent);
if (!event) return;
// 移除事件组件(事件处理完成)
}
/**
* 启用调试模式(调试时使用)
*/
enableDebug() {
}
/**
* 禁用调试模式(正式运行)
*/
disableDebug() {
}
}