v0.9.1: fixed a bug with sewer pipe rooms and let them merge together
This commit is contained in:
parent
fafb887d3b
commit
81156427bb
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,18 +204,19 @@ public class SewerPipeRoom extends StandardRoom {
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int spaceBetween(int a, int b){
|
private int spaceBetween(int a, int b){
|
||||||
return Math.abs(a - b)-1;
|
return Math.abs(a - b)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//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));
|
||||||
}
|
}
|
||||||
|
|
||||||
//otherwise...
|
//otherwise...
|
||||||
//subtract 1 at the end to account for overlap
|
//subtract 1 at the end to account for overlap
|
||||||
return
|
return
|
||||||
|
@ -215,14 +228,15 @@ public class SewerPipeRoom extends StandardRoom {
|
||||||
-
|
-
|
||||||
1;
|
1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Point[] corners;
|
private Point[] corners;
|
||||||
|
|
||||||
//picks the smallest path to fill between two points
|
//picks the smallest path to fill between two points
|
||||||
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),
|
||||||
|
@ -231,7 +245,7 @@ public class SewerPipeRoom extends StandardRoom {
|
||||||
floor);
|
floor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//set up corners
|
//set up corners
|
||||||
if (corners == null){
|
if (corners == null){
|
||||||
corners = new Point[4];
|
corners = new Point[4];
|
||||||
|
@ -240,7 +254,7 @@ public class SewerPipeRoom extends StandardRoom {
|
||||||
corners[2] = new Point(right-2, bottom-2);
|
corners[2] = new Point(right-2, bottom-2);
|
||||||
corners[3] = new Point(left+2, bottom-2);
|
corners[3] = new Point(left+2, bottom-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//doors on adjacent sides
|
//doors on adjacent sides
|
||||||
for (Point c : corners){
|
for (Point c : corners){
|
||||||
if ((c.x == from.x || c.y == from.y) && (c.x == to.x || c.y == to.y)){
|
if ((c.x == from.x || c.y == from.y) && (c.x == to.x || c.y == to.y)){
|
||||||
|
@ -249,7 +263,7 @@ public class SewerPipeRoom extends StandardRoom {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//doors on opposite sides
|
//doors on opposite sides
|
||||||
Point side;
|
Point side;
|
||||||
if (from.y == top+2 || from.y == bottom-2){
|
if (from.y == top+2 || from.y == bottom-2){
|
||||||
|
@ -260,7 +274,7 @@ public class SewerPipeRoom extends StandardRoom {
|
||||||
} else {
|
} else {
|
||||||
side = new Point(right-2, top + height()/2);
|
side = new Point(right-2, top + height()/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//connect along the top, or bottom side
|
//connect along the top, or bottom side
|
||||||
if (spaceBetween(top, from.y) + spaceBetween(top, to.y) <=
|
if (spaceBetween(top, from.y) + spaceBetween(top, to.y) <=
|
||||||
|
|
Loading…
Reference in New Issue
Block a user