diff --git a/src/engine/gameManager/BuildingManager.java b/src/engine/gameManager/BuildingManager.java index 882b1261..3be25723 100644 --- a/src/engine/gameManager/BuildingManager.java +++ b/src/engine/gameManager/BuildingManager.java @@ -1014,14 +1014,49 @@ public enum BuildingManager { cornersAndFaces.add(new Vector2f(building.loc.x,building.loc.z - Y)); cornersAndFaces.add(new Vector2f(building.loc.x,building.loc.z + Y)); for(Vector2f point : cornersAndFaces){ - if(!NavigationManager.pointIsBlocked(new Vector3fImmutable(point.x,building.loc.y,point.y))){ - building.parentZone.navNodes.add(new PathingUtilities.Node(point,null,building)); + if (!NavigationManager.pointIsBlocked(new Vector3fImmutable(point.x, building.loc.y, point.y))) { + building.parentZone.navNodes.add(new PathingUtilities.Node(point, null, building)); } } //add region centers to the zones navNodes list - for(Regions region : building.getBounds().getRegions()){ - building.parentZone.navNodes.add(new PathingUtilities.Node(new Vector2f(region.center.x,region.center.z),region,building)); + for (Regions region : building.getBounds().getRegions()) { + building.parentZone.navNodes.add(new PathingUtilities.Node(new Vector2f(region.center.x, region.center.z), region, building)); + } + } + + public static Path2D.Float hullToPath2d(String[] hullString) { + + ArrayList vertices = new ArrayList<>(); + ArrayList floats = new ArrayList<>(); + Path2D.Float outPath = new Path2D.Float(); + + // Build Arraylist of vertices + + for (String floatString : hullString) { + + floats.add(Float.parseFloat(floatString)); + + if (floats.size() == 2) { + vertices.add(new Vector2f(floats.get(0), floats.get(1))); + floats.clear(); + } + } + + // Build Path from vertices + + outPath.moveTo(vertices.get(0).x, vertices.get(0).y); + + for (Vector2f vertex : vertices) { + + if (outPath.getCurrentPoint() == null) + outPath.moveTo(vertex.x, vertex.y); + else + outPath.lineTo(vertex.x, vertex.y); + + outPath.closePath(); + } + return outPath; } }