From fc6b08e2f14ee08429c108469282398177a16f15 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 13 Jun 2021 14:25:48 -0400 Subject: [PATCH] v0.9.3a: fixed ally rats forgetting ally state on game load --- .../shatteredpixeldungeon/actors/mobs/Rat.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Rat.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Rat.java index f85d825e5..8908e168d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Rat.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Rat.java @@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.abilities.Ratmogrify; import com.shatteredpixel.shatteredpixeldungeon.sprites.RatSprite; +import com.watabou.utils.Bundle; import com.watabou.utils.Random; public class Rat extends Mob { @@ -61,4 +62,18 @@ public class Rat extends Mob { public int drRoll() { return Random.NormalIntRange(0, 1); } + + private static final String RAT_ALLY = "rat_ally"; + + @Override + public void storeInBundle(Bundle bundle) { + super.storeInBundle(bundle); + if (alignment == Alignment.ALLY) bundle.put(RAT_ALLY, true); + } + + @Override + public void restoreFromBundle(Bundle bundle) { + super.restoreFromBundle(bundle); + if (bundle.contains(RAT_ALLY)) alignment = Alignment.ALLY; + } }