From 9615f85f0d067ca5a12536483db5ab46a4c12a59 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 14 Nov 2023 21:11:21 -0600 Subject: [PATCH] shape --- src/engine/gameManager/ZoneManager.java | 16 ++++++++++++++++ src/engine/server/world/WorldServer.java | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/engine/gameManager/ZoneManager.java b/src/engine/gameManager/ZoneManager.java index b842b968..000de7cc 100644 --- a/src/engine/gameManager/ZoneManager.java +++ b/src/engine/gameManager/ZoneManager.java @@ -14,6 +14,7 @@ import engine.math.Bounds; import engine.math.Vector2f; import engine.math.Vector3f; import engine.math.Vector3fImmutable; +import engine.mobileAI.utilities.PathingUtilities; import engine.objects.Building; import engine.objects.City; import engine.objects.Zone; @@ -21,6 +22,7 @@ import engine.objects.ZoneTemplate; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.awt.geom.Path2D; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -433,4 +435,18 @@ public enum ZoneManager { return localAltitude < zone.sea_level; } + + public static void LinkNavNodes(){ + for(Zone zone : getAllZones()){ + for(PathingUtilities.Node node : zone.navNodes){ + for(PathingUtilities.Node potentialNeighbor : zone.navNodes){ + 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.neighbors.add(potentialNeighbor); + } + } + } + } + } + } } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index acc86e1c..c4ef2ee6 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -437,6 +437,9 @@ 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