Ensure new pathfinder iterates for the max iterations per tick

This commit is contained in:
fullwall 2024-06-18 00:54:54 +08:00
parent 5e9f04f141
commit 6d1aad513e

View File

@ -50,6 +50,7 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
this.params = params;
destination = dest;
this.npc = npc;
planner = new AStarPlanner(params, npc.getEntity().getLocation(), destination);
}
@Override
@ -77,20 +78,15 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
@Override
public boolean update() {
if (plan == null) {
if (planner == null) {
planner = new AStarPlanner(params, npc.getEntity().getLocation(), destination);
}
if (planner != null) {
CancelReason reason = planner.tick(Setting.ASTAR_ITERATIONS_PER_TICK.asInt(),
Setting.MAXIMUM_ASTAR_ITERATIONS.asInt());
if (reason != null) {
setCancelReason(reason);
}
plan = planner.plan;
if (plan != null) {
if (reason == null || plan == null)
return false;
setCancelReason(reason);
planner = null;
}
}
if (getCancelReason() != null || plan == null || plan.isComplete())
return true;
if (vector == null) {