diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 276f22b3..f6585b4e 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -28,6 +28,8 @@ import engine.objects.*; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; +import java.awt.geom.Area; +import java.awt.geom.Path2D; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; @@ -962,4 +964,31 @@ public enum BuildingManager { return null; } + public static void bakeNavMesh(Building building) { + + // Build up navmesh by stencil of the + // prop's convex hull + + ArrayList> convexHullList; + convexHullList = _hull_data.get(building.meshUUID); + + for (ArrayList meshEntry : convexHullList) { + + Path2D.Float stencil = new Path2D.Float(); + + for (Vector2f vertex : meshEntry) + stencil.moveTo(vertex.x, vertex.y); + + // enclose polygon + + stencil.moveTo(meshEntry.get(0).x, meshEntry.get(0).y); + + Area stencilArea = new Area(stencil); + building.parentZone.navMesh.subtract(stencilArea); + } + + //add in all the regions to the navMesh + for (Regions region : building.getBounds().getRegions()) + building.parentZone.navMesh.add(region.getArea()); + } } diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 1fef5296..ea9fcfd7 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -25,7 +25,6 @@ import engine.job.JobScheduler; import engine.jobs.DoorCloseJob; import engine.jobs.SiegeSpireWithdrawlJob; import engine.math.Bounds; -import engine.math.Vector2f; import engine.math.Vector3f; import engine.math.Vector3fImmutable; import engine.net.ByteBufferWriter; @@ -35,8 +34,6 @@ import engine.net.client.msg.UpdateObjectMsg; import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; -import java.awt.geom.Area; -import java.awt.geom.Path2D; import java.sql.ResultSet; import java.sql.SQLException; import java.time.LocalDateTime; @@ -1007,7 +1004,7 @@ public class Building extends AbstractWorldObject { if (this.upgradeDateTime != null) BuildingManager.submitUpgradeJob(this); - this.updateNavMesh(); // update the navmesh of the parent zone + BuildingManager.bakeNavMesh(this); // update the navmesh of the parent zone } public synchronized boolean setOwner(AbstractCharacter newOwner) { @@ -1536,31 +1533,4 @@ public class Building extends AbstractWorldObject { } - public void updateNavMesh() { - - // Build up navmesh by stencil of the - // prop's convex hull - - ArrayList> convexHullList; - convexHullList = BuildingManager._hull_data.get(this.meshUUID); - - for (ArrayList meshEntry : convexHullList) { - - Path2D.Float stencil = new Path2D.Float(); - - for (Vector2f vertex : meshEntry) - stencil.moveTo(vertex.x, vertex.y); - - // enclose polygon - - stencil.moveTo(meshEntry.get(0).x, meshEntry.get(0).y); - - Area stencilArea = new Area(stencil); - this.parentZone.navMesh.subtract(stencilArea); - } - - //add in all the regions to the navMesh - for (Regions region : this.getBounds().getRegions()) - this.parentZone.navMesh.add(region.getArea()); - } }