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; this.a = a;
canPowerDown = a.Trait<CanPowerDown>(); canPowerDown = a.Trait<CanPowerDown>();
anim = new Animation(a.World, "poweroff"); anim = new Animation(a.World, canPowerDown.Info.IndicatorImage);
anim.PlayRepeating("offline"); anim.PlayRepeating(canPowerDown.Info.IndicatorSequence);
} }
public void Tick(World world) public void Tick(World world)
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Effects
if (a.Destroyed || wr.World.FogObscures(a)) if (a.Destroyed || wr.World.FogObscures(a))
return SpriteRenderable.None; 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 class RepairIndicator : IEffect
{ {
readonly Actor building; readonly Actor building;
readonly string palettePrefix;
readonly Animation anim; readonly Animation anim;
readonly RepairableBuilding rb; readonly RepairableBuilding rb;
int shownPlayer = 0; int shownPlayer = 0;
public RepairIndicator(Actor building, string palettePrefix) public RepairIndicator(Actor building)
{ {
this.building = building; this.building = building;
this.palettePrefix = palettePrefix;
rb = building.TraitOrDefault<RepairableBuilding>(); rb = building.Trait<RepairableBuilding>();
anim = new Animation(building.World, "allyrepair"); anim = new Animation(building.World, rb.Info.IndicatorImage);
anim.Paused = () => !rb.RepairActive || rb.IsTraitDisabled; anim.Paused = () => !rb.RepairActive || rb.IsTraitDisabled;
CycleRepairer(); CycleRepairer();
@@ -38,8 +37,7 @@ namespace OpenRA.Mods.Common.Effects
public void Tick(World world) public void Tick(World world)
{ {
if (!building.IsInWorld || building.IsDead || if (!building.IsInWorld || building.IsDead || !rb.Repairers.Any())
rb == null || !rb.Repairers.Any())
world.AddFrameEndTask(w => w.Remove(this)); world.AddFrameEndTask(w => w.Remove(this));
anim.Tick(); anim.Tick();
@@ -50,13 +48,18 @@ namespace OpenRA.Mods.Common.Effects
if (building.Destroyed || wr.World.FogObscures(building) || rb.Repairers.Count == 0) if (building.Destroyed || wr.World.FogObscures(building) || rb.Repairers.Count == 0)
return SpriteRenderable.None; 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); return anim.Render(building.CenterPosition, palette);
} }
void CycleRepairer() void CycleRepairer()
{ {
anim.PlayThen("repair", CycleRepairer); anim.PlayThen(rb.Info.IndicatorSequence, CycleRepairer);
if (++shownPlayer == rb.Repairers.Count) if (++shownPlayer == rb.Repairers.Count)
shownPlayer = 0; shownPlayer = 0;

View File

@@ -25,6 +25,13 @@ namespace OpenRA.Mods.Common.Traits
public readonly int[] RepairBonuses = { 100, 150, 175, 200, 220, 240, 260, 280, 300 }; public readonly int[] RepairBonuses = { 100, 150, 175, 200, 220, 240, 260, 280, 300 };
public readonly bool CancelWhenDisabled = false; 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 readonly string IndicatorPalettePrefix = "player";
public object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); } public object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); }
@@ -61,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
self.World.AddFrameEndTask(w => self.World.AddFrameEndTask(w =>
{ {
if (!self.IsDead) if (!self.IsDead)
w.Add(new RepairIndicator(self, Info.IndicatorPalettePrefix)); w.Add(new RepairIndicator(self));
}); });
} }
} }

View File

@@ -19,6 +19,11 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Restore power when this trait is disabled.")] [Desc("Restore power when this trait is disabled.")]
public readonly bool CancelWhenDisabled = false; 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); } public object Create(ActorInitializer init) { return new CanPowerDown(init.Self, this); }
} }

View File

@@ -24,6 +24,7 @@
DeathSequence: dead DeathSequence: dead
UseDeathTypeSuffix: false UseDeathTypeSuffix: false
RepairableBuilding: RepairableBuilding:
IndicatorPalette: mouse
EngineerRepairable: EngineerRepairable:
EmitInfantryOnSell@gdi: EmitInfantryOnSell@gdi:
ActorTypes: e1, e1, e2, medic ActorTypes: e1, e1, e2, medic

View File

@@ -247,6 +247,7 @@ GARADR:
Type: Wood Type: Wood
RequiresPower: RequiresPower:
CanPowerDown: CanPowerDown:
IndicatorPalette: mouse
ProvidesRadar: ProvidesRadar:
InfiltrateForExploration: InfiltrateForExploration:
DetectCloaked: DetectCloaked:
@@ -309,6 +310,7 @@ GAPLUG:
Dimensions: 2,3 Dimensions: 2,3
RequiresPower: RequiresPower:
CanPowerDown: CanPowerDown:
IndicatorPalette: mouse
DisabledOverlay: DisabledOverlay:
RenderBuilding: RenderBuilding:
WithIdleOverlay@DISH: WithIdleOverlay@DISH:

View File

@@ -62,6 +62,7 @@ GACTWR:
UpgradeTypes: tower UpgradeTypes: tower
UpgradeMinEnabledLevel: 1 UpgradeMinEnabledLevel: 1
CanPowerDown: CanPowerDown:
IndicatorPalette: mouse
WithTurret@VULC: WithTurret@VULC:
UpgradeTypes: tower.vulcan UpgradeTypes: tower.vulcan
UpgradeMinEnabledLevel: 1 UpgradeMinEnabledLevel: 1

View File

@@ -211,6 +211,7 @@ NARADR:
Type: Wood Type: Wood
RequiresPower: RequiresPower:
CanPowerDown: CanPowerDown:
IndicatorPalette: mouse
ProvidesRadar: ProvidesRadar:
InfiltrateForExploration: InfiltrateForExploration:
DetectCloaked: DetectCloaked:
@@ -285,6 +286,7 @@ NASTLH:
Amount: -350 Amount: -350
RequiresPower: RequiresPower:
CanPowerDown: CanPowerDown:
IndicatorPalette: mouse
UpgradeActorsNear: UpgradeActorsNear:
Upgrades: cloakgenerator Upgrades: cloakgenerator
Range: 12c0 Range: 12c0

View File

@@ -273,6 +273,7 @@ NAMISL:
Power: Power:
Amount: -50 Amount: -50
CanPowerDown: CanPowerDown:
IndicatorPalette: mouse
RequiresPower: RequiresPower:
DisabledOverlay: DisabledOverlay:
SupportPowerChargeBar: SupportPowerChargeBar:

View File

@@ -10,6 +10,9 @@ World:
BuildingInfluence: BuildingInfluence:
ProductionQueueFromSelection: ProductionQueueFromSelection:
ProductionPaletteWidget: PRODUCTION_PALETTE ProductionPaletteWidget: PRODUCTION_PALETTE
PaletteFromFile@mouse:
Name: mouse
Filename: mousepal.pal
PaletteFromFile@playersno: PaletteFromFile@playersno:
Name: player Name: player
Tileset: SNOW Tileset: SNOW