diff --git a/assets/script/game/hero/BuffSystem.ts b/assets/script/game/hero/BuffSystem.ts index 5798a819..8cad3e10 100644 --- a/assets/script/game/hero/BuffSystem.ts +++ b/assets/script/game/hero/BuffSystem.ts @@ -34,25 +34,9 @@ export class BuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate const buffComp = e.get(BuffComp); if (!buffComp) return; - // HeroAttrsComp 可选,用于 DoT/HoT 的血量结算和兼容字段 + // HeroAttrsComp 可选,用于 DoT/HoT 的血量结算 const attrsComp = e.has(HeroAttrsComp) ? e.get(HeroAttrsComp) : null; - // ---- 兼容期:递减旧字段 frost_end_time / stun_end_time ---- - if (attrsComp) { - if (attrsComp.frost_end_time > 0) { - attrsComp.frost_end_time -= TICK_STEP; - if (attrsComp.frost_end_time <= 0) { - attrsComp.frost_end_time = 0; - } - } - if (attrsComp.stun_end_time > 0) { - attrsComp.stun_end_time -= TICK_STEP; - if (attrsComp.stun_end_time <= 0) { - attrsComp.stun_end_time = 0; - } - } - } - // ---- 处理所有 buff 层 ---- let anyChanged = false; buffComp.buffs.forEach((layers, buffId) => { @@ -63,16 +47,16 @@ export class BuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate for (let i = layers.length - 1; i >= 0; i--) { const layer = layers[i]; + // 周期效果结算(先于到期判断,避免到期帧丢失末次 tick) + if (cfg.tick && attrsComp) { + this.processTick(layer, cfg.tick, attrsComp); + } + // 永久 buff(duration<=0)不递减 remaining if (cfg.duration > 0) { layer.remaining -= TICK_STEP; } - // 周期效果结算(仅在未到期时) - if (cfg.tick && layer.remaining > 0 && attrsComp) { - this.processTick(layer, cfg.tick, attrsComp); - } - // 到期移除 if (cfg.duration > 0 && layer.remaining <= 0) { layers.splice(i, 1);