Fix powerdown effect + flash
This commit is contained in:
@@ -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<Renderable> 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user