Line of sight for enemy
This commit is contained in:
@@ -17,6 +17,8 @@ public interface IEnemy : ICharacterBody3D
|
||||
public EnemyStatInfo EnemyStatInfo { get; set; }
|
||||
|
||||
public NavigationAgent3D NavAgent { get; set; }
|
||||
|
||||
public Area3D LineOfSight { get; set; }
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
@@ -43,6 +45,8 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
|
||||
[Node] public NavigationAgent3D NavAgent { get; set; } = default!;
|
||||
|
||||
[Node] public Area3D LineOfSight { get; set; } = default!;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
EnemyLogic = new EnemyLogic();
|
||||
@@ -55,6 +59,12 @@ public partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLogic>
|
||||
{
|
||||
CurrentHP = new AutoProp<double>(EnemyStatInfo.MaximumHP);
|
||||
CurrentHP.Sync += OnHPChanged;
|
||||
LineOfSight.BodyEntered += LineOfSight_BodyEntered;
|
||||
}
|
||||
|
||||
private void LineOfSight_BodyEntered(Node3D body)
|
||||
{
|
||||
EnemyLogic.Input(new EnemyLogic.Input.Alerted());
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
|
||||
Reference in New Issue
Block a user