v1.4.0: improved logic for limiting char and item spawn placement
This commit is contained in:
+6
-1
@@ -231,7 +231,11 @@ public abstract class RegularLevel extends Level {
|
|||||||
do {
|
do {
|
||||||
mob.pos = pointToCell(roomToSpawn.random());
|
mob.pos = pointToCell(roomToSpawn.random());
|
||||||
tries--;
|
tries--;
|
||||||
} while (tries >= 0 && (findMob(mob.pos) != null || !passable[mob.pos] || solid[mob.pos] || mob.pos == exit()
|
} while (tries >= 0 && (findMob(mob.pos) != null
|
||||||
|
|| !passable[mob.pos]
|
||||||
|
|| solid[mob.pos]
|
||||||
|
|| !roomToSpawn.canPlaceCharacter(cellToPoint(mob.pos), this)
|
||||||
|
|| mob.pos == exit()
|
||||||
|| (!openSpace[mob.pos] && mob.properties().contains(Char.Property.LARGE))));
|
|| (!openSpace[mob.pos] && mob.properties().contains(Char.Property.LARGE))));
|
||||||
|
|
||||||
if (tries >= 0) {
|
if (tries >= 0) {
|
||||||
@@ -598,6 +602,7 @@ public abstract class RegularLevel extends Level {
|
|||||||
if (passable[pos] && !solid[pos]
|
if (passable[pos] && !solid[pos]
|
||||||
&& pos != exit()
|
&& pos != exit()
|
||||||
&& heaps.get(pos) == null
|
&& heaps.get(pos) == null
|
||||||
|
&& room.canPlaceItem(cellToPoint(pos), this)
|
||||||
&& findMob(pos) == null) {
|
&& findMob(pos) == null) {
|
||||||
|
|
||||||
Trap t = traps.get(pos);
|
Trap t = traps.get(pos);
|
||||||
|
|||||||
@@ -335,6 +335,22 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
|
|||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//whether or not an item can be placed here (usually via randomDropCell)
|
||||||
|
public boolean canPlaceItem(Point p, Level l){
|
||||||
|
return inside(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final ArrayList<Point> itemPlaceablePoints(Level l){
|
||||||
|
ArrayList<Point> points = new ArrayList<>();
|
||||||
|
for (int i = left; i <= right; i++) {
|
||||||
|
for (int j = top; j <= bottom; j++) {
|
||||||
|
Point p = new Point(i, j);
|
||||||
|
if (canPlaceItem(p, l)) points.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
//whether or not a character can be placed here (usually via spawn, tele, or wander)
|
//whether or not a character can be placed here (usually via spawn, tele, or wander)
|
||||||
public boolean canPlaceCharacter(Point p, Level l){
|
public boolean canPlaceCharacter(Point p, Level l){
|
||||||
return inside(p);
|
return inside(p);
|
||||||
|
|||||||
Reference in New Issue
Block a user