From 840a17d255dca7ebe0d2938f7b2c8ef391399656 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 8 Jan 2010 22:28:01 +1300 Subject: [PATCH] Fix powerdown effect + flash --- OpenRa.Game/Effects/PowerDownIndicator.cs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/OpenRa.Game/Effects/PowerDownIndicator.cs b/OpenRa.Game/Effects/PowerDownIndicator.cs index 185366a078..55858a6f54 100644 --- a/OpenRa.Game/Effects/PowerDownIndicator.cs +++ b/OpenRa.Game/Effects/PowerDownIndicator.cs @@ -9,7 +9,10 @@ namespace OpenRa.Game.Effects Actor a; Building b; Animation anim = new Animation("powerdown"); - + bool removeNextFrame = false; + bool indicatorState = true; + int stateTicks = 0; + public PowerDownIndicator(Actor a) { this.a = a; @@ -19,8 +22,19 @@ namespace OpenRa.Game.Effects public void Tick() { - if (!b.Disabled || a.IsDead) + if (removeNextFrame == true) Game.world.AddFrameEndTask(w => w.Remove(this)); + + // Fix off-by one frame bug with undisabling causing low-power + if (!b.Disabled || a.IsDead) + removeNextFrame = true; + + // Flash power icon + if (++stateTicks == 15) + { + stateTicks = 0; + indicatorState = !indicatorState; + } } public IEnumerable Render() @@ -28,7 +42,7 @@ namespace OpenRa.Game.Effects foreach (var r in a.Render()) yield return r.WithPalette(PaletteType.Disabled); - if (b.ManuallyDisabled) + if (b.ManuallyDisabled && indicatorState) yield return new Renderable(anim.Image, a.CenterLocation - .5f * anim.Image.size, PaletteType.Chrome); }