SupaLidlGame/State/Thinker/IdleState.cs

29 lines
630 B
C#
Raw Normal View History

2023-08-05 23:50:08 -07:00
using Godot;
namespace SupaLidlGame.State.Thinker;
public partial class IdleState : ThinkerState
{
[Export]
public ThinkerState PursueState { get; set; }
[Export]
public float MinTargetDistance { get; set; }
public override ThinkerState Think()
{
var bestTarget = NPC.FindBestTarget();
if (bestTarget is not null)
{
var pos = bestTarget.GlobalPosition;
var dist = NPC.GlobalPosition.DistanceTo(pos);
if (dist < MinTargetDistance)
{
return PursueState;
}
}
return base.Think();
}
}