v0.4.2: fixed some redundant observe calls

This commit is contained in:
Evan Debenham 2016-08-26 20:15:19 -04:00 committed by Evan Debenham
parent 50f6329578
commit a8e04b51ca
5 changed files with 25 additions and 17 deletions

View File

@ -412,13 +412,13 @@ public abstract class Char extends Actor {
} }
if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) { if (Dungeon.level.map[pos] == Terrain.OPEN_DOOR) {
Door.leave( pos ); Door.leave( pos, this );
} }
pos = step; pos = step;
if (flying && Dungeon.level.map[pos] == Terrain.DOOR) { if (flying && Dungeon.level.map[pos] == Terrain.DOOR) {
Door.enter( pos ); Door.enter( pos, this );
} }
if (this != Dungeon.hero) { if (this != Dungeon.hero) {

View File

@ -103,7 +103,7 @@ public class Swarm extends Mob {
clone.state = clone.HUNTING; clone.state = clone.HUNTING;
if (Dungeon.level.map[clone.pos] == Terrain.DOOR) { if (Dungeon.level.map[clone.pos] == Terrain.DOOR) {
Door.enter( clone.pos ); Door.enter( clone.pos, clone );
} }
GameScene.add( clone, SPLIT_DELAY ); GameScene.add( clone, SPLIT_DELAY );

View File

@ -843,7 +843,7 @@ public abstract class Level implements Bundlable {
break; break;
case Terrain.DOOR: case Terrain.DOOR:
Door.enter( cell ); Door.enter( cell, ch );
break; break;
} }
@ -891,7 +891,7 @@ public abstract class Level implements Bundlable {
break; break;
case Terrain.DOOR: case Terrain.DOOR:
Door.enter( cell ); Door.enter( cell, mob );
break; break;
} }

View File

@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.features;
import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
@ -29,21 +30,26 @@ import com.watabou.noosa.audio.Sample;
public class Door { public class Door {
public static void enter( int pos ) { public static void enter( int pos, Char ch ) {
Level.set( pos, Terrain.OPEN_DOOR ); Level.set( pos, Terrain.OPEN_DOOR );
GameScene.updateMap( pos ); GameScene.updateMap( pos );
Dungeon.observe();
if (ch == Dungeon.hero){
if (Dungeon.visible[pos]) { //don't obsserve here as that already happens on hero move
Sample.INSTANCE.play( Assets.SND_OPEN );
} else if (Dungeon.visible[pos]) {
Sample.INSTANCE.play( Assets.SND_OPEN ); Sample.INSTANCE.play( Assets.SND_OPEN );
}
}
public static void leave( int pos ) {
if (Dungeon.level.heaps.get( pos ) == null) {
Level.set( pos, Terrain.DOOR );
GameScene.updateMap( pos );
Dungeon.observe(); Dungeon.observe();
} }
} }
public static void leave( int pos, Char ch ) {
if (Dungeon.level.heaps.get( pos ) == null) {
Level.set( pos, Terrain.DOOR );
GameScene.updateMap( pos );
if (ch != Dungeon.hero && Dungeon.visible[pos])
Dungeon.observe();
}
}
} }

View File

@ -103,6 +103,8 @@ public class HighGrass {
} }
CellEmitter.get( pos ).burst( LeafParticle.LEVEL_SPECIFIC, leaves ); CellEmitter.get( pos ).burst( LeafParticle.LEVEL_SPECIFIC, leaves );
Dungeon.observe(); //observe already happens when hero moves
if (ch != Dungeon.hero)
Dungeon.observe();
} }
} }