From 64a2b9de552ccd9291c9f8d99fa30520ff2a79d4 Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Thu, 16 Mar 2017 13:40:31 -0500 Subject: [PATCH] WithRepairOverlay into pausable-conditional trait EMP disabled polish. --- .../Traits/Render/WithRepairOverlay.cs | 14 ++++++-------- mods/ts/rules/gdi-structures.yaml | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs index a5dcb11902..a09d6061de 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairOverlay.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits.Render { [Desc("Displays an overlay when the building is being repaired by the player.")] - public class WithRepairOverlayInfo : ITraitInfo, Requires, Requires + public class WithRepairOverlayInfo : PausableConditionalTraitInfo, Requires, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "active"; @@ -30,30 +30,28 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Custom palette is a player palette BaseName")] public readonly bool IsPlayerPalette = false; - public readonly bool PauseOnLowPower = false; - - public object Create(ActorInitializer init) { return new WithRepairOverlay(init.Self, this); } + public override object Create(ActorInitializer init) { return new WithRepairOverlay(init.Self, this); } } - public class WithRepairOverlay : INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyRepair + public class WithRepairOverlay : PausableConditionalTrait, INotifyDamageStateChanged, INotifyBuildComplete, INotifySold, INotifyRepair { readonly Animation overlay; bool buildComplete; bool visible; public WithRepairOverlay(Actor self, WithRepairOverlayInfo info) + : base(info) { var rs = self.Trait(); var body = self.Trait(); buildComplete = !self.Info.HasTraitInfo(); // always render instantly for units - overlay = new Animation(self.World, rs.GetImage(self), - () => info.PauseOnLowPower && self.IsDisabled()); + overlay = new Animation(self.World, rs.GetImage(self), () => IsTraitPaused); overlay.PlayThen(info.Sequence, () => visible = false); var anim = new AnimationWithOffset(overlay, () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), - () => !visible || !buildComplete, + () => IsTraitDisabled || !visible || !buildComplete, p => RenderUtils.ZOffsetFromCenter(self, p, 1)); rs.Add(anim, info.Palette, info.IsPlayerPalette); diff --git a/mods/ts/rules/gdi-structures.yaml b/mods/ts/rules/gdi-structures.yaml index 5186956da9..56364b12f8 100644 --- a/mods/ts/rules/gdi-structures.yaml +++ b/mods/ts/rules/gdi-structures.yaml @@ -271,8 +271,10 @@ GADEPT: WithIdleOverlay@CIRCUITS: Sequence: circuits WithRepairOverlay@CRANE: + PauseOnCondition: empdisable Sequence: crane WithRepairOverlay@PLATFORM: + RequiresCondition: !empdisable Sequence: platform WithDeathAnimation@BIB: DeathSequence: dead-ground