From f34c6f3471451d171987ffc2bc87350c7429cb7f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 7 Mar 2022 23:14:11 -0500 Subject: [PATCH] v1.2.0: adjusted the secrets level feeling, prevents isolated rooms --- .../levels/painters/RegularPainter.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java index 0bacf013a..a4b6b8907 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java @@ -28,6 +28,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Patch; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; @@ -204,6 +205,38 @@ public abstract class RegularPainter extends Painter { if (d.type == Room.Door.Type.REGULAR){ if (Random.Float() < hiddenDoorChance) { d.type = Room.Door.Type.HIDDEN; + //all standard rooms must have an unbroken path to all other standard rooms + if (l.feeling != Level.Feeling.SECRETS){ + Graph.buildDistanceMap(rooms, r); + if (n.distance == Integer.MAX_VALUE){ + d.type = Room.Door.Type.UNLOCKED; + } + //on a secrets level, rooms just have to not be totally isolated + } else { + int roomsInGraph = 0; + Graph.buildDistanceMap(rooms, r); + for (Room rDest : rooms){ + if (rDest.distance != Integer.MAX_VALUE + && !(rDest instanceof ConnectionRoom)){ + roomsInGraph++; + } + } + if (roomsInGraph < 2){ + d.type = Room.Door.Type.UNLOCKED; + } else { + roomsInGraph = 0; + Graph.buildDistanceMap(rooms, n); + for (Room nDest : rooms){ + if (nDest.distance != Integer.MAX_VALUE + && !(nDest instanceof ConnectionRoom)){ + roomsInGraph++; + } + } + if (roomsInGraph < 2){ + d.type = Room.Door.Type.UNLOCKED; + } + } + } Graph.buildDistanceMap(rooms, r); //don't hide if it would make this room only accessible by hidden doors //unless we're on a secrets depth