diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index 8a3ed4d1..313e6472 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -435,23 +435,4 @@ public enum ZoneManager { return localAltitude < zone.sea_level; } - - public static void LinkNavNodes(){ - //TODO optimize - for(Zone zone : getAllZones()){ - for(PathingUtilities.Node node : zone.navNodes){ - for(PathingUtilities.Node potentialNeighbor : zone.navNodes){ - try { - for (Path2D.Float obstacle : zone.navObstacles) { - if (!node.equals(potentialNeighbor) && !obstacle.intersects(node.location.x, node.location.y, potentialNeighbor.location.x, potentialNeighbor.location.y) && node.location.distance(potentialNeighbor.location) < 50) { - node.neighbors.add(potentialNeighbor); - } - } - } catch(Exception e){ - Logger.error("Failed To Check Neighbors Of Node In Zone: " + zone.getObjectUUID()); - } - } - } - } - } } diff --git a/src/engine/mobileAI/utilities/PathingUtilities.java b/src/engine/mobileAI/utilities/PathingUtilities.java index 596b1b6a..29e00990 100644 --- a/src/engine/mobileAI/utilities/PathingUtilities.java +++ b/src/engine/mobileAI/utilities/PathingUtilities.java @@ -1,8 +1,13 @@ package engine.mobileAI.utilities; +import engine.gameManager.ZoneManager; import engine.math.Vector2f; +import engine.math.Vector3fImmutable; import engine.objects.Building; import engine.objects.Regions; +import engine.objects.Zone; +import org.pmw.tinylog.Logger; +import java.awt.geom.Path2D; import java.util.ArrayList; public class PathingUtilities { @@ -18,6 +23,22 @@ public class PathingUtilities { this.parentBuilding = parent; this.neighbors = new ArrayList<>(); } + public ArrayList getNeighbors(){ + if(neighbors.size() == 0){ + Zone zone = ZoneManager.findSmallestZone(new Vector3fImmutable(this.location.x,0,this.location.y)); + if(zone == null) + return null; + + for(Node potentialNeighbor : zone.navNodes){ + for (Path2D.Float obstacle : zone.navObstacles) { + if (!this.equals(potentialNeighbor) && !obstacle.intersects(this.location.x, this.location.y, potentialNeighbor.location.x, potentialNeighbor.location.y) && this.location.distance(potentialNeighbor.location) < 65) { + this.neighbors.add(potentialNeighbor); + } + } + } + } + return this.neighbors; + } } } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index c4ef2ee6..acc86e1c 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -437,9 +437,6 @@ public class WorldServer { DbManager.NPCQueries.GET_ALL_NPCS(); DbManager.MobQueries.GET_ALL_MOBS(); - Logger.info("Generating Neighbors for NavNodes"); - ZoneManager.LinkNavNodes(); - Logger.info("time to load World Objects: " + (System.currentTimeMillis() - start) + " ms"); // Configure realms for serialization