v1.4.0: improved logic for limiting char and item spawn placement
This commit is contained in:
@@ -231,7 +231,11 @@ public abstract class RegularLevel extends Level {
|
||||
do {
|
||||
mob.pos = pointToCell(roomToSpawn.random());
|
||||
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))));
|
||||
|
||||
if (tries >= 0) {
|
||||
@@ -598,6 +602,7 @@ public abstract class RegularLevel extends Level {
|
||||
if (passable[pos] && !solid[pos]
|
||||
&& pos != exit()
|
||||
&& heaps.get(pos) == null
|
||||
&& room.canPlaceItem(cellToPoint(pos), this)
|
||||
&& findMob(pos) == null) {
|
||||
|
||||
Trap t = traps.get(pos);
|
||||
|
||||
@@ -334,6 +334,22 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
|
||||
}
|
||||
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)
|
||||
public boolean canPlaceCharacter(Point p, Level l){
|
||||
|
||||
Reference in New Issue
Block a user