Added collision mask for navigation provider

This commit is contained in:
MaddoScientisto 2025-02-19 19:29:35 +01:00
commit 1f6c881b92
3 changed files with 7 additions and 3 deletions

View file

@ -25,6 +25,9 @@ public partial class EnemyNavigationMovement : MovementHandler
[Export] public float PlayerDisengageRange = 500f;
[Export(PropertyHint.Layers2DPhysics)]
public uint CollisionMask { get; set; }
public bool NavigationEnabled
{
get => _actorAi is not null && _actorAi.Ai is AiState.Enabled && _navigationEnabled && _navigationAgent != null;
@ -42,7 +45,7 @@ public partial class EnemyNavigationMovement : MovementHandler
private bool IsPlayerInRange => _playerDetection is { IsPlayerInRange: true };
private bool IsPlayerInSight =>
_playerDetection is not null && _playerDetection.IsPlayerInSight(_parent.CollisionMask);
_playerDetection is not null && _playerDetection.IsPlayerInSight(CollisionMask);
public override void Init(Actor parent)
{
@ -80,7 +83,7 @@ public partial class EnemyNavigationMovement : MovementHandler
switch (_actorAi.State)
{
case EnemyState.Idle:
if (_playerDetection != null && _playerDetection.IsPlayerInSight(_parent.CollisionMask))
if (_playerDetection != null && IsPlayerInSight)
{
_actorAi.State = EnemyState.Alert;
GD.Print("Switching to alert");