v2.2.0: CavesPainter no longer walls up corners if there is a connection

This commit is contained in:
Evan Debenham
2023-10-04 22:45:01 -04:00
parent 9181882870
commit e0f7f2d620
2 changed files with 9 additions and 15 deletions

View File

@@ -60,7 +60,8 @@ public class CavesPainter extends RegularPainter {
if (Random.Int( s ) > 8) { if (Random.Int( s ) > 8) {
int corner = (room.left + 1) + (room.top + 1) * w; int corner = (room.left + 1) + (room.top + 1) * w;
if (map[corner - 1] == Terrain.WALL && map[corner - w] == Terrain.WALL) { if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1))
&& map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w))) {
map[corner] = Terrain.WALL; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }
@@ -68,7 +69,8 @@ public class CavesPainter extends RegularPainter {
if (Random.Int( s ) > 8) { if (Random.Int( s ) > 8) {
int corner = (room.right - 1) + (room.top + 1) * w; int corner = (room.right - 1) + (room.top + 1) * w;
if (map[corner + 1] == Terrain.WALL && map[corner - w] == Terrain.WALL) { if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1))
&& map[corner-w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-w))) {
map[corner] = Terrain.WALL; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }
@@ -76,7 +78,8 @@ public class CavesPainter extends RegularPainter {
if (Random.Int( s ) > 8) { if (Random.Int( s ) > 8) {
int corner = (room.left + 1) + (room.bottom - 1) * w; int corner = (room.left + 1) + (room.bottom - 1) * w;
if (map[corner - 1] == Terrain.WALL && map[corner + w] == Terrain.WALL) { if (map[corner-1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner-1))
&& map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w))) {
map[corner] = Terrain.WALL; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }
@@ -84,7 +87,8 @@ public class CavesPainter extends RegularPainter {
if (Random.Int( s ) > 8) { if (Random.Int( s ) > 8) {
int corner = (room.right - 1) + (room.bottom - 1) * w; int corner = (room.right - 1) + (room.bottom - 1) * w;
if (map[corner + 1] == Terrain.WALL && map[corner + w] == Terrain.WALL) { if (map[corner+1] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+1))
&& map[corner+w] == Terrain.WALL && !room.connected.containsValue(level.cellToPoint(corner+w))) {
map[corner] = Terrain.WALL; map[corner] = Terrain.WALL;
level.traps.remove(corner); level.traps.remove(corner);
} }

View File

@@ -49,16 +49,6 @@ public class MiningLevelPainter extends CavesPainter {
@Override @Override
protected void generateGold(Level level, ArrayList<Room> rooms) { protected void generateGold(Level level, ArrayList<Room> rooms) {
//replace all hidden doors with wall
// we do this here so that levels can still know where hidden passages are until the end
// but said passages can also sometimes have gold in them
for (int i = 0; i < level.length(); i++) {
if (level.map[i] == Terrain.SECRET_DOOR) {
level.map[i] = Terrain.WALL;
}
}
//we start by counting all the gold purposefully made by rooms //we start by counting all the gold purposefully made by rooms
for (int i = 0; i < level.length(); i++){ for (int i = 0; i < level.length(); i++){
if (level.map[i] == Terrain.WALL_DECO) { if (level.map[i] == Terrain.WALL_DECO) {
@@ -131,7 +121,7 @@ public class MiningLevelPainter extends CavesPainter {
int door = d.x + d.y * l.width(); int door = d.x + d.y * l.width();
if (d.type == Room.Door.Type.HIDDEN){ if (d.type == Room.Door.Type.HIDDEN){
l.map[door] = Terrain.SECRET_DOOR; l.map[door] = Terrain.WALL;
} else { } else {
//some of these are randomly hidden, using the same rules as regular levels //some of these are randomly hidden, using the same rules as regular levels
if (Random.Float() < hiddenDoorChance) { if (Random.Float() < hiddenDoorChance) {