From 2d338b5fb7d97c5ff3ef745a770a3f7f74b2ffd5 Mon Sep 17 00:00:00 2001 From: Obique Date: Sun, 24 Jun 2018 15:43:55 -0500 Subject: [PATCH] Fixed FLIP patrol routes --- .../objects/swg/custom/PatrolAIObject.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/projectswg/holocore/resources/support/objects/swg/custom/PatrolAIObject.java b/src/main/java/com/projectswg/holocore/resources/support/objects/swg/custom/PatrolAIObject.java index 28c8c3090..9a722331a 100644 --- a/src/main/java/com/projectswg/holocore/resources/support/objects/swg/custom/PatrolAIObject.java +++ b/src/main/java/com/projectswg/holocore/resources/support/objects/swg/custom/PatrolAIObject.java @@ -32,7 +32,6 @@ import com.projectswg.holocore.resources.support.data.server_info.loader.NpcPatr import com.projectswg.holocore.resources.support.npc.ai.AINavigationSupport; import com.projectswg.holocore.resources.support.npc.spawn.Spawner.ResolvedPatrolWaypoint; import com.projectswg.holocore.resources.support.objects.swg.SWGObject; -import me.joshlarson.jlcommon.log.Log; import java.util.*; import java.util.concurrent.CopyOnWriteArrayList; @@ -79,22 +78,22 @@ public class PatrolAIObject extends AIObject { } private void createPlannedRoute() { - { // Creates the full route - Location prevLocation = getLocation(); - SWGObject prevParent = getParent(); - for (ResolvedPatrolWaypoint waypoint : waypoints) { + Location prevLocation = getLocation(); + SWGObject prevParent = getParent(); + for (ResolvedPatrolWaypoint waypoint : waypoints) { + appendPlannedRouteWaypoint(prevParent, prevLocation, waypoint); + prevParent = waypoint.getParent(); + prevLocation = waypoint.getLocation(); + } + if (patrolType.get() == PatrolType.FLIP) { + List waypointsReverse = new ArrayList<>(waypoints); + Collections.reverse(waypointsReverse); + for (ResolvedPatrolWaypoint waypoint : waypointsReverse) { appendPlannedRouteWaypoint(prevParent, prevLocation, waypoint); prevParent = waypoint.getParent(); prevLocation = waypoint.getLocation(); } } - - // Creates a route in reverse for flip patrol types - if (patrolType.get() == PatrolType.FLIP) { - List reversed = new ArrayList<>(plannedRoute); - Collections.reverse(reversed); - plannedRoute.addAll(reversed); - } } private void appendPlannedRouteWaypoint(SWGObject prevParent, Location prevLocation, ResolvedPatrolWaypoint waypoint) { @@ -115,10 +114,7 @@ public class PatrolAIObject extends AIObject { } private void addToPlannedRoute(SWGObject parent, Location location) { - plannedRoute.add(() -> { - MoveObjectIntent.broadcast(this, parent, location, calculateWalkSpeed(), getNextUpdateCount()); - Log.d("AI Log: %s moving to %s @ %s", this, location, parent); - }); + plannedRoute.add(() -> MoveObjectIntent.broadcast(this, parent, location, calculateWalkSpeed(), getNextUpdateCount())); } private void addNopToPlannedRoute() {