public void UpdatePath() { Location goal = TargetPosition; if (goal.IsNaN()) { if (TargetEntity == null) { Path = null; return; } goal = TargetEntity.GetPosition(); } Location selfpos = GetPosition(); if ((goal - selfpos).LengthSquared() > MaxPathFindDistance * MaxPathFindDistance) { TargetPosition = Location.NaN; // TODO: Configurable "can't find path" result -> giveup vs. teleport TargetEntity = null; Path = null; return; } List <Location> tpath = TheRegion.FindPathAsyncDouble(selfpos, goal, MaxPathFindDistance, new PathfinderOptions()); if (tpath == null) { TargetPosition = Location.NaN; // TODO: Configurable "can't find path" result -> giveup vs. teleport TargetEntity = null; Path = null; return; } Path = new ListQueue <Location>(tpath); PathUpdate = 1; // TODO: Configurable update time }