using DoomDeathmatch.Component.MVC.Enemy; using DoomDeathmatch.Component.MVC.Health; using Engine.Util; namespace DoomDeathmatch.Script.Model.Enemy.Attack; public abstract class CooldownAttackBehavior( EnemyController parEnemyController, HealthController parHealthController, float parCooldown) : AttackBehavior(parEnemyController, parHealthController) { private readonly TickableTimer _tickableTimer = new(parCooldown); public sealed override bool Attack(double parDeltaTime) { _tickableTimer.Update(parDeltaTime); if (CanAttack()) { if (!_tickableTimer.IsFinished) return false; var result = ActivateAttack(); _tickableTimer.Reset(); return result; } return false; } protected abstract bool CanAttack(); protected abstract bool ActivateAttack(); }