Update thinkers to handle no nav agents

issue-templates
John Montagu, the 4th Earl of Sandvich 2024-04-27 18:52:38 -07:00
parent f07ce2f5df
commit 40ba0285f4
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
1 changed files with 2 additions and 2 deletions

View File

@ -75,13 +75,13 @@ public partial class IdleState : ThinkerState
public override ThinkerState PhysicsProcess(double delta)
{
if (_isReturning && NavigationAgent.IsTargetReachable())
if (_isReturning && (NavigationAgent?.IsTargetReachable() ?? false))
{
var navPos = NavigationAgent.GetNextPathPosition();
NPC.Direction = NPC.GlobalPosition.DirectionTo(navPos);
}
if (NavigationAgent.IsTargetReached())
if (NavigationAgent?.IsTargetReached() ?? false)
{
NPC.Direction = Vector2.Zero;
}