Refactor building power-down and Invulnerable effect. Introduces render bugs on state change (effects appearing/dissapearing a frame too late)
This commit is contained in:
36
OpenRa.Game/Effects/PowerDownIndicator.cs
Normal file
36
OpenRa.Game/Effects/PowerDownIndicator.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Traits;
|
||||
|
||||
namespace OpenRa.Game.Effects
|
||||
{
|
||||
class PowerDownIndicator : IEffect
|
||||
{
|
||||
Actor a;
|
||||
Building b;
|
||||
Animation anim = new Animation("powerdown");
|
||||
|
||||
public PowerDownIndicator(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = a.traits.Get<Building>();
|
||||
anim.PlayRepeating("disabled");
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if (!b.Disabled || a.IsDead)
|
||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
foreach (var r in a.Render())
|
||||
yield return r.WithPalette(PaletteType.Disabled);
|
||||
|
||||
if (b.ManuallyDisabled)
|
||||
yield return new Renderable(anim.Image,
|
||||
a.CenterLocation - .5f * anim.Image.size, PaletteType.Chrome);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user