This commit is contained in:
2023-11-14 22:37:50 -06:00
parent 4621b657e4
commit d482265994
4 changed files with 16 additions and 6 deletions
@@ -30,6 +30,12 @@ public class PathingUtilities {
this.parentBuilding = parent;
this.neighbors = new ArrayList<>();
}
public Node(Node clone){
this.location = clone.location;
this.region = clone.region;
this.parentBuilding = clone.parentBuilding;
this.neighbors = (ArrayList<Node>) clone.neighbors.clone();
}
public ArrayList<Node> getNeighbors(){
if(neighbors.size() == 0){
Zone zone = ZoneManager.findSmallestZone(new Vector3fImmutable(this.location.x,0,this.location.y));
@@ -69,7 +75,7 @@ public class PathingUtilities {
ArrayList<Node> path = new ArrayList<>();
Node startNode = getClosestNode(start);
Node goalNode = getClosestNode(goal);
Node currentNode = startNode;
Node currentNode = new Node(startNode);
path.add(startNode);
int attempts = 0;
while(!currentNode.equals(goalNode) && attempts < 250){
@@ -112,6 +118,7 @@ public class PathingUtilities {
move(character,new Vector3fImmutable(path.get(0).location.x,0,path.get(0).location.y));
path.remove(0);
}
character.isPathing = false;
}
public static void move(AbstractCharacter mob, Vector3fImmutable goal) {
mob.destination = goal;