use RepairIndicator rather than renderer hack
This commit is contained in:
27
OpenRa.Game/Effects/RepairIndicator.cs
Normal file
27
OpenRa.Game/Effects/RepairIndicator.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -84,17 +84,6 @@ namespace OpenRa.Game.Graphics
|
|||||||
|
|
||||||
DrawBandBox();
|
DrawBandBox();
|
||||||
|
|
||||||
|
|
||||||
foreach(var a in Game.world.Actors.Where(b => b.Owner == Game.LocalPlayer && b.traits.Contains<Building>() && b.traits.Get<Building>().IsRepairing()))
|
|
||||||
{
|
|
||||||
var bounds = a.GetBounds(true);
|
|
||||||
|
|
||||||
var repairImages = new Animation("select");
|
|
||||||
repairImages.PlayRepeating("repair");
|
|
||||||
spriteRenderer.DrawSprite(repairImages.Image, new float2(.5f * (bounds.Left + bounds.Right)-12, .5f * (bounds.Top + bounds.Bottom)-11), PaletteType.Chrome);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (Game.controller.orderGenerator != null)
|
if (Game.controller.orderGenerator != null)
|
||||||
Game.controller.orderGenerator.Render();
|
Game.controller.orderGenerator.Render();
|
||||||
|
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
<Compile Include="Effects\Corpse.cs" />
|
<Compile Include="Effects\Corpse.cs" />
|
||||||
<Compile Include="Effects\DelayedAction.cs" />
|
<Compile Include="Effects\DelayedAction.cs" />
|
||||||
<Compile Include="Effects\MoveFlash.cs" />
|
<Compile Include="Effects\MoveFlash.cs" />
|
||||||
|
<Compile Include="Effects\RepairIndicator.cs" />
|
||||||
<Compile Include="Effects\Smoke.cs" />
|
<Compile Include="Effects\Smoke.cs" />
|
||||||
<Compile Include="Effects\TeslaZap.cs" />
|
<Compile Include="Effects\TeslaZap.cs" />
|
||||||
<Compile Include="Exts.cs" />
|
<Compile Include="Exts.cs" />
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using OpenRa.Game.Effects;
|
||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
@@ -44,10 +45,6 @@ namespace OpenRa.Game.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRepairing(){
|
|
||||||
return isRepairing;
|
|
||||||
}
|
|
||||||
|
|
||||||
int remainingTicks;
|
int remainingTicks;
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
@@ -62,8 +59,10 @@ namespace OpenRa.Game.Traits
|
|||||||
if (!self.Owner.TakeCash(cost))
|
if (!self.Owner.TakeCash(cost))
|
||||||
{
|
{
|
||||||
remainingTicks = 1;
|
remainingTicks = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Game.world.AddFrameEndTask(w => w.Add(new RepairIndicator(self)));
|
||||||
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
|
self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]);
|
||||||
if (self.Health == self.Info.Strength)
|
if (self.Health == self.Info.Strength)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user