diff --git a/OpenRA.Mods.Common/Effects/PowerdownIndicator.cs b/OpenRA.Mods.Common/Effects/PowerdownIndicator.cs index a2bc6eadb1..735c9aa3c2 100644 --- a/OpenRA.Mods.Common/Effects/PowerdownIndicator.cs +++ b/OpenRA.Mods.Common/Effects/PowerdownIndicator.cs @@ -26,8 +26,8 @@ namespace OpenRA.Mods.Common.Effects this.a = a; canPowerDown = a.Trait(); - 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)); } } } diff --git a/OpenRA.Mods.Common/Effects/RepairIndicator.cs b/OpenRA.Mods.Common/Effects/RepairIndicator.cs index d5227b0d2f..8ec8092ac5 100644 --- a/OpenRA.Mods.Common/Effects/RepairIndicator.cs +++ b/OpenRA.Mods.Common/Effects/RepairIndicator.cs @@ -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(); - anim = new Animation(building.World, "allyrepair"); + rb = building.Trait(); + 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; diff --git a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs index 4718b7ba87..b966bc6129 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/RepairableBuilding.cs @@ -25,6 +25,13 @@ namespace OpenRA.Mods.Common.Traits public readonly int[] RepairBonuses = { 100, 150, 175, 200, 220, 240, 260, 280, 300 }; public readonly bool CancelWhenDisabled = false; + public readonly string IndicatorImage = "allyrepair"; + public readonly string IndicatorSequence = "repair"; + + [Desc("Overrides the IndicatorPalettePrefix.")] + public readonly string IndicatorPalette = ""; + + [Desc("Suffixed by the interal repairing player name.")] public readonly string IndicatorPalettePrefix = "player"; public object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); } @@ -61,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits self.World.AddFrameEndTask(w => { if (!self.IsDead) - w.Add(new RepairIndicator(self, Info.IndicatorPalettePrefix)); + w.Add(new RepairIndicator(self)); }); } } diff --git a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs index 4f3c9db2a4..b6902f44b1 100644 --- a/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs +++ b/OpenRA.Mods.Common/Traits/Power/CanPowerDown.cs @@ -19,6 +19,11 @@ namespace OpenRA.Mods.Common.Traits [Desc("Restore power when this trait is disabled.")] public readonly bool CancelWhenDisabled = false; + public readonly string IndicatorImage = "poweroff"; + public readonly string IndicatorSequence = "offline"; + + public readonly string IndicatorPalette = "chrome"; + public object Create(ActorInitializer init) { return new CanPowerDown(init.Self, this); } } diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index f60819da21..d9fd9790a9 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -24,6 +24,7 @@ DeathSequence: dead UseDeathTypeSuffix: false RepairableBuilding: + IndicatorPalette: mouse EngineerRepairable: EmitInfantryOnSell@gdi: ActorTypes: e1, e1, e2, medic diff --git a/mods/ts/rules/gdi-structures.yaml b/mods/ts/rules/gdi-structures.yaml index c2ae0cc44d..6ecf481663 100644 --- a/mods/ts/rules/gdi-structures.yaml +++ b/mods/ts/rules/gdi-structures.yaml @@ -247,6 +247,7 @@ GARADR: Type: Wood RequiresPower: CanPowerDown: + IndicatorPalette: mouse ProvidesRadar: InfiltrateForExploration: DetectCloaked: @@ -309,6 +310,7 @@ GAPLUG: Dimensions: 2,3 RequiresPower: CanPowerDown: + IndicatorPalette: mouse DisabledOverlay: RenderBuilding: WithIdleOverlay@DISH: diff --git a/mods/ts/rules/gdi-support.yaml b/mods/ts/rules/gdi-support.yaml index af1d651fd1..e367a15e5a 100644 --- a/mods/ts/rules/gdi-support.yaml +++ b/mods/ts/rules/gdi-support.yaml @@ -62,6 +62,7 @@ GACTWR: UpgradeTypes: tower UpgradeMinEnabledLevel: 1 CanPowerDown: + IndicatorPalette: mouse WithTurret@VULC: UpgradeTypes: tower.vulcan UpgradeMinEnabledLevel: 1 diff --git a/mods/ts/rules/nod-structures.yaml b/mods/ts/rules/nod-structures.yaml index f0abc754ca..15118349d8 100644 --- a/mods/ts/rules/nod-structures.yaml +++ b/mods/ts/rules/nod-structures.yaml @@ -211,6 +211,7 @@ NARADR: Type: Wood RequiresPower: CanPowerDown: + IndicatorPalette: mouse ProvidesRadar: InfiltrateForExploration: DetectCloaked: @@ -285,6 +286,7 @@ NASTLH: Amount: -350 RequiresPower: CanPowerDown: + IndicatorPalette: mouse UpgradeActorsNear: Upgrades: cloakgenerator Range: 12c0 diff --git a/mods/ts/rules/nod-support.yaml b/mods/ts/rules/nod-support.yaml index 179c68d33c..1133f23eeb 100644 --- a/mods/ts/rules/nod-support.yaml +++ b/mods/ts/rules/nod-support.yaml @@ -273,6 +273,7 @@ NAMISL: Power: Amount: -50 CanPowerDown: + IndicatorPalette: mouse RequiresPower: DisabledOverlay: SupportPowerChargeBar: diff --git a/mods/ts/rules/world.yaml b/mods/ts/rules/world.yaml index 4c36e7e5ce..390e7cf33c 100644 --- a/mods/ts/rules/world.yaml +++ b/mods/ts/rules/world.yaml @@ -10,6 +10,9 @@ World: BuildingInfluence: ProductionQueueFromSelection: ProductionPaletteWidget: PRODUCTION_PALETTE + PaletteFromFile@mouse: + Name: mouse + Filename: mousepal.pal PaletteFromFile@playersno: Name: player Tileset: SNOW