将 Weapon 攻击冷却计时器 由 Weapon 内部维护迁移到 TimerModule 维护
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user