This commit is contained in:
Marco 2025-03-21 10:30:44 +01:00
commit f2bdec7ad7
14 changed files with 200 additions and 21 deletions

View file

@ -26,7 +26,7 @@ public partial class Shooting : EnemyStateBase
base.EnterState();
GD.Print($"Entered {Name}");
_isPlayerInRange = PlayerDetection.IsPlayerInRange(StorageModule.Root.EnemyResource.PlayerDetectionRange);
//_isPlayerInRange = PlayerDetection.IsPlayerInRange(StorageModule.Root.EnemyResource.ViewRange);
PlayerDetection.PlayerOutOfRange += PlayerDetectionOnPlayerOutOfRange;
@ -55,7 +55,6 @@ public partial class Shooting : EnemyStateBase
private void PlayerDetectionOnPlayerOutOfRange()
{
_isPlayerInRange = false;
StateMachine.SetState(EnemyState.Alert);
}
@ -75,7 +74,7 @@ public partial class Shooting : EnemyStateBase
{
base.PhysicsProcessState(delta);
if (_isPlayerInRange && PlayerDetection.IsPlayerInSight())
if (PlayerDetection.IsPlayerInRange(StorageModule.Root.EnemyResource.ViewRange) && PlayerDetection.IsPlayerInSight())
{
// SHOOT
Shoot();
@ -84,7 +83,6 @@ public partial class Shooting : EnemyStateBase
{
StateMachine.SetState(EnemyState.Alert);
}
}
private void Shoot()
@ -92,7 +90,6 @@ public partial class Shooting : EnemyStateBase
if (EquippedWeapon == null) return;
if (!PlayerDetection.LastKnownPlayerPosition.HasValue) return;
var direction = ( PlayerDetection.LastKnownPlayerPosition.Value - MainObject.GlobalPosition).Normalized();
// Shoot at the player's last known position