Merge remote-tracking branch 'origin/dev' into dev222

This commit is contained in:
KrewsOrg 2020-02-05 21:24:30 +00:00
commit 8321a60efc

View File

@ -257,8 +257,12 @@ public class RoomLayout {
return this.heightmap.replace("\r\n", "\r"); return this.heightmap.replace("\r\n", "\r");
}//re }//re
/// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3
public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) { public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) {
return this.findPath(oldTile, newTile, goalLocation, roomUnit, false);
}
/// Pathfinder Reworked By Quadral, thanks buddy!! You Saved Morningstar <3
public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit, boolean isWalktroughRetry) {
if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID) if (this.room == null || !this.room.isLoaded() || oldTile == null || newTile == null || oldTile.equals(newTile) || newTile.state == RoomTileState.INVALID)
return new LinkedList<>(); return new LinkedList<>();
LinkedList<RoomTile> openList = new LinkedList<>(); LinkedList<RoomTile> openList = new LinkedList<>();
@ -291,7 +295,7 @@ public class RoomLayout {
double height = currentAdj.getStackHeight() - current.getStackHeight(); double height = currentAdj.getStackHeight() - current.getStackHeight();
if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue; if (!ALLOW_FALLING && height < -MAXIMUM_STEP_HEIGHT) continue;
if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue; if (currentAdj.state == RoomTileState.OPEN && height > MAXIMUM_STEP_HEIGHT) continue;
if (currentAdj.hasUnits() && (!this.room.isAllowWalkthrough() || currentAdj.equals(goalLocation))) { if (currentAdj.hasUnits() && ((!isWalktroughRetry && !this.room.isAllowWalkthrough()) || currentAdj.equals(goalLocation))) {
closedList.add(currentAdj); closedList.add(currentAdj);
openList.remove(currentAdj); openList.remove(currentAdj);
continue; continue;
@ -308,6 +312,11 @@ public class RoomLayout {
} }
} }
// System.out.println("Invalid Path."); // System.out.println("Invalid Path.");
if (!this.room.isAllowWalkthrough()) {
return this.findPath(oldTile, newTile, goalLocation, roomUnit, true);
}
return new LinkedList<>(); return new LinkedList<>();
} }