using DoomDeathmatch.Component.MVC.Controller;
using Engine.Util;

namespace DoomDeathmatch.Component.MVC.Model.Enemy.Attack;

public class CloseCooldownAttackBehavior(
  EnemyController parEnemyController,
  HealthController parHealthController,
  float parRadius,
  float parCooldown,
  float parDamage)
  : CooldownAttackBehavior(parEnemyController, parHealthController, parCooldown)
{
  protected override bool CanAttack()
  {
    var distanceSquared =
      (_enemyController.GameObject.Transform.Translation - _healthController.GameObject.Transform.Translation)
      .LengthSquared;

    return distanceSquared <= parRadius * parRadius;
  }

  protected override bool ActivateAttack()
  {
    _healthController.TakeDamage(parDamage);

    return true;
  }
}