From ee7c0ea69c38e61c4db566a6099346a330f75ee4 Mon Sep 17 00:00:00 2001 From: pan Date: Thu, 23 Jul 2026 17:09:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(buff=E7=B3=BB=E7=BB=9F):=20=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E5=B9=B6=E9=87=8D=E6=9E=84buff=E8=AE=A1=E6=97=B6?= =?UTF-8?q?=E4=B8=8E=E7=BB=93=E7=AE=97=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 移除旧的冰霜、眩晕状态旧字段兼容处理代码 2. 调整周期效果结算时机,移到期判断之前避免丢失末次tick 3. 更新注释说明,移除过时的兼容期注释内容 --- assets/script/game/hero/BuffSystem.ts | 28 ++++++--------------------- 1 file changed, 6 insertions(+), 22 deletions(-) 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);