v0.6.1: fixed various issues with levelgen

This commit is contained in:
Evan Debenham 2017-08-04 15:30:46 -04:00
parent 54749a5eb5
commit 46ba333af1
3 changed files with 14 additions and 9 deletions

View File

@ -57,13 +57,14 @@ public abstract class Builder {
ArrayList<Room> colliding = new ArrayList<>(collision);
do{
//remove any rooms we aren't currently overlapping
//remove empty rooms and any rooms we aren't currently overlapping
Iterator<Room> it = colliding.iterator();
while (it.hasNext()){
Room room = it.next();
//if not colliding
if ( Math.max(space.left, room.left) >= Math.min(space.right, room.right)
|| Math.max(space.top, room.top) >= Math.min(space.bottom, room.bottom) ){
if ( room.isEmpty()
|| Math.max(space.left, room.left) >= Math.min(space.right, room.right)
|| Math.max(space.top, room.top) >= Math.min(space.bottom, room.bottom) ){
it.remove();
}
}

View File

@ -83,6 +83,10 @@ public abstract class RegularBuilder extends Builder {
protected ArrayList<Room> singleConnections = new ArrayList<>();
protected void setupRooms(ArrayList<Room> rooms){
for(Room r : rooms){
r.setEmpty();
}
entrance = exit = shop = null;
singleConnections.clear();
multiConnections.clear();

View File

@ -64,7 +64,7 @@ public class SewerPipeRoom extends StandardRoom {
Rect c = getConnectionSpace();
if (connected.size() <= 3) {
if (connected.size() <= 2) {
for (Door door : connected.values()) {
Point start;
@ -248,22 +248,22 @@ public class SewerPipeRoom extends StandardRoom {
//doors on opposite sides
Point side;
if (from.y == top+1 || from.y == bottom-1){
if (from.y == top+2 || from.y == bottom-2){
//connect along the left, or right side
if (spaceBetween(left, from.x) + spaceBetween(left, to.x) <=
spaceBetween(right, from.x) + spaceBetween(right, to.x)){
side = new Point(left+1, top + height()/2);
side = new Point(left+2, top + height()/2);
} else {
side = new Point(right-1, top + height()/2);
side = new Point(right-2, top + height()/2);
}
} else {
//connect along the top, or bottom side
if (spaceBetween(top, from.y) + spaceBetween(top, to.y) <=
spaceBetween(bottom, from.y) + spaceBetween(bottom, to.y)){
side = new Point(left + width()/2, top+1);
side = new Point(left + width()/2, top+2);
} else {
side = new Point(left + width()/2, bottom-1);
side = new Point(left + width()/2, bottom-2);
}
}
//treat this as two connections with adjacent sides