v0.3.5: fixed thrown weapons trigger traps incorrectly while time was frozen

This commit is contained in:
Evan Debenham 2016-03-25 02:04:18 -04:00
parent 7301217975
commit 4bc69be53e
2 changed files with 20 additions and 22 deletions

View File

@ -286,11 +286,11 @@ public class TimekeepersHourglass extends Artifact {
presses.add(cell); presses.add(cell);
} }
public void triggerPresses(){ private void triggerPresses(){
for (int cell : presses) for (int cell : presses)
Dungeon.level.press(cell, null); Dungeon.level.press(cell, null);
presses = new ArrayList<Integer>(); presses = new ArrayList<>();
} }
@Override @Override
@ -304,7 +304,6 @@ public class TimekeepersHourglass extends Artifact {
@Override @Override
public void detach(){ public void detach(){
triggerPresses();
for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0])) for (Mob mob : Dungeon.level.mobs.toArray(new Mob[0]))
mob.sprite.remove(CharSprite.State.PARALYSED); mob.sprite.remove(CharSprite.State.PARALYSED);
GameScene.freezeEmitters = false; GameScene.freezeEmitters = false;
@ -313,6 +312,7 @@ public class TimekeepersHourglass extends Artifact {
updateQuickslot(); updateQuickslot();
super.detach(); super.detach();
activeBuff = null; activeBuff = null;
triggerPresses();
} }
private static final String PRESSES = "presses"; private static final String PRESSES = "presses";

View File

@ -60,20 +60,21 @@ import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth; import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.HighGrass; import com.shatteredpixel.shatteredpixeldungeon.levels.features.HighGrass;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.*; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornTrap;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster; import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush; import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.Game; import com.watabou.noosa.Game;
import com.watabou.noosa.Group; import com.watabou.noosa.Group;
@ -843,13 +844,6 @@ public abstract class Level implements Bundlable {
return; return;
} }
TimekeepersHourglass.timeFreeze timeFreeze = null;
if (ch != null)
timeFreeze = ch.buff(TimekeepersHourglass.timeFreeze.class);
boolean frozen = timeFreeze != null;
Trap trap = null; Trap trap = null;
switch (map[cell]) { switch (map[cell]) {
@ -879,21 +873,25 @@ public abstract class Level implements Bundlable {
break; break;
} }
if (trap != null && !frozen) { TimekeepersHourglass.timeFreeze timeFreeze = Dungeon.hero.buff(TimekeepersHourglass.timeFreeze.class);
if (ch == Dungeon.hero) if (trap != null) {
Dungeon.hero.interrupt(); if (timeFreeze == null) {
trap.trigger(); if (ch == Dungeon.hero)
Dungeon.hero.interrupt();
} else if (trap != null && frozen){ trap.trigger();
Sample.INSTANCE.play(Assets.SND_TRAP); } else {
discover(cell); Sample.INSTANCE.play(Assets.SND_TRAP);
timeFreeze.setDelayedPress( cell ); discover(cell);
timeFreeze.setDelayedPress(cell);
}
} }
Plant plant = plants.get( cell ); Plant plant = plants.get( cell );