Remove RepairIndicator dependence on target RenderSimple.
This also fixes the case where the building palette doesn't match the indicator, and saves 2 trait lookups per tick.
This commit is contained in:
@@ -19,6 +19,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
public readonly int RepairPercent = 20;
|
||||
public readonly int RepairInterval = 24;
|
||||
public readonly int RepairStep = 7;
|
||||
public readonly string IndicatorPalettePrefix = "player";
|
||||
|
||||
public object Create(ActorInitializer init) { return new RepairableBuilding(init.self, this); }
|
||||
}
|
||||
@@ -51,7 +52,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
Sound.PlayNotification(Repairer, "Speech", "Repairing", self.Owner.Country.Race);
|
||||
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(new RepairIndicator(self, p)));
|
||||
w => w.Add(new RepairIndicator(self, Info.IndicatorPalettePrefix, p)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,23 +20,23 @@ namespace OpenRA.Mods.RA.Effects
|
||||
{
|
||||
Actor building;
|
||||
Player player;
|
||||
RenderSimple rs;
|
||||
string palettePrefix;
|
||||
Animation anim = new Animation("allyrepair");
|
||||
RepairableBuilding rb;
|
||||
|
||||
public RepairIndicator(Actor building, Player player)
|
||||
public RepairIndicator(Actor building, string palettePrefix, Player player)
|
||||
{
|
||||
this.building = building;
|
||||
this.player = player;
|
||||
this.palettePrefix = palettePrefix;
|
||||
rb = building.Trait<RepairableBuilding>();
|
||||
anim.PlayRepeating("repair");
|
||||
rs = building.Trait<RenderSimple>();
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (!building.IsInWorld ||
|
||||
building.IsDead() ||
|
||||
building.Trait<RepairableBuilding>().Repairer == null ||
|
||||
building.Trait<RepairableBuilding>().Repairer != player)
|
||||
if (!building.IsInWorld || building.IsDead() ||
|
||||
rb.Repairer == null || rb.Repairer != player)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
anim.Tick();
|
||||
@@ -47,7 +47,8 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (!building.Destroyed)
|
||||
{
|
||||
yield return new Renderable(anim.Image,
|
||||
building.CenterLocation.ToFloat2() - .5f * anim.Image.size, rs.Palette(player, wr), (int)building.CenterLocation.Y);
|
||||
building.CenterLocation.ToFloat2() - .5f * anim.Image.size,
|
||||
wr.Palette(palettePrefix+player.InternalName), (int)building.CenterLocation.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user