shape
This commit is contained in:
@@ -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 {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user