v0.3.0c: fixed some bugs relating to removing Actor.chars[], can now find mobs within a level by position too.
This commit is contained in:
parent
5cfd0385ae
commit
abbdcff9ea
|
@ -471,6 +471,15 @@ public abstract class Level implements Bundlable {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Mob findMob( int pos ){
|
||||||
|
for (Mob mob : mobs){
|
||||||
|
if (mob.pos == pos){
|
||||||
|
return mob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Actor respawner() {
|
public Actor respawner() {
|
||||||
return new Actor() {
|
return new Actor() {
|
||||||
|
|
||||||
|
|
|
@ -588,7 +588,7 @@ public abstract class RegularLevel extends Level {
|
||||||
Mob mob = Bestiary.mob( Dungeon.depth );
|
Mob mob = Bestiary.mob( Dungeon.depth );
|
||||||
mob.pos = roomToSpawn.random();
|
mob.pos = roomToSpawn.random();
|
||||||
|
|
||||||
if (Actor.findChar(mob.pos) == null && Level.passable[mob.pos]) {
|
if (findMob(mob.pos) == null && Level.passable[mob.pos]) {
|
||||||
mobsToSpawn--;
|
mobsToSpawn--;
|
||||||
mobs.add(mob);
|
mobs.add(mob);
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ public abstract class RegularLevel extends Level {
|
||||||
mob = Bestiary.mob( Dungeon.depth );
|
mob = Bestiary.mob( Dungeon.depth );
|
||||||
mob.pos = roomToSpawn.random();
|
mob.pos = roomToSpawn.random();
|
||||||
|
|
||||||
if (Actor.findChar(mob.pos) == null && Level.passable[mob.pos]) {
|
if (findMob(mob.pos) == null && Level.passable[mob.pos]) {
|
||||||
mobsToSpawn--;
|
mobsToSpawn--;
|
||||||
mobs.add(mob);
|
mobs.add(mob);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class PoolPainter extends Painter {
|
||||||
Piranha piranha = new Piranha();
|
Piranha piranha = new Piranha();
|
||||||
do {
|
do {
|
||||||
piranha.pos = room.random();
|
piranha.pos = room.random();
|
||||||
} while (level.map[piranha.pos] != Terrain.WATER|| Actor.findChar( piranha.pos ) != null);
|
} while (level.map[piranha.pos] != Terrain.WATER|| level.findMob( piranha.pos ) != null);
|
||||||
level.mobs.add( piranha );
|
level.mobs.add( piranha );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user