v3.3.0: rot garden rooms now have a minimum open size
This commit is contained in:
@@ -58,6 +58,7 @@ public class RotGardenRoom extends SpecialRoom {
|
|||||||
ArrayList<Integer> candidates = new ArrayList<>();
|
ArrayList<Integer> candidates = new ArrayList<>();
|
||||||
boolean[] passable = new boolean[level.length()];
|
boolean[] passable = new boolean[level.length()];
|
||||||
int entryPos = level.pointToCell(entrance());
|
int entryPos = level.pointToCell(entrance());
|
||||||
|
int openCells;
|
||||||
do {
|
do {
|
||||||
Painter.fill(level, this, 1, Terrain.HIGH_GRASS);
|
Painter.fill(level, this, 1, Terrain.HIGH_GRASS);
|
||||||
for (int i = 0; i < 12; i++) {
|
for (int i = 0; i < 12; i++) {
|
||||||
@@ -78,9 +79,11 @@ public class RotGardenRoom extends SpecialRoom {
|
|||||||
//place the heart in a slightly random location sufficiently far from the entrance
|
//place the heart in a slightly random location sufficiently far from the entrance
|
||||||
PathFinder.buildDistanceMap(entryPos, passable);
|
PathFinder.buildDistanceMap(entryPos, passable);
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
openCells = 0;
|
||||||
for (Point p : getPoints()) {
|
for (Point p : getPoints()) {
|
||||||
int i = level.pointToCell(p);
|
int i = level.pointToCell(p);
|
||||||
if (PathFinder.distance[i] != Integer.MAX_VALUE) {
|
if (PathFinder.distance[i] != Integer.MAX_VALUE) {
|
||||||
|
openCells++;
|
||||||
if (PathFinder.distance[i] >= 7) {
|
if (PathFinder.distance[i] >= 7) {
|
||||||
candidates.add(i);
|
candidates.add(i);
|
||||||
}
|
}
|
||||||
@@ -102,7 +105,8 @@ public class RotGardenRoom extends SpecialRoom {
|
|||||||
closestPos++;
|
closestPos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (candidates.isEmpty());
|
//retry if there are no distanc candidates, or more than ~half the room is closed off
|
||||||
|
} while (candidates.isEmpty() || openCells < 35);
|
||||||
int heartPos = Random.element(candidates);
|
int heartPos = Random.element(candidates);
|
||||||
placePlant(level, heartPos, new RotHeart());
|
placePlant(level, heartPos, new RotHeart());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user