Tweaked turret AI

This commit is contained in:
Marco 2025-03-03 15:21:24 +01:00
commit a8c493c27a
4 changed files with 77 additions and 58 deletions

View file

@ -60,10 +60,9 @@ public partial class EnemyTurretRotationMovement : MovementHandler
switch (_actorAi.State)
{
case EnemyState.Idle:
if (_playerDetection != null && IsPlayerInSight)
if (_playerDetection != null && IsPlayerInRange && IsPlayerInSight)
{
_actorAi.State = EnemyState.Alert;
GD.Print("Switching to alert");
}
break;
@ -75,10 +74,14 @@ public partial class EnemyTurretRotationMovement : MovementHandler
_lastPlayerPosition = _playerDetection.CachedPlayer.GlobalPosition;
}
if (IsPlayerInSight)
if (IsPlayerInRange && IsPlayerInSight)
{
Shoot();
}
else
{
_actorAi.State = EnemyState.Idle;
}
break;
}
}

View file

@ -1,4 +1,6 @@
namespace Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.Resources;
public interface IBulletModifier
{