v3.3.0: slightly improved the shape varying logic in TunnelRoom

This commit is contained in:
Evan Debenham
2025-10-07 19:56:56 -04:00
parent 05c52bdc1f
commit 039f374d62

View File

@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.GameMath;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Point;
import com.watabou.utils.PointF;
import com.watabou.utils.Random;
@@ -79,13 +80,14 @@ public class TunnelRoom extends ConnectionRoom {
//fill in an extra diagonal tile at center randomly if we're a larger room with many connections
//this makes the shape a bit more varied in these cases
if (width() >= 7 && height() >= 7 && connected.size() >= 4 && c.square() == 0){
Point p = new Point(c.left, c.top);
p.x += Random.Int(2) == 0 ? 1 : -1;
p.y += Random.Int(2) == 0 ? 1 : -1;
//also prevent filling a tile outside the room in rare cases
p.x = (int)GameMath.gate(left+1, p.x, right-1);
p.y = (int)GameMath.gate(top+1, p.y, bottom-1);
Painter.set(level, p, floor);
int cell = level.pointToCell(new Point(c.left, c.top));
int ofs = 2*Random.Int(4);
//check that it doesn't create and extra tile of tunnel before doing so
if (level.map[cell + PathFinder.CIRCLE8[(ofs+7)%8]] == floor
&& level.map[cell + PathFinder.CIRCLE8[(ofs+1)%8]] == floor){
Painter.set(level, cell + PathFinder.CIRCLE8[ofs], floor);
}
}
for (Door door : connected.values()) {