refactor(buff系统): 简化并重构buff计时与结算逻辑

1. 移除旧的冰霜、眩晕状态旧字段兼容处理代码
2. 调整周期效果结算时机,移到期判断之前避免丢失末次tick
3. 更新注释说明,移除过时的兼容期注释内容
This commit is contained in:
pan
2026-07-23 17:09:18 +08:00
parent 1afa06efb8
commit ee7c0ea69c

View File

@@ -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);
}
// 永久 buffduration<=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);