v0.9.0: fixed a freeze bug caused by a race condition on DM-300's sprite

This commit is contained in:
Evan Debenham 2020-09-20 14:09:05 -04:00
parent 2a48f2e944
commit 0913c65d81
2 changed files with 7 additions and 10 deletions

View File

@ -461,6 +461,7 @@ public class NewDM300 extends Mob {
spend(3f); spend(3f);
yell(Messages.get(this, "charging")); yell(Messages.get(this, "charging"));
sprite.showStatus(CharSprite.POSITIVE, Messages.get(this, "invulnerable")); sprite.showStatus(CharSprite.POSITIVE, Messages.get(this, "invulnerable"));
((DM300Sprite)sprite).updateChargeState(true);
((DM300Sprite)sprite).charge(); ((DM300Sprite)sprite).charge();
chargeAnnounced = false; chargeAnnounced = false;
@ -472,7 +473,7 @@ public class NewDM300 extends Mob {
public void loseSupercharge(){ public void loseSupercharge(){
supercharged = false; supercharged = false;
sprite.resetColor(); ((DM300Sprite)sprite).updateChargeState(false);
if (pylonsActivated < 2){ if (pylonsActivated < 2){
yell(Messages.get(this, "charge_lost")); yell(Messages.get(this, "charge_lost"));

View File

@ -45,10 +45,12 @@ public class DM300Sprite extends MobSprite {
texture( Assets.Sprites.DM300 ); texture( Assets.Sprites.DM300 );
setAnimations(false); updateChargeState(false);
} }
private void setAnimations( boolean enraged ){ public void updateChargeState( boolean enraged ){
if (superchargeSparks != null) superchargeSparks.on = enraged;
int c = enraged ? 10 : 0; int c = enraged ? 10 : 0;
TextureFilm frames = new TextureFilm( texture, 25, 22 ); TextureFilm frames = new TextureFilm( texture, 25, 22 );
@ -148,8 +150,7 @@ public class DM300Sprite extends MobSprite {
superchargeSparks.on = false; superchargeSparks.on = false;
if (ch instanceof NewDM300 && ((NewDM300) ch).isSupercharged()){ if (ch instanceof NewDM300 && ((NewDM300) ch).isSupercharged()){
setAnimations(true); updateChargeState(true);
superchargeSparks.on = true;
} }
} }
@ -159,11 +160,6 @@ public class DM300Sprite extends MobSprite {
if (superchargeSparks != null){ if (superchargeSparks != null){
superchargeSparks.visible = visible; superchargeSparks.visible = visible;
if (ch instanceof NewDM300
&& ((NewDM300) ch).isSupercharged() != superchargeSparks.on){
superchargeSparks.on = ((NewDM300) ch).isSupercharged();
setAnimations(((NewDM300) ch).isSupercharged());
}
} }
} }