From abbdcff9eacce749edf6920d29ef9fc0e001eda3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 7 Jun 2015 03:38:40 -0400 Subject: [PATCH] v0.3.0c: fixed some bugs relating to removing Actor.chars[], can now find mobs within a level by position too. --- .../shatteredpixeldungeon/levels/Level.java | 9 +++++++++ .../shatteredpixeldungeon/levels/RegularLevel.java | 4 ++-- .../levels/painters/PoolPainter.java | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 2e77573e9..b6e35451c 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -470,6 +470,15 @@ public abstract class Level implements Bundlable { public int nMobs() { return 0; } + + public Mob findMob( int pos ){ + for (Mob mob : mobs){ + if (mob.pos == pos){ + return mob; + } + } + return null; + } public Actor respawner() { return new Actor() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index e7c7815a8..6430edf96 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -588,7 +588,7 @@ public abstract class RegularLevel extends Level { Mob mob = Bestiary.mob( Dungeon.depth ); mob.pos = roomToSpawn.random(); - if (Actor.findChar(mob.pos) == null && Level.passable[mob.pos]) { + if (findMob(mob.pos) == null && Level.passable[mob.pos]) { mobsToSpawn--; mobs.add(mob); @@ -597,7 +597,7 @@ public abstract class RegularLevel extends Level { mob = Bestiary.mob( Dungeon.depth ); mob.pos = roomToSpawn.random(); - if (Actor.findChar(mob.pos) == null && Level.passable[mob.pos]) { + if (findMob(mob.pos) == null && Level.passable[mob.pos]) { mobsToSpawn--; mobs.add(mob); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/PoolPainter.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/PoolPainter.java index 6e0046530..0aaea3b94 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/PoolPainter.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/painters/PoolPainter.java @@ -75,7 +75,7 @@ public class PoolPainter extends Painter { Piranha piranha = new Piranha(); do { 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 ); } }