v1.4.0: improved merging logic for a few specific standard room types

This commit is contained in:
Evan Debenham
2022-08-05 16:30:49 -04:00
parent 00bc4ef473
commit a5dc890280
8 changed files with 70 additions and 3 deletions

View File

@@ -306,7 +306,7 @@ public abstract class RegularPainter extends Painter {
}
if (merge.height() >= 3) {
Painter.fill(l, merge.left, merge.top + 1, 1, merge.height()-1, mergeTerrain);
r.merge(l, n, new Rect(merge.left, merge.top + 1, merge.left+1, merge.bottom), mergeTerrain);
return true;
} else {
return false;
@@ -330,7 +330,7 @@ public abstract class RegularPainter extends Painter {
}
if (merge.width() >= 3) {
Painter.fill(l, merge.left + 1, merge.top, merge.width()-1, 1, mergeTerrain);
r.merge(l, n, new Rect(merge.left + 1, merge.top, merge.right, merge.top+1), mergeTerrain);
return true;
} else {
return false;

View File

@@ -22,6 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import com.watabou.utils.Graph;
@@ -241,6 +242,11 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
public boolean canMerge(Level l, Point p, int mergeTerrain){
return false;
}
//can be overriden for special merge logic between rooms
public void merge(Level l, Room other, Rect merge, int mergeTerrain){
Painter.fill(l, merge, mergeTerrain);
}
public boolean addNeigbour( Room other ) {
if (neigbours.contains(other))

View File

@@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Rect;
public class ChasmRoom extends PatchRoom {
@@ -33,6 +34,17 @@ public class ChasmRoom extends PatchRoom {
return new float[]{4, 2, 1};
}
@Override
public void merge(Level l, Room other, Rect merge, int mergeTerrain) {
if (mergeTerrain == Terrain.EMPTY
&& (other instanceof ChasmRoom || other instanceof PlatformRoom)){
super.merge(l, other, merge, Terrain.CHASM);
Painter.set(l, connected.get(other), Terrain.EMPTY);
} else {
super.merge(l, other, merge, mergeTerrain);
}
}
@Override
public void paint(Level level) {
Painter.fill( level, this, Terrain.WALL );

View File

@@ -27,9 +27,21 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Random;
import com.watabou.utils.Rect;
public class GrassyGraveRoom extends StandardRoom {
@Override
public void merge(Level l, Room other, Rect merge, int mergeTerrain) {
if (mergeTerrain == Terrain.EMPTY &&
(other instanceof GrassyGraveRoom || other instanceof PlantsRoom)){
super.merge(l, other, merge, Terrain.GRASS);
} else {
super.merge(l, other, merge, mergeTerrain);
}
}
@Override
public void paint(Level level) {

View File

@@ -25,10 +25,12 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.plants.Firebloom;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
import com.watabou.utils.Rect;
public class PlantsRoom extends StandardRoom {
@@ -47,6 +49,16 @@ public class PlantsRoom extends StandardRoom {
return new float[]{3, 1, 0};
}
@Override
public void merge(Level l, Room other, Rect merge, int mergeTerrain) {
if (mergeTerrain == Terrain.EMPTY &&
(other instanceof PlantsRoom || other instanceof GrassyGraveRoom)){
super.merge(l, other, merge, Terrain.GRASS);
} else {
super.merge(l, other, merge, mergeTerrain);
}
}
@Override
public void paint(Level level) {
Painter.fill( level, this, Terrain.WALL );

View File

@@ -24,6 +24,8 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
import com.watabou.utils.Rect;
@@ -46,6 +48,17 @@ public class PlatformRoom extends StandardRoom {
return new float[]{6, 3, 1};
}
@Override
public void merge(Level l, Room other, Rect merge, int mergeTerrain) {
if (mergeTerrain != Terrain.CHASM
&& (other instanceof PlatformRoom || other instanceof ChasmRoom)){
super.merge(l, other, merge, Terrain.CHASM);
Painter.set(l, connected.get(other), Terrain.EMPTY_SP);
} else {
super.merge(l, other, merge, mergeTerrain);
}
}
@Override
public void paint(Level level) {

View File

@@ -149,7 +149,7 @@ public abstract class StandardRoom extends Room {
private static float[][] chances = new float[27][];
static {
chances[1] = new float[]{10, 10,10,5, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 1,0,1,0,1,0,1,1,0,0};
chances[2] = new float[]{10, 10,10,5, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 1,1,1,1,1,1,1,1,1,1};
chances[2] = new float[]{10, 10,10,5, 0,0,0, 0,0,0, 0,0,0, 0,1000,0, 1,1,1000,1,1,1,1,1,1,1};
chances[4] = chances[3] = chances[2];
chances[5] = new float[]{10, 10,10,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0,0,0,0,0,0,0,0};

View File

@@ -24,7 +24,9 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Random;
import com.watabou.utils.Rect;
public class StripedRoom extends StandardRoom {
@@ -33,6 +35,16 @@ public class StripedRoom extends StandardRoom {
return new float[]{2, 1, 0};
}
@Override
public void merge(Level l, Room other, Rect merge, int mergeTerrain) {
if (other instanceof StripedRoom && mergeTerrain == Terrain.EMPTY){
super.merge(l, other, merge, Terrain.EMPTY_SP);
} else {
super.merge(l, other, merge, mergeTerrain);
}
}
@Override
public void paint(Level level) {
Painter.fill( level, this, Terrain.WALL );