mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 21:45:55 +00:00
Enemy AI
This commit is contained in:
parent
242222a4d7
commit
f2bdec7ad7
14 changed files with 200 additions and 21 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue