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) {
Door.leave( pos );
Door.leave( pos, this );
}
pos = step;
if (flying && Dungeon.level.map[pos] == Terrain.DOOR) {
Door.enter( pos );
Door.enter( pos, this );
}
if (this != Dungeon.hero) {

View File

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

View File

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

View File

@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.features;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
@ -29,21 +30,26 @@ import com.watabou.noosa.audio.Sample;
public class Door {
public static void enter( int pos ) {
public static void enter( int pos, Char ch ) {
Level.set( pos, Terrain.OPEN_DOOR );
GameScene.updateMap( pos );
Dungeon.observe();
if (Dungeon.visible[pos]) {
if (ch == Dungeon.hero){
//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 );
}
}
public static void leave( int pos ) {
if (Dungeon.level.heaps.get( pos ) == null) {
Level.set( pos, Terrain.DOOR );
GameScene.updateMap( pos );
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 );
Dungeon.observe();
//observe already happens when hero moves
if (ch != Dungeon.hero)
Dungeon.observe();
}
}