Browse Source

shape

hull4
FatBoy-DOTC 12 months ago
parent
commit
d7159758a1
  1. 19
      src/engine/gameManager/ZoneManager.java
  2. 21
      src/engine/mobileAI/utilities/PathingUtilities.java
  3. 3
      src/engine/server/world/WorldServer.java

19
src/engine/gameManager/ZoneManager.java

@ -435,23 +435,4 @@ public enum ZoneManager { @@ -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());
}
}
}
}
}
}

21
src/engine/mobileAI/utilities/PathingUtilities.java

@ -1,8 +1,13 @@ @@ -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 { @@ -18,6 +23,22 @@ public class PathingUtilities {
this.parentBuilding = parent;
this.neighbors = new ArrayList<>();
}
public ArrayList<Node> 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;
}
}
}

3
src/engine/server/world/WorldServer.java

@ -437,9 +437,6 @@ public class WorldServer { @@ -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

Loading…
Cancel
Save