v0.7.5: refactored room selection logic for mob spawning
This commit is contained in:
parent
20f49ac600
commit
7f13e1cefa
|
@ -195,29 +195,32 @@ public abstract class RegularLevel extends Level {
|
||||||
Iterator<Room> stdRoomIter = stdRooms.iterator();
|
Iterator<Room> stdRoomIter = stdRooms.iterator();
|
||||||
|
|
||||||
while (mobsToSpawn > 0) {
|
while (mobsToSpawn > 0) {
|
||||||
if (!stdRoomIter.hasNext())
|
|
||||||
stdRoomIter = stdRooms.iterator();
|
|
||||||
Room roomToSpawn = stdRoomIter.next();
|
|
||||||
|
|
||||||
Mob mob = createMob();
|
Mob mob = createMob();
|
||||||
mob.pos = pointToCell(roomToSpawn.random());
|
Room roomToSpawn;
|
||||||
|
|
||||||
|
if (!stdRoomIter.hasNext()) {
|
||||||
|
stdRoomIter = stdRooms.iterator();
|
||||||
|
}
|
||||||
|
roomToSpawn = stdRoomIter.next();
|
||||||
|
|
||||||
|
do {
|
||||||
|
mob.pos = pointToCell(roomToSpawn.random());
|
||||||
|
} while (findMob(mob.pos) != null || !passable[mob.pos] || mob.pos == exit);
|
||||||
|
|
||||||
if (findMob(mob.pos) == null && passable[mob.pos] && mob.pos != exit) {
|
|
||||||
mobsToSpawn--;
|
mobsToSpawn--;
|
||||||
mobs.add(mob);
|
mobs.add(mob);
|
||||||
|
|
||||||
//TODO: perhaps externalize this logic into a method. Do I want to make mobs more likely to clump deeper down?
|
|
||||||
if (mobsToSpawn > 0 && Random.Int(4) == 0){
|
if (mobsToSpawn > 0 && Random.Int(4) == 0){
|
||||||
mob = createMob();
|
mob = createMob();
|
||||||
mob.pos = pointToCell(roomToSpawn.random());
|
|
||||||
|
|
||||||
if (findMob(mob.pos) == null && passable[mob.pos] && mob.pos != exit) {
|
do {
|
||||||
|
mob.pos = pointToCell(roomToSpawn.random());
|
||||||
|
} while (findMob(mob.pos) != null || !passable[mob.pos] || mob.pos == exit);
|
||||||
|
|
||||||
mobsToSpawn--;
|
mobsToSpawn--;
|
||||||
mobs.add(mob);
|
mobs.add(mob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Mob m : mobs){
|
for (Mob m : mobs){
|
||||||
if (map[m.pos] == Terrain.HIGH_GRASS || map[m.pos] == Terrain.FURROWED_GRASS) {
|
if (map[m.pos] == Terrain.HIGH_GRASS || map[m.pos] == Terrain.FURROWED_GRASS) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user