1078: Added ally repairing for CNC and RA

This commit is contained in:
Curtis S
2011-09-10 16:41:40 -06:00
parent 1d052bbfa2
commit be9948426c
11 changed files with 115 additions and 41 deletions

View File

@@ -18,27 +18,37 @@ namespace OpenRA.Mods.RA.Effects
{
class RepairIndicator : IEffect
{
int framesLeft;
Actor a;
Animation anim = new Animation("select");
Actor building;
Player player;
Animation anim = new Animation("allyrepair");
public RepairIndicator(Actor a, int frames)
{
this.a = a; anim.PlayRepeating("repair");
framesLeft = frames;
public RepairIndicator(Actor building, Player player)
{
this.building = building;
this.player = player;
anim.PlayRepeating("repair");
}
public void Tick( World world )
public void Tick(World world)
{
if (--framesLeft == 0 || !a.IsInWorld || a.IsDead())
if (!building.IsInWorld ||
building.IsDead() ||
building.Trait<RepairableBuilding>().Repairer == null ||
building.Trait<RepairableBuilding>().Repairer != player)
world.AddFrameEndTask(w => w.Remove(this));
anim.Tick();
}
public IEnumerable<Renderable> Render()
{
if (!a.Destroyed)
yield return new Renderable(anim.Image,
a.CenterLocation - .5f * anim.Image.size, "chrome", (int)a.CenterLocation.Y);
if (!building.Destroyed)
{
var palette = building.Trait<RenderSimple>().Palette(player);
yield return new Renderable(anim.Image,
building.CenterLocation - .5f * anim.Image.size, palette, (int)building.CenterLocation.Y);
}
}
}
}