Merge pull request #7957 from Mailaender/ts-powerdown-indicator-palette

Fixed Tiberian Sun building repair and power down indicator palette
This commit is contained in:
Paul Chote
2015-04-25 19:50:21 +12:00
10 changed files with 38 additions and 13 deletions

View File

@@ -26,8 +26,8 @@ namespace OpenRA.Mods.Common.Effects
this.a = a;
canPowerDown = a.Trait<CanPowerDown>();
anim = new Animation(a.World, "poweroff");
anim.PlayRepeating("offline");
anim = new Animation(a.World, canPowerDown.Info.IndicatorImage);
anim.PlayRepeating(canPowerDown.Info.IndicatorSequence);
}
public void Tick(World world)
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Effects
if (a.Destroyed || wr.World.FogObscures(a))
return SpriteRenderable.None;
return anim.Render(a.CenterPosition, wr.Palette("chrome"));
return anim.Render(a.CenterPosition, wr.Palette(canPowerDown.Info.IndicatorPalette));
}
}
}

View File

@@ -19,18 +19,17 @@ namespace OpenRA.Mods.Common.Effects
class RepairIndicator : IEffect
{
readonly Actor building;
readonly string palettePrefix;
readonly Animation anim;
readonly RepairableBuilding rb;
int shownPlayer = 0;
public RepairIndicator(Actor building, string palettePrefix)
public RepairIndicator(Actor building)
{
this.building = building;
this.palettePrefix = palettePrefix;
rb = building.TraitOrDefault<RepairableBuilding>();
anim = new Animation(building.World, "allyrepair");
rb = building.Trait<RepairableBuilding>();
anim = new Animation(building.World, rb.Info.IndicatorImage);
anim.Paused = () => !rb.RepairActive || rb.IsTraitDisabled;
CycleRepairer();
@@ -38,8 +37,7 @@ namespace OpenRA.Mods.Common.Effects
public void Tick(World world)
{
if (!building.IsInWorld || building.IsDead ||
rb == null || !rb.Repairers.Any())
if (!building.IsInWorld || building.IsDead || !rb.Repairers.Any())
world.AddFrameEndTask(w => w.Remove(this));
anim.Tick();
@@ -50,13 +48,18 @@ namespace OpenRA.Mods.Common.Effects
if (building.Destroyed || wr.World.FogObscures(building) || rb.Repairers.Count == 0)
return SpriteRenderable.None;
var palette = wr.Palette(palettePrefix + rb.Repairers[shownPlayer % rb.Repairers.Count].InternalName);
PaletteReference palette;
if (!string.IsNullOrEmpty(rb.Info.IndicatorPalette))
palette = wr.Palette(rb.Info.IndicatorPalette);
else
palette = wr.Palette(rb.Info.IndicatorPalettePrefix + rb.Repairers[shownPlayer % rb.Repairers.Count].InternalName);
return anim.Render(building.CenterPosition, palette);
}
void CycleRepairer()
{
anim.PlayThen("repair", CycleRepairer);
anim.PlayThen(rb.Info.IndicatorSequence, CycleRepairer);
if (++shownPlayer == rb.Repairers.Count)
shownPlayer = 0;