perf(英雄属性): 使用脏标签模式优化属性UI更新性能

在 HeroAttrsComp 中添加脏标签标记,仅在属性变化时更新UI
移除 HeroViewComp 中每帧不必要的UI更新调用
添加文档说明优化方案
This commit is contained in:
panw
2025-12-31 14:49:53 +08:00
parent bb0ed6a9c3
commit 05b82a912a
4 changed files with 110 additions and 29 deletions

View File

@@ -14,39 +14,27 @@ import { HeroAttrEvent } from "./HeroAttrEvent";
*
* 系统职责:
* 1. 处理当角色收到attr变更事件时更新角色属性并处理动画展示
*
/**
* 使用方式:
* 在 RootSystem 中注册此系统,它会自动每帧更新所有拥有 HeroAttrsComp 的实体
*/
@ecs.register('HeroAttrEventSystem')
export class HeroAttrEventSystem extends ecs.ComblockSystem
implements ecs.IEntityEnterSystem {
/**
* 过滤器:只处理拥有 HeroAttrsComp 的实体
*/
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;
}
/**
* 系统首次更新前调用(整个系统只调用一次)
*/
firstUpdate(): void {
console.log("[HeroAttrEventSystem] 系统首次更新");
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;
// 移除事件组件(事件处理完成)
}
/**
* 启用调试模式(调试时使用)
*/