use RepairIndicator rather than renderer hack

This commit is contained in:
Chris Forbes
2010-01-02 17:52:24 +13:00
parent 3b53f692df
commit 6b1857e0b6
4 changed files with 32 additions and 16 deletions

View File

@@ -0,0 +1,27 @@
using System.Collections.Generic;
using OpenRa.Game.Graphics;
using OpenRa.Game.Traits;
namespace OpenRa.Game.Effects
{
class RepairIndicator : IEffect
{
int framesLeft = (int)(Rules.General.RepairRate * 25 * 60 / 2);
Actor a;
Animation anim = new Animation("select");
public RepairIndicator(Actor a) { this.a = a; anim.PlayRepeating("repair"); }
public void Tick()
{
if (--framesLeft == 0 || a.IsDead)
Game.world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()
{
yield return new Renderable(anim.Image,
a.CenterLocation - .5f * anim.Image.size, PaletteType.Chrome);
}
}
}