v0.9.1: further improvements to room merging logic
This commit is contained in:
parent
5655cdff1c
commit
772da815d6
|
@ -29,7 +29,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
import com.watabou.utils.Rect;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -43,25 +42,9 @@ public class CavesPainter extends RegularPainter {
|
||||||
int[] map = level.map;
|
int[] map = level.map;
|
||||||
|
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
if (r instanceof StandardRoom && ((StandardRoom) r).joinable) {
|
|
||||||
for (Room n : r.neigbours) {
|
for (Room n : r.neigbours) {
|
||||||
if (n instanceof StandardRoom && ((StandardRoom) n).joinable && !r.connected.containsKey( n )) {
|
if (!r.connected.containsKey( n )) {
|
||||||
Rect i = r.intersect( n );
|
mergeRooms(level, r, n, null, Terrain.CHASM);
|
||||||
if (i.left == i.right && i.bottom - i.top >= 3) {
|
|
||||||
|
|
||||||
i.top++;
|
|
||||||
i.right++;
|
|
||||||
|
|
||||||
Painter.fill( level, i.left, i.top, 1, i.height(), Terrain.CHASM );
|
|
||||||
|
|
||||||
} else if (i.top == i.bottom && i.right - i.left >= 3) {
|
|
||||||
|
|
||||||
i.left++;
|
|
||||||
i.bottom++;
|
|
||||||
|
|
||||||
Painter.fill( level, i.left, i.top, i.width(), 1, Terrain.CHASM );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,8 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
|
||||||
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.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
|
||||||
import com.watabou.utils.PathFinder;
|
import com.watabou.utils.PathFinder;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
import com.watabou.utils.Rect;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -65,25 +63,9 @@ public class HallsPainter extends RegularPainter {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
if (r instanceof StandardRoom && ((StandardRoom) r).joinable) {
|
|
||||||
for (Room n : r.neigbours) {
|
for (Room n : r.neigbours) {
|
||||||
if (n instanceof StandardRoom && ((StandardRoom) n).joinable && !r.connected.containsKey( n )) {
|
if (!r.connected.containsKey( n )) {
|
||||||
Rect i = r.intersect( n );
|
mergeRooms(level, r, n, null, Terrain.CHASM);
|
||||||
if (i.left == i.right && i.bottom - i.top >= 3) {
|
|
||||||
|
|
||||||
i.top++;
|
|
||||||
i.right++;
|
|
||||||
|
|
||||||
Painter.fill( level, i.left, i.top, 1, i.height(), Terrain.CHASM );
|
|
||||||
|
|
||||||
} else if (i.top == i.bottom && i.right - i.left >= 3) {
|
|
||||||
|
|
||||||
i.left++;
|
|
||||||
i.bottom++;
|
|
||||||
|
|
||||||
Painter.fill( level, i.left, i.top, i.width(), 1, Terrain.CHASM );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,12 +177,18 @@ public abstract class RegularPainter extends Painter {
|
||||||
hiddenDoorChance = (0.5f + hiddenDoorChance)/2f;
|
hiddenDoorChance = (0.5f + hiddenDoorChance)/2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
roomMerges.clear();
|
HashMap<Room, Room> roomMerges = new HashMap<>();
|
||||||
|
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
for (Room n : r.connected.keySet()) {
|
for (Room n : r.connected.keySet()) {
|
||||||
|
|
||||||
if (joinRooms(l, r, n)) {
|
//normal sized rooms can be merged at most once. Large and Giant rooms can be merged many times
|
||||||
|
if (roomMerges.get(r) == n || roomMerges.get(n) == r){
|
||||||
|
continue;
|
||||||
|
} else if (!roomMerges.containsKey(r) && !roomMerges.containsKey(n) &&
|
||||||
|
mergeRooms(l, r, n, r.connected.get(n), Terrain.EMPTY)) {
|
||||||
|
if (((StandardRoom) r).sizeCat == StandardRoom.SizeCategory.NORMAL) roomMerges.put(r, n);
|
||||||
|
if (((StandardRoom) n).sizeCat == StandardRoom.SizeCategory.NORMAL) roomMerges.put(n, r);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,51 +243,60 @@ public abstract class RegularPainter extends Painter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<Room, Room> roomMerges = new HashMap<>();
|
protected boolean mergeRooms( Level l, Room r, Room n, Point start, int mergeTerrain){
|
||||||
|
|
||||||
protected boolean joinRooms( Level l, Room r, Room n ) {
|
Rect intersect = r.intersect( n );
|
||||||
|
if (intersect.left == intersect.right) {
|
||||||
|
|
||||||
if (!(r instanceof StandardRoom) || !((StandardRoom) r).joinable
|
Rect merge = new Rect();
|
||||||
|| !(n instanceof StandardRoom) || !((StandardRoom) n).joinable) {
|
merge.left = merge.right = intersect.left;
|
||||||
return false;
|
merge.top = merge.bottom = start != null ? start.y : intersect.center().y;
|
||||||
|
|
||||||
|
Point p = new Point(merge.left, merge.top);
|
||||||
|
while(merge.top > intersect.top && n.canMerge(l, p, mergeTerrain) && r.canMerge(l, p, mergeTerrain)) {
|
||||||
|
merge.top--;
|
||||||
|
p.y--;
|
||||||
|
}
|
||||||
|
p.y = merge.bottom;
|
||||||
|
while(merge.bottom < intersect.bottom && n.canMerge(l, p, mergeTerrain) && r.canMerge(l, p, mergeTerrain)) {
|
||||||
|
merge.bottom++;
|
||||||
|
p.y++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roomMerges.get(r) == n) return true;
|
if (merge.height() >= 3) {
|
||||||
if (roomMerges.get(n) == r) return true;
|
Painter.fill(l, merge.left, merge.top + 1, 1, merge.height()-1, mergeTerrain);
|
||||||
if (roomMerges.containsKey(r)) return false;
|
|
||||||
if (roomMerges.containsKey(n)) return false;
|
|
||||||
|
|
||||||
//TODO maybe more limitations here, such as limiting maximum width/height for normal sized rooms?
|
|
||||||
|
|
||||||
Rect w = r.intersect( n );
|
|
||||||
if (w.left == w.right) {
|
|
||||||
|
|
||||||
if (w.bottom - w.top < 3) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
w.top++;
|
|
||||||
w.right++;
|
|
||||||
|
|
||||||
Painter.fill( l, w.left, w.top, 1, w.height(), Terrain.EMPTY );
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (w.right - w.left < 3) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
w.left++;
|
|
||||||
w.bottom++;
|
|
||||||
|
|
||||||
Painter.fill( l, w.left, w.top, w.width(), 1, Terrain.EMPTY );
|
|
||||||
}
|
|
||||||
|
|
||||||
//normal sized rooms can be merged at most once. Large and Giant rooms can be merged many times
|
|
||||||
if (((StandardRoom) r).sizeCat == StandardRoom.SizeCategory.NORMAL) roomMerges.put(r, n);
|
|
||||||
if (((StandardRoom) n).sizeCat == StandardRoom.SizeCategory.NORMAL) roomMerges.put(n, r);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (intersect.top == intersect.bottom) {
|
||||||
|
|
||||||
|
Rect merge = new Rect();
|
||||||
|
merge.left = merge.right = start != null ? start.x : intersect.center().x;
|
||||||
|
merge.top = merge.bottom = intersect.top;
|
||||||
|
|
||||||
|
Point p = new Point(merge.left, merge.top);
|
||||||
|
while(merge.left > intersect.left && n.canMerge(l, p, mergeTerrain) && r.canMerge(l, p, mergeTerrain)) {
|
||||||
|
merge.left--;
|
||||||
|
p.x--;
|
||||||
|
}
|
||||||
|
p.x = merge.right;
|
||||||
|
while(merge.right < intersect.right && n.canMerge(l, p, mergeTerrain) && r.canMerge(l, p, mergeTerrain)) {
|
||||||
|
merge.right++;
|
||||||
|
p.x++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (merge.width() >= 3) {
|
||||||
|
Painter.fill(l, merge.left + 1, merge.top, merge.width()-1, 1, mergeTerrain);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintWater( Level l, ArrayList<Room> rooms ){
|
protected void paintWater( Level l, ArrayList<Room> rooms ){
|
||||||
|
|
|
@ -116,6 +116,20 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Point pointInside(Point from, int n){
|
||||||
|
Point step = new Point(from);
|
||||||
|
if (from.x == left) {
|
||||||
|
step.offset( +n, 0 );
|
||||||
|
} else if (from.x == right) {
|
||||||
|
step.offset( -n, 0 );
|
||||||
|
} else if (from.y == top) {
|
||||||
|
step.offset( 0, +n );
|
||||||
|
} else if (from.y == bottom) {
|
||||||
|
step.offset( 0, -n );
|
||||||
|
}
|
||||||
|
return step;
|
||||||
|
}
|
||||||
|
|
||||||
//Width and height are increased by 1 because rooms are inclusive to their right and bottom sides
|
//Width and height are increased by 1 because rooms are inclusive to their right and bottom sides
|
||||||
@Override
|
@Override
|
||||||
public int width() {
|
public int width() {
|
||||||
|
@ -224,6 +238,10 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addNeigbour( Room other ) {
|
public boolean addNeigbour( Room other ) {
|
||||||
if (neigbours.contains(other))
|
if (neigbours.contains(other))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -25,6 +25,7 @@ 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.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Rect;
|
import com.watabou.utils.Rect;
|
||||||
|
|
||||||
public class BridgeRoom extends TunnelRoom {
|
public class BridgeRoom extends TunnelRoom {
|
||||||
|
@ -52,4 +53,9 @@ public class BridgeRoom extends TunnelRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return mergeTerrain == Terrain.CHASM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ 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.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Rect;
|
import com.watabou.utils.Rect;
|
||||||
|
|
||||||
public class RingBridgeRoom extends RingTunnelRoom {
|
public class RingBridgeRoom extends RingTunnelRoom {
|
||||||
|
@ -49,4 +50,9 @@ public class RingBridgeRoom extends RingTunnelRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return mergeTerrain == Terrain.CHASM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ 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.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Rect;
|
import com.watabou.utils.Rect;
|
||||||
|
|
||||||
public class WalkwayRoom extends PerimeterRoom {
|
public class WalkwayRoom extends PerimeterRoom {
|
||||||
|
@ -52,4 +53,9 @@ public class WalkwayRoom extends PerimeterRoom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return mergeTerrain == Terrain.CHASM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,19 +27,21 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRo
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap;
|
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.Tilemap;
|
import com.watabou.noosa.Tilemap;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public abstract class GooBossRoom extends StandardRoom {
|
public abstract class GooBossRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] sizeCatProbs() {
|
public float[] sizeCatProbs() {
|
||||||
return new float[]{0, 1, 0};
|
return new float[]{0, 1, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static GooBossRoom randomGooRoom(){
|
public static GooBossRoom randomGooRoom(){
|
||||||
switch (Random.Int(4)){
|
switch (Random.Int(4)){
|
||||||
case 0: default:
|
case 0: default:
|
||||||
|
|
|
@ -30,15 +30,17 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class BurnedRoom extends PatchRoom {
|
public class BurnedRoom extends PatchRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] sizeCatProbs() {
|
public float[] sizeCatProbs() {
|
||||||
return new float[]{4, 1, 0};
|
return new float[]{4, 1, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
int cell = l.pointToCell(pointInside(p, 1));
|
||||||
|
return l.map[cell] == Terrain.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
Painter.fill( level, this, Terrain.WALL );
|
||||||
|
|
|
@ -27,10 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||||
|
|
||||||
public class CaveRoom extends PatchRoom {
|
public class CaveRoom extends PatchRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] sizeCatProbs() {
|
public float[] sizeCatProbs() {
|
||||||
return new float[]{4, 2, 1};
|
return new float[]{4, 2, 1};
|
||||||
|
|
|
@ -28,10 +28,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
|
||||||
public class ChasmRoom extends PatchRoom {
|
public class ChasmRoom extends PatchRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] sizeCatProbs() {
|
public float[] sizeCatProbs() {
|
||||||
return new float[]{4, 2, 1};
|
return new float[]{4, 2, 1};
|
||||||
|
|
|
@ -29,10 +29,6 @@ import com.watabou.utils.Rect;
|
||||||
|
|
||||||
public class CircleBasinRoom extends PatchRoom {
|
public class CircleBasinRoom extends PatchRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() { return sizeCat.minDim+1; }
|
public int minWidth() { return sizeCat.minDim+1; }
|
||||||
public int minHeight() {
|
public int minHeight() {
|
||||||
|
|
|
@ -27,10 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||||
|
|
||||||
public class CirclePitRoom extends StandardRoom {
|
public class CirclePitRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(8, super.minWidth());
|
return Math.max(8, super.minWidth());
|
||||||
|
|
|
@ -33,10 +33,6 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class EntranceRoom extends StandardRoom {
|
public class EntranceRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(super.minWidth(), 5);
|
return Math.max(super.minWidth(), 5);
|
||||||
|
@ -47,6 +43,11 @@ public class EntranceRoom extends StandardRoom {
|
||||||
return Math.max(super.minHeight(), 5);
|
return Math.max(super.minHeight(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void paint( Level level ) {
|
public void paint( Level level ) {
|
||||||
|
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
Painter.fill( level, this, Terrain.WALL );
|
||||||
|
|
|
@ -32,10 +32,6 @@ import com.watabou.utils.Rect;
|
||||||
|
|
||||||
public class HallwayRoom extends StandardRoom {
|
public class HallwayRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(5, super.minWidth());
|
return Math.max(5, super.minWidth());
|
||||||
|
@ -46,6 +42,11 @@ public class HallwayRoom extends StandardRoom {
|
||||||
return Math.max(5, super.minHeight());
|
return Math.max(5, super.minHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//FIXME lots of copy-pasta from tunnel rooms here
|
//FIXME lots of copy-pasta from tunnel rooms here
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
|
|
|
@ -26,19 +26,22 @@ 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.traps.ExplosiveTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
|
||||||
import com.watabou.utils.PathFinder;
|
import com.watabou.utils.PathFinder;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class MinefieldRoom extends StandardRoom {
|
public class MinefieldRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] sizeCatProbs() {
|
public float[] sizeCatProbs() {
|
||||||
return new float[]{4, 1, 0};
|
return new float[]{4, 1, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
int cell = l.pointToCell(pointInside(p, 1));
|
||||||
|
return l.map[cell] == Terrain.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
Painter.fill( level, this, Terrain.WALL );
|
||||||
|
|
|
@ -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.watabou.utils.Point;
|
||||||
|
|
||||||
public class RuinsRoom extends PatchRoom {
|
public class RuinsRoom extends PatchRoom {
|
||||||
|
|
||||||
|
@ -32,6 +33,11 @@ public class RuinsRoom extends PatchRoom {
|
||||||
return new float[]{4, 2, 1};
|
return new float[]{4, 2, 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
Painter.fill( level, this, Terrain.WALL );
|
Painter.fill( level, this, Terrain.WALL );
|
||||||
|
|
|
@ -31,10 +31,6 @@ import com.watabou.utils.Rect;
|
||||||
//FIXME some copypasta from segmented room with changed constants in here, might want to externalize
|
//FIXME some copypasta from segmented room with changed constants in here, might want to externalize
|
||||||
public class SegmentedLibraryRoom extends StandardRoom {
|
public class SegmentedLibraryRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] sizeCatProbs() {
|
public float[] sizeCatProbs() {
|
||||||
return new float[]{0, 3, 1};
|
return new float[]{0, 3, 1};
|
||||||
|
|
|
@ -30,10 +30,6 @@ import com.watabou.utils.Rect;
|
||||||
|
|
||||||
public class SegmentedRoom extends StandardRoom {
|
public class SegmentedRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(super.minWidth(), 7);
|
return Math.max(super.minWidth(), 7);
|
||||||
|
|
|
@ -36,10 +36,6 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class SewerPipeRoom extends StandardRoom {
|
public class SewerPipeRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(7, super.minWidth());
|
return Math.max(7, super.minWidth());
|
||||||
|
@ -55,6 +51,11 @@ public class SewerPipeRoom extends StandardRoom {
|
||||||
return new float[]{4, 2, 1};
|
return new float[]{4, 2, 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(Point p) {
|
public boolean canConnect(Point p) {
|
||||||
//refuses connections next to corners
|
//refuses connections next to corners
|
||||||
|
|
|
@ -27,10 +27,6 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||||
|
|
||||||
public class SkullsRoom extends StandardRoom {
|
public class SkullsRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(7, super.minWidth());
|
return Math.max(7, super.minWidth());
|
||||||
|
|
|
@ -22,7 +22,10 @@
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
|
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
import com.watabou.utils.Reflection;
|
import com.watabou.utils.Reflection;
|
||||||
|
|
||||||
|
@ -30,10 +33,6 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public abstract class StandardRoom extends Room {
|
public abstract class StandardRoom extends Room {
|
||||||
|
|
||||||
//whether this room can be joined with other standard rooms
|
|
||||||
//should usually be set to false by rooms that substantially alter terrain
|
|
||||||
public boolean joinable = true;
|
|
||||||
|
|
||||||
public enum SizeCategory {
|
public enum SizeCategory {
|
||||||
|
|
||||||
NORMAL(4, 10, 1),
|
NORMAL(4, 10, 1),
|
||||||
|
@ -102,6 +101,12 @@ public abstract class StandardRoom extends Room {
|
||||||
public int minHeight() { return sizeCat.minDim; }
|
public int minHeight() { return sizeCat.minDim; }
|
||||||
public int maxHeight() { return sizeCat.maxDim; }
|
public int maxHeight() { return sizeCat.maxDim; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
|
int cell = l.pointToCell(pointInside(p, 1));
|
||||||
|
return (Terrain.flags[l.map[cell]] & Terrain.SOLID) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
//FIXME this is a very messy way of handing variable standard rooms
|
//FIXME this is a very messy way of handing variable standard rooms
|
||||||
private static ArrayList<Class<?extends StandardRoom>> rooms = new ArrayList<>();
|
private static ArrayList<Class<?extends StandardRoom>> rooms = new ArrayList<>();
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -31,10 +31,6 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class StudyRoom extends StandardRoom {
|
public class StudyRoom extends StandardRoom {
|
||||||
|
|
||||||
{
|
|
||||||
joinable = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int minWidth() {
|
public int minWidth() {
|
||||||
return Math.max(super.minWidth(), 7);
|
return Math.max(super.minWidth(), 7);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user