将 Weapon 攻击冷却计时器 由 Weapon 内部维护迁移到 TimerModule 维护

This commit is contained in:
2026-06-18 23:23:29 +08:00
parent 25f36d38c9
commit 846e4d6f44
26 changed files with 48 additions and 36 deletions
@@ -4,6 +4,7 @@ using SepCore.Definition;
using SepCore.Entity;
using GameFramework;
using SepCore.CustomUtility;
using SepCore.Timer;
using UnityEngine;
using UnityGameFramework.Runtime;
@@ -41,7 +42,8 @@ namespace SepCore.Entity.Weapon
protected EntityBase _target;
protected float _currAttackTimer;
protected bool _canAttack;
protected TimerHandle _attackTimerHandle;
protected float _sqrRange;
@@ -306,6 +308,26 @@ namespace SepCore.Entity.Weapon
_attackStatCallback = null;
AttackStat = new StatProperty();
}
protected void StartAttackCooldown(float cooldown)
{
_canAttack = false;
_attackTimerHandle = GameEntry.Timer.ScheduleOnce(cooldown, () => _canAttack = true, this);
}
protected void ResetAttackCooldown(float cooldown)
{
GameEntry.Timer.Cancel(_attackTimerHandle);
_canAttack = false;
_attackTimerHandle = GameEntry.Timer.ScheduleOnce(cooldown, () => _canAttack = true, this);
}
protected void CancelAttackCooldown()
{
GameEntry.Timer.Cancel(_attackTimerHandle);
_attackTimerHandle = TimerHandle.Invalid;
_canAttack = false;
}
}
public abstract class WeaponStateBase