using DoomDeathmatch.Component.MVC.Controller;

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

public class CloseContinuousAttackBehavior(
  EnemyController parEnemyController,
  HealthController parHealthController,
  float parRadius,
  float parDamage)
  : AttackBehavior(parEnemyController, parHealthController)
{
  public override bool Attack(double parDeltaTime)
  {
    var distanceSquared =
      (_enemyController.GameObject.Transform.Translation - _healthController.GameObject.Transform.Translation)
      .LengthSquared;

    if (distanceSquared <= parRadius * parRadius)
    {
      _healthController.TakeDamage(parDamage * (float)parDeltaTime);
      return true;
    }

    return false;
  }
}