Files
pixelheros/assets/script/todo.md
walkpan 6a0db764d7 docs: 添加 HeroAttrsComp 架构问题的待办事项
记录 HeroAttrsComp 组件中数据层与表现层耦合的问题,并列出后续可能的重构方向
2025-12-21 00:26:57 +08:00

12 lines
646 B
Markdown
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.
1. [待评估] HeroAttrsComp 架构问题:数据层与表现层耦合
- 位置assets/script/game/hero/HeroAttrsComp.ts 的 add_hp、add_mp
- 问题:属性组件中直接通过 this.ent.get(HeroViewComp) 更新视图,
数据层与表现层强耦合,不利于复用(例如无头战斗逻辑)。
- TODO后续根据整体架构再决定是否重构方向预留如下
- 移除 HeroAttrsComp 中对 HeroViewComp 的直接依赖,仅维护数值;
- 使用事件或 System 把 hp/mp 变更同步给视图组件;
- 保证 HeroAttrsComp 只处理战斗数值逻辑,不直接操作表现层。