diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 3ca96266..c71e9266 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -249,7 +249,7 @@ export class HeroAttrsComp extends ecs.Comp { // ✅ 数据层只负责数据修改,不调用视图层 // let heroView = this.ent.get(HeroViewComp); - // if(heroView){ + // if(heroView && addValue > 0){ // heroView.health(addValue); // } diff --git a/assets/script/game/hero/HeroAttrsSystem.ts b/assets/script/game/hero/HeroAttrsSystem.ts index b09dca48..a51d52d5 100644 --- a/assets/script/game/hero/HeroAttrsSystem.ts +++ b/assets/script/game/hero/HeroAttrsSystem.ts @@ -5,6 +5,7 @@ import { Attrs } from "../common/config/HeroAttrs"; import { HeroUpSet } from "../common/config/heroSet"; import { HeroSkillsComp } from "./HeroSkills"; import { HeroAttrsComp } from "./HeroAttrsComp"; +import { HeroViewComp } from "./HeroViewComp"; import { mLogger } from "../common/Logger"; /** * ==================== 英雄属性更新系统 ==================== @@ -84,8 +85,28 @@ export class HeroAttrSystem extends ecs.ComblockSystem if(this.timer.update(this.dt)){ // 2. HP/MP 自然回复(业务规则) - model.mp += HeroUpSet.MP - model.hp += HeroUpSet.HP + // 加上回血/回蓝属性的影响 + const hpRegen = model.Attrs[Attrs.HP_REGEN] || 0; + const mpRegen = model.Attrs[Attrs.MP_REGEN] || 0; + + model.mp += HeroUpSet.MP + mpRegen; + // model.hp += HeroUpSet.HP + hpRegen; + // model.add_hp(HeroUpSet.HP + hpRegen, true); + + // 回血逻辑 + 视图表现 + const totalHpRegen = HeroUpSet.HP + hpRegen; + if (totalHpRegen > 0) { + model.add_hp(totalHpRegen, true); + // 触发视图层回血特效 + const view = e.get(HeroViewComp); + if (view) { + view.health(totalHpRegen); + } + } else if (totalHpRegen < 0) { + // 如果是扣血(虽然叫 regen),走正常的扣血逻辑? + // 暂时按原样处理,只处理正向回血的特效 + model.add_hp(totalHpRegen, true); + } } // 3. 限制属性值在合理范围内