}
}
}
private void updateWaypoints(HumanNPC npc) {
WaypointPath waypoints = npc.getWaypoints();
switch (waypoints.size()) {
case 0:
break;
case 1:
// TODO: merge the default and this case.
if (waypoints.currentIndex() >= 1) {
if (!waypoints.isStarted()) {
waypoints.schedule(npc, 0);
}
if (waypoints.isStarted() && !npc.isPaused() && npc.getHandle().pathFinished()) {
waypoints.setIndex(0);
}
} else {
if (!npc.getWaypoints().isStarted()) {
PathUtils.createPath(npc, npc.getNPCData().getLocation(), -1, -1,
Settings.getDouble("PathfindingRange"));
waypoints.setStarted(true);
}
if (waypoints.isStarted() && !npc.isPaused() && npc.getHandle().pathFinished()) {
waypoints.setIndex(1);
}
}
if (waypoints.isStarted() && !npc.isPaused() && npc.getHandle().pathFinished()) {
waypoints.setStarted(false);
waypoints.onReach(npc);
}
break;
default:
if (!waypoints.isStarted()) {
waypoints.scheduleNext(npc);
}
if (waypoints.isStarted() && !npc.isPaused() && npc.getHandle().pathFinished()) {
waypoints.setIndex(waypoints.currentIndex() + 1);
waypoints.setStarted(false);
waypoints.onReach(npc);
}
}
}