mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Enemy AI
This commit is contained in:
parent
242222a4d7
commit
f2bdec7ad7
14 changed files with 200 additions and 21 deletions
|
|
@ -27,9 +27,11 @@ public partial class Alert : EnemyStateBase
|
|||
base.EnterState();
|
||||
GD.Print($"Entered {Name}");
|
||||
NavigationModule.Init(MainObject);
|
||||
|
||||
PlayerDetection.SetRange(StorageModule.Root.EnemyResource.PlayerDetectionRange);
|
||||
|
||||
_isPlayerInRange = PlayerDetection.IsPlayerInRange(StorageModule.Root.EnemyResource.PlayerDetectionRange);
|
||||
//_isPlayerInRange = PlayerDetection.IsPlayerInRange(StorageModule.Root.EnemyResource.ViewRange);
|
||||
//GD.Print($"Player In Range: {_isPlayerInRange}");
|
||||
|
||||
PlayerDetection.PlayerInRange += PlayerDetectionOnPlayerInRange;
|
||||
|
||||
|
|
@ -38,10 +40,8 @@ public partial class Alert : EnemyStateBase
|
|||
DamageReceiver.ChangeState(true);
|
||||
|
||||
DamageReceiver.HealthProvider.ResourceDepleted += HealthProviderOnResourceDepleted;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void HealthProviderOnResourceDepleted()
|
||||
{
|
||||
ChangeState(EnemyState.Dead);
|
||||
|
|
@ -68,14 +68,14 @@ public partial class Alert : EnemyStateBase
|
|||
|
||||
private void PlayerDetectionOnPlayerInRange()
|
||||
{
|
||||
_isPlayerInRange = true;
|
||||
//_isPlayerInRange = true;
|
||||
GD.Print("Player In Range");
|
||||
}
|
||||
|
||||
public override void PhysicsProcessState(double delta)
|
||||
{
|
||||
base.PhysicsProcessState(delta);
|
||||
if (_isPlayerInRange && PlayerDetection.IsPlayerInSight())
|
||||
if (PlayerDetection.IsPlayerInRange(StorageModule.Root.EnemyResource.ViewRange) && PlayerDetection.IsPlayerInSight())
|
||||
{
|
||||
GD.Print("Player is in sight, shooting");
|
||||
StateMachine.SetState(EnemyState.Shooting);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue