forked from MagicBane/Server
region work
This commit is contained in:
@@ -32,7 +32,7 @@ import static engine.math.FastMath.sqrt;
|
|||||||
|
|
||||||
public class MovementUtilities {
|
public class MovementUtilities {
|
||||||
private static final int cellGap = 1;
|
private static final int cellGap = 1;
|
||||||
private static final int stepHeight = 1;
|
private static final int stepHeight = 2;
|
||||||
|
|
||||||
public static boolean inRangeOfBindLocation(Mob agent) {
|
public static boolean inRangeOfBindLocation(Mob agent) {
|
||||||
|
|
||||||
@@ -298,49 +298,18 @@ public class MovementUtilities {
|
|||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
Building building = BuildingManager.getBuildingAtLocation(point);
|
|
||||||
if(building != null){
|
|
||||||
float halfX = building.getBounds().getHalfExtents().x;
|
|
||||||
float halfY = building.getBounds().getHalfExtents().y;
|
|
||||||
ArrayList<Vector3fImmutable> corners = new ArrayList<>();
|
|
||||||
corners.add(building.loc.add(new Vector3fImmutable(halfX,0,-halfY)));
|
|
||||||
corners.add(building.loc.add(new Vector3fImmutable(halfX,0,halfY)));
|
|
||||||
corners.add(building.loc.subtract(new Vector3fImmutable(halfX,0,halfY)));
|
|
||||||
corners.add(building.loc.add(new Vector3fImmutable(-halfX,0,halfY)));
|
|
||||||
Vector3fImmutable cheapCorner = Vector3fImmutable.ZERO;
|
|
||||||
for(Vector3fImmutable corn : corners){
|
|
||||||
if(Bounds.collide(building.getBounds(),point,corn))
|
|
||||||
continue;
|
|
||||||
if(getCost(corn,start,goal) < getCost(cheapCorner,start,goal))
|
|
||||||
cheapCorner = corn;
|
|
||||||
}
|
|
||||||
if(!cheapCorner.equals(Vector3fImmutable.ZERO))
|
|
||||||
if (path.contains(cheapCorner)) {
|
|
||||||
continue;
|
|
||||||
}else {
|
|
||||||
path.add(cheapCorner);
|
|
||||||
current = cheapCorner;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (path.contains(point))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (path.contains(point))
|
if (path.contains(point))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Regions region = Regions.getRegionAtLocation(goal);
|
|
||||||
if(region != null) {
|
|
||||||
path.add(new Vector3fImmutable(region.center)); //only use center points when travelling through regions
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (pointIsBlocked(point)) {
|
if (pointIsBlocked(point)) {
|
||||||
obstructed = true;
|
obstructed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Regions region = Regions.getRegionAtLocation(point);
|
||||||
|
if(region != null)
|
||||||
|
point = new Vector3fImmutable(point.x,region.lerpY(point),point.z); // adjust the Y value of the point to the region height it is in
|
||||||
|
|
||||||
if (getCost(cheapest, current, goal) > getCost(point, current, goal))
|
if (getCost(cheapest, current, goal) > getCost(point, current, goal))
|
||||||
cheapest = point;
|
cheapest = point;
|
||||||
|
|
||||||
@@ -371,6 +340,11 @@ public class MovementUtilities {
|
|||||||
if(building == null)
|
if(building == null)
|
||||||
return false;//no building at this location means nothing obstructing the walking path
|
return false;//no building at this location means nothing obstructing the walking path
|
||||||
|
|
||||||
|
Regions region = Regions.getRegionAtLocation(point);
|
||||||
|
if(region != null && Math.abs(region.lerpY(point) - point.y) < stepHeight) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Zone currentZone = ZoneManager.findSmallestZone(point);
|
Zone currentZone = ZoneManager.findSmallestZone(point);
|
||||||
if(currentZone == null)
|
if(currentZone == null)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user