v0.9.3: adjusted attack indicator to do less on the actor thread

This commit is contained in:
Evan Debenham
2021-05-31 22:05:34 -04:00
parent 3d01d844b4
commit c067425783
@@ -80,11 +80,17 @@ public class AttackIndicator extends Tag {
PixelScene.align(sprite); PixelScene.align(sprite);
} }
} }
private boolean needsImageUpdate = false;
@Override @Override
public synchronized void update() { public synchronized void update() {
super.update(); super.update();
if (needsImageUpdate){
updateImage();
}
if (!bg.visible){ if (!bg.visible){
enable(false); enable(false);
if (delay > 0f) delay -= Game.elapsed; if (delay > 0f) delay -= Game.elapsed;
@@ -121,7 +127,7 @@ public class AttackIndicator extends Tag {
} else { } else {
active = true; active = true;
lastTarget = Random.element( candidates ); lastTarget = Random.element( candidates );
updateImage(); needsImageUpdate = true;
flash(); flash();
} }
} else { } else {
@@ -182,7 +188,7 @@ public class AttackIndicator extends Tag {
public static void target( Char target ) { public static void target( Char target ) {
synchronized (instance) { synchronized (instance) {
instance.lastTarget = (Mob) target; instance.lastTarget = (Mob) target;
instance.updateImage(); instance.needsImageUpdate = true;
TargetHealthIndicator.instance.target(target); TargetHealthIndicator.instance.target(target);
} }