mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-21 05:13:48 +00:00
Added collision mask for navigation provider
This commit is contained in:
parent
f32a347f48
commit
1f6c881b92
3 changed files with 7 additions and 3 deletions
|
|
@ -257,6 +257,7 @@ Ai = 0
|
||||||
[node name="NavigationMovementProvider" type="Node2D" parent="." node_paths=PackedStringArray("_playerDetection")]
|
[node name="NavigationMovementProvider" type="Node2D" parent="." node_paths=PackedStringArray("_playerDetection")]
|
||||||
script = ExtResource("7_fvl12")
|
script = ExtResource("7_fvl12")
|
||||||
_navigationEnabled = true
|
_navigationEnabled = true
|
||||||
|
CollisionMask = 81
|
||||||
_playerDetection = NodePath("../PlayerDetection")
|
_playerDetection = NodePath("../PlayerDetection")
|
||||||
|
|
||||||
[node name="PlayerDetection" type="Area2D" parent="."]
|
[node name="PlayerDetection" type="Area2D" parent="."]
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -25,6 +25,9 @@ public partial class EnemyNavigationMovement : MovementHandler
|
||||||
|
|
||||||
[Export] public float PlayerDisengageRange = 500f;
|
[Export] public float PlayerDisengageRange = 500f;
|
||||||
|
|
||||||
|
[Export(PropertyHint.Layers2DPhysics)]
|
||||||
|
public uint CollisionMask { get; set; }
|
||||||
|
|
||||||
public bool NavigationEnabled
|
public bool NavigationEnabled
|
||||||
{
|
{
|
||||||
get => _actorAi is not null && _actorAi.Ai is AiState.Enabled && _navigationEnabled && _navigationAgent != null;
|
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 IsPlayerInRange => _playerDetection is { IsPlayerInRange: true };
|
||||||
|
|
||||||
private bool IsPlayerInSight =>
|
private bool IsPlayerInSight =>
|
||||||
_playerDetection is not null && _playerDetection.IsPlayerInSight(_parent.CollisionMask);
|
_playerDetection is not null && _playerDetection.IsPlayerInSight(CollisionMask);
|
||||||
|
|
||||||
public override void Init(Actor parent)
|
public override void Init(Actor parent)
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +83,7 @@ public partial class EnemyNavigationMovement : MovementHandler
|
||||||
switch (_actorAi.State)
|
switch (_actorAi.State)
|
||||||
{
|
{
|
||||||
case EnemyState.Idle:
|
case EnemyState.Idle:
|
||||||
if (_playerDetection != null && _playerDetection.IsPlayerInSight(_parent.CollisionMask))
|
if (_playerDetection != null && IsPlayerInSight)
|
||||||
{
|
{
|
||||||
_actorAi.State = EnemyState.Alert;
|
_actorAi.State = EnemyState.Alert;
|
||||||
GD.Print("Switching to alert");
|
GD.Print("Switching to alert");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue