🆙 allow to walk diagonal between objects
Don't forget to run the SQL !
This commit is contained in:
parent
57aa3c14cd
commit
e0f4f4a19f
1
Database Updates/UpdateDatabase_Allow_diagonale.sql
Normal file
1
Database Updates/UpdateDatabase_Allow_diagonale.sql
Normal file
@ -0,0 +1 @@
|
||||
INSERT INTO emulator_settings (`key`, `value`) VALUES ('pathfinder.diagonale.enabled', '1');
|
@ -34,8 +34,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
@ -32,6 +32,7 @@ public class RoomLayout {
|
||||
private RoomTile[][] roomTiles;
|
||||
private RoomTile doorTile;
|
||||
private Room room;
|
||||
boolean canMoveDiagonally = PathfinderConfig.canMoveDiagonally();
|
||||
|
||||
public RoomLayout(ResultSet set, Room room) throws SQLException {
|
||||
this.room = room;
|
||||
@ -49,6 +50,13 @@ public class RoomLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public class PathfinderConfig {
|
||||
private static boolean canMoveDiagonally = Emulator.getConfig().getBoolean("pathfinder.diagonal.enabled", false);
|
||||
public static boolean canMoveDiagonally() {
|
||||
return canMoveDiagonally;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean squareInSquare(Rectangle outerSquare, Rectangle innerSquare) {
|
||||
if (outerSquare.x > innerSquare.x)
|
||||
return false;
|
||||
@ -255,7 +263,7 @@ public class RoomLayout {
|
||||
|
||||
public String getRelativeMap() {
|
||||
return this.heightmap.replace("\r\n", "\r");
|
||||
}//re
|
||||
}
|
||||
|
||||
public final Deque<RoomTile> findPath(RoomTile oldTile, RoomTile newTile, RoomTile goalLocation, RoomUnit roomUnit) {
|
||||
return this.findPath(oldTile, newTile, goalLocation, roomUnit, false);
|
||||
@ -426,11 +434,13 @@ public class RoomLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.CANMOVEDIAGONALY) {
|
||||
// Diagonal: bottom-right
|
||||
if ((x < this.mapSizeX) && (y < this.mapSizeY)) {
|
||||
RoomTile offX = this.findTile(openList, (short) (x + 1), y);
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y + 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
if (offX != null && offY != null && (canMoveDiagonally || offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y + 1));
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
@ -441,10 +451,12 @@ public class RoomLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Diagonal: top-left
|
||||
if ((x > 0) && (y > 0)) {
|
||||
RoomTile offX = this.findTile(openList, (short) (x - 1), y);
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y - 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
if (offX != null && offY != null && (canMoveDiagonally || offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y - 1));
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
@ -455,10 +467,12 @@ public class RoomLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Diagonal: bottom-left
|
||||
if ((x > 0) && (y < this.mapSizeY)) {
|
||||
RoomTile offX = this.findTile(openList, (short) (x - 1), y);
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y + 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
if (offX != null && offY != null && (canMoveDiagonally || offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x - 1), (short) (y + 1));
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
@ -469,10 +483,12 @@ public class RoomLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Diagonal: top-right
|
||||
if ((x < this.mapSizeX) && (y > 0)) {
|
||||
RoomTile offX = this.findTile(openList, (short) (x + 1), y);
|
||||
RoomTile offY = this.findTile(openList, x, (short) (y - 1));
|
||||
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable())) {
|
||||
if (offX != null && offY != null && (canMoveDiagonally || offX.isWalkable() || offY.isWalkable())) {
|
||||
RoomTile temp = this.findTile(openList, (short) (x + 1), (short) (y - 1));
|
||||
if (this.canWalkOn(temp, unit)) {
|
||||
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user