Adding more tests

This commit is contained in:
ceikry 2022-04-26 22:00:36 -05:00
parent c4ab32f7d7
commit 45980f5823

View file

@ -386,55 +386,20 @@ public final class HouseManager {
* @return The region. * @return The region.
*/ */
public DynamicRegion construct() { public DynamicRegion construct() {
Region from = RegionManager.forId(style.getRegionId());
Region.load(from, true);
RegionChunk defaultChunk = from.getPlanes()[style.getPlane()].getRegionChunk(1, 0);
RegionChunk defaultSkyChunk = from.getPlanes()[1].getRegionChunk(0,0);
houseRegion = getPreparedRegion(); houseRegion = getPreparedRegion();
configureRoofs(); configureRoofs();
for (int z = 0; z < 4; z++) { prepareHouseChunks(style, houseRegion, buildingMode, rooms);
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
if(z == 3){
houseRegion.replaceChunk(z, x, y, defaultSkyChunk.copy(houseRegion.getPlanes()[z]), from);
continue;
}
Room room = rooms[z][x][y];
if (room != null) {
if (room.getProperties().isRoof() && buildingMode) {
continue;
}
BuildRegionChunk copy = room.getChunk().copy(houseRegion.getPlanes()[z]);
houseRegion.replaceChunk(z, x, y, copy, from);
room.loadDecorations(z, copy, this);
} else {
houseRegion.replaceChunk(z, x, y, z != 0 ? null : defaultChunk.copy(houseRegion.getPlanes()[0]), from);
}
}
}
}
if (hasDungeon()) { if (hasDungeon()) {
defaultChunk = from.getPlanes()[style.getPlane()].getRegionChunk(3, 0);
dungeonRegion = getPreparedRegion(); dungeonRegion = getPreparedRegion();
for (int x = 0; x < 8; x++) { prepareDungeonChunks(style, dungeonRegion, buildingMode, houseRegion, rooms[3]);
for (int y = 0; y < 8; y++) {
Room room = rooms[3][x][y];
if (hasRoomAt(3, x, y)) {
BuildRegionChunk copy = room.getChunk().copy(dungeonRegion.getPlanes()[0]);
dungeonRegion.replaceChunk(0, x, y, copy, from);
room.loadDecorations(3, copy, this);
} else {
dungeonRegion.replaceChunk(0, x, y, buildingMode ? null : defaultChunk.copy(dungeonRegion.getPlanes()[0]), from);
}
}
}
houseRegion.link(dungeonRegion);
} }
ZoneBuilder.configure(zone); ZoneBuilder.configure(zone);
return houseRegion; return houseRegion;
} }
public DynamicRegion getPreparedRegion() { private DynamicRegion getPreparedRegion() {
ZoneBorders borders = DynamicRegion.reserveArea(8,8); ZoneBorders borders = DynamicRegion.reserveArea(8,8);
DynamicRegion region = new DynamicRegion(-1, borders.getSouthWestX() >> 6, borders.getSouthWestY() >> 6); DynamicRegion region = new DynamicRegion(-1, borders.getSouthWestX() >> 6, borders.getSouthWestY() >> 6);
region.setBorders(borders); region.setBorders(borders);
@ -443,6 +408,53 @@ public final class HouseManager {
return region; return region;
} }
private void prepareHouseChunks(HousingStyle style, DynamicRegion target, boolean buildingMode, Room[][][] rooms) {
Region from = RegionManager.forId(style.getRegionId());
Region.load(from, true);
RegionChunk defaultChunk = from.getPlanes()[style.getPlane()].getRegionChunk(1, 0);
RegionChunk defaultSkyChunk = from.getPlanes()[1].getRegionChunk(0,0);
for (int z = 0; z < 4; z++) {
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
if(z == 3){
target.replaceChunk(z, x, y, defaultSkyChunk.copy(target.getPlanes()[z]), from);
continue;
}
Room room = rooms[z][x][y];
if (room != null) {
if (room.getProperties().isRoof() && buildingMode) {
continue;
}
BuildRegionChunk copy = room.getChunk().copy(target.getPlanes()[z]);
target.replaceChunk(z, x, y, copy, from);
room.loadDecorations(z, copy, this);
} else {
target.replaceChunk(z, x, y, z != 0 ? null : defaultChunk.copy(target.getPlanes()[0]), from);
}
}
}
}
}
private void prepareDungeonChunks(HousingStyle style, DynamicRegion target, boolean buildingMode, DynamicRegion house, Room[][] rooms) {
Region from = RegionManager.forId(style.getRegionId());
Region.load(from, true);
RegionChunk defaultChunk = from.getPlanes()[style.getPlane()].getRegionChunk(3, 0);
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
Room room = rooms[x][y];
if (room != null) {
BuildRegionChunk copy = room.getChunk().copy(target.getPlanes()[0]);
target.replaceChunk(0, x, y, copy, from);
room.loadDecorations(3, copy, this);
} else {
target.replaceChunk(0, x, y, buildingMode ? null : defaultChunk.copy(target.getPlanes()[0]), from);
}
}
}
house.link(target);
}
/** /**
* Configures the rooftops. * Configures the rooftops.
*/ */