Construction improvements

Relaxed constraint on room rotation to allow for blind walls
Prevent the room snapping into a different rotation than the one specified
This commit is contained in:
Player Name
2023-08-25 09:39:10 +00:00
committed by Ryan
parent e84192d985
commit e9fa9d0d41
@@ -558,18 +558,11 @@ public final class BuildingUtils {
} }
else if (count == 3) { else if (count == 3) {
room = Room.create(player, RoomProperties.ROOF_3_EXIT); room = Room.create(player, RoomProperties.ROOF_3_EXIT);
room.setRotation(DIRECTIONS[(index + 2) % 4]);
} }
else if ((exits[0] != exits[2]) || (exits[1] != exits[3])) { else if ((exits[0] != exits[2]) || (exits[1] != exits[3])) {
room = Room.create(player, RoomProperties.ROOF_3_EXIT); room = Room.create(player, RoomProperties.ROOF_3_EXIT);
if (exits[2]) {
room.setRotation(DIRECTIONS[exits[3] ? 3 : 1]);
}
} else { } else {
room = Room.create(player, RoomProperties.ROOF_2_EXIT); room = Room.create(player, RoomProperties.ROOF_2_EXIT);
if (exits[0] || exits[2]) {
room.setRotation(DIRECTIONS[1]);
}
} }
player.getHouseManager().getRooms()[z + 1][x][y] = room; player.getHouseManager().getRooms()[z + 1][x][y] = room;
} }
@@ -657,45 +650,24 @@ public final class BuildingUtils {
* Gets the exit requirements for the given room. * Gets the exit requirements for the given room.
* @param roomX The room x-coordinate. * @param roomX The room x-coordinate.
* @param roomY The room y-coordinate. * @param roomY The room y-coordinate.
* @return The disabled exit indexes. * @return The requirements on the exit indexes. -1 if exit must be absent, +1 if exit must be present.
*/ */
private static int[] getExitRequirements(Player player, int z, int roomX, int roomY) { private static int[] getExitRequirements(Player player, int z, int roomX, int roomY) {
int[] exits = new int[4]; int[] exits = new int[4];
if (roomX == 0) { int deltaX = roomX - player.getLocation().getChunkX();
exits[2] = -1; int deltaY = roomY - player.getLocation().getChunkY();
} if (deltaX > 0) {
else if (player.getHouseManager().hasExit(z, roomX - 1, roomY, Direction.EAST)) { // player is to our west
exits[2] = 1; exits[2] = 1;
} } else if (deltaX < 0) {
else if (player.getHouseManager().hasRoomAt(z, roomX - 1, roomY)) { // player is to our east
exits[2] = -1;
}
if (roomY == 7) {
exits[3] = -1;
}
else if (player.getHouseManager().hasExit(z, roomX, roomY + 1, Direction.SOUTH)) {
exits[3] = 1;
}
else if (player.getHouseManager().hasRoomAt(z, roomX, roomY + 1)) {
exits[3] = -1;
}
if (roomX == 7) {
exits[0] = -1;
}
else if (player.getHouseManager().hasExit(z, roomX + 1, roomY, Direction.WEST)) {
exits[0] = 1; exits[0] = 1;
} } else if (deltaY > 0) {
else if (player.getHouseManager().hasRoomAt(z, roomX + 1, roomY)) { // player is to our south
exits[0] = -1;
}
if (roomY == 0) {
exits[1] = -1;
}
else if (player.getHouseManager().hasExit(z, roomX, roomY - 1, Direction.NORTH)) {
exits[1] = 1; exits[1] = 1;
} } else if (deltaY < 0) {
else if (player.getHouseManager().hasRoomAt(z, roomX, roomY - 1)) { // player is to our north
exits[1] = -1; exits[3] = 1;
} }
return exits; return exits;
} }