v0.9.1: fixed a bug with sewer pipe rooms and let them merge together

This commit is contained in:
Evan Debenham 2020-10-23 22:30:29 -04:00
parent fafb887d3b
commit 81156427bb
3 changed files with 32 additions and 15 deletions

View File

@ -214,6 +214,9 @@ public abstract class RegularPainter extends Painter {
case TUNNEL: case TUNNEL:
l.map[door] = l.tunnelTile(); l.map[door] = l.tunnelTile();
break; break;
case WATER:
l.map[door] = Terrain.WATER;
break;
case UNLOCKED: case UNLOCKED:
l.map[door] = Terrain.DOOR; l.map[door] = Terrain.DOOR;
break; break;

View File

@ -387,7 +387,7 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
public static class Door extends Point implements Bundlable { public static class Door extends Point implements Bundlable {
public enum Type { public enum Type {
EMPTY, TUNNEL, REGULAR, UNLOCKED, HIDDEN, BARRICADE, LOCKED EMPTY, TUNNEL, WATER, REGULAR, UNLOCKED, HIDDEN, BARRICADE, LOCKED
} }
public Type type = Type.EMPTY; public Type type = Type.EMPTY;

View File

@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.GameMath; import com.watabou.utils.GameMath;
import com.watabou.utils.PathFinder; import com.watabou.utils.PathFinder;
import com.watabou.utils.Point; import com.watabou.utils.Point;
@ -157,8 +158,19 @@ public class SewerPipeRoom extends StandardRoom {
} }
} }
for (Door door : connected.values()) { for (Room r : connected.keySet()) {
door.set( Door.Type.REGULAR ); if (r instanceof SewerPipeRoom){
Point door = connected.get(r);
Painter.fill(level, door.x-1, door.y-1, 3, 3, Terrain.EMPTY);
if (door.x == left || door.x == right){
Painter.fill(level, door.x-1, door.y, 3, 1, Terrain.WATER);
} else {
Painter.fill(level, door.x, door.y-1, 1, 3, Terrain.WATER);
}
connected.get(r).set( Door.Type.WATER );
} else {
connected.get(r).set( Door.Type.REGULAR );
}
} }
} }
@ -200,7 +212,8 @@ public class SewerPipeRoom extends StandardRoom {
//gets the path distance between two points //gets the path distance between two points
private int distanceBetweenPoints(Point a, Point b){ private int distanceBetweenPoints(Point a, Point b){
//on the same side //on the same side
if (a.y == b.y || a.x == b.x){ if (((a.x == left || a.x == right) && a.y == b.y)
|| ((a.y == top || a.y == bottom) && a.x == b.x)){
return Math.max(spaceBetween(a.x, b.x), spaceBetween(a.y, b.y)); return Math.max(spaceBetween(a.x, b.x), spaceBetween(a.y, b.y));
} }
@ -222,7 +235,8 @@ public class SewerPipeRoom extends StandardRoom {
private void fillBetweenPoints(Level level, Point from, Point to, int floor){ private void fillBetweenPoints(Level level, Point from, Point to, int floor){
//doors are along the same side //doors are along the same side
if (from.y == to.y || from.x == to.x){ if (((from.x == left+1 || from.x == right-1) && from.x == to.x)
|| ((from.y == top+1 || from.y == bottom-1) && from.y == to.y)){
Painter.fill(level, Painter.fill(level,
Math.min(from.x, to.x), Math.min(from.x, to.x),
Math.min(from.y, to.y), Math.min(from.y, to.y),