feat(skill&shield): 实现护盾持续时间功能,调整魔法盾冷却
1. 为护盾技能添加duration配置,支持永久/限时护盾 2. 新增护盾倒计时逻辑,到期自动清空护盾 3. 调整英雄6301魔法盾的冷却时间为10秒,新增7秒持续时长配置 4. 重构HeroAttrsComp,新增护盾持续时间字段与清空护盾方法
This commit is contained in:
@@ -28,18 +28,34 @@ const TICK_STEP = 0.1;
|
||||
export class BuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
||||
private timer = new Timer(TICK_STEP);
|
||||
|
||||
// HeroAttrsComp 可选,用于 DoT/HoT 的血量结算与护盾倒计时
|
||||
private processShieldTimer(attrsComp: HeroAttrsComp | null): void {
|
||||
if (!attrsComp) return;
|
||||
// 永久护盾(duration<=0)不参与倒计时
|
||||
if (attrsComp.shield_duration <= 0) return;
|
||||
attrsComp.shield_duration -= TICK_STEP;
|
||||
if (attrsComp.shield_duration <= 0) {
|
||||
attrsComp.clear_shield();
|
||||
mLogger.log(DEBUG, "BuffSystem", `护盾到期: ${attrsComp.hero_name}(eid:${attrsComp.ent?.eid ?? "-"}) 护盾已清空`);
|
||||
}
|
||||
}
|
||||
|
||||
// filter 改为 allOf(HeroAttrsComp):护盾倒计时挂在 HeroAttrsComp 上,
|
||||
// 若按 BuffComp 过滤,无 buff 的实体不会被遍历,护盾到期清空会失效
|
||||
filter(): ecs.IMatcher {
|
||||
return ecs.allOf(BuffComp);
|
||||
return ecs.allOf(HeroAttrsComp);
|
||||
}
|
||||
|
||||
update(e: ecs.Entity): void {
|
||||
if (!this.timer.update(this.dt)) return;
|
||||
|
||||
const buffComp = e.get(BuffComp);
|
||||
if (!buffComp) return;
|
||||
// HeroAttrsComp 必有(filter 保证),用于 DoT/HoT 血量结算与护盾倒计时
|
||||
const attrsComp = e.get(HeroAttrsComp);
|
||||
this.processShieldTimer(attrsComp);
|
||||
|
||||
// HeroAttrsComp 可选,用于 DoT/HoT 的血量结算
|
||||
const attrsComp = e.has(HeroAttrsComp) ? e.get(HeroAttrsComp) : null;
|
||||
// BuffComp 可选:无 buff 时仅做护盾倒计时
|
||||
const buffComp = e.has(BuffComp) ? e.get(BuffComp) : null;
|
||||
if (!buffComp) return;
|
||||
|
||||
// ---- 处理所有 buff 层 ----
|
||||
let anyChanged = false;
|
||||
|
||||
Reference in New Issue
Block a user