Files
doom-dm/DoomDeathmatch/src/Script/Model/Enemy/Attack/CloseContinuousAttackBehavior.cs
2025-01-06 22:36:52 +03:00

27 lines
753 B
C#

using DoomDeathmatch.Component.MVC.Enemy;
using DoomDeathmatch.Component.MVC.Health;
namespace DoomDeathmatch.Script.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;
}
}