From 700b11712201fe3d79d936035c6f636c50fb89a7 Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Thu, 16 Mar 2017 17:29:45 -0500 Subject: [PATCH] Convert WithRepairAnimation from disable to conditional. --- .../Traits/Render/WithRepairAnimation.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs index 5805878016..f9de5e9e49 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs @@ -14,32 +14,29 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits.Render { [Desc("Replaces the building animation when it repairs a unit.")] - public class WithRepairAnimationInfo : ITraitInfo, Requires + public class WithRepairAnimationInfo : ConditionalTraitInfo, Requires { [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "active"; - public readonly bool PauseOnLowPower = false; - - public object Create(ActorInitializer init) { return new WithRepairAnimation(init.Self, this); } + public override object Create(ActorInitializer init) { return new WithRepairAnimation(init.Self, this); } } - public class WithRepairAnimation : INotifyRepair, INotifyBuildComplete, INotifySold + public class WithRepairAnimation : ConditionalTrait, INotifyRepair, INotifyBuildComplete, INotifySold { - readonly WithRepairAnimationInfo info; readonly WithSpriteBody spriteBody; bool buildComplete; public WithRepairAnimation(Actor self, WithRepairAnimationInfo info) + : base(info) { - this.info = info; spriteBody = self.TraitOrDefault(); } void INotifyRepair.Repairing(Actor self, Actor target) { - if (buildComplete && spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled())) - spriteBody.PlayCustomAnimation(self, info.Sequence, () => spriteBody.CancelCustomAnimation(self)); + if (buildComplete && spriteBody != null && !IsTraitDisabled) + spriteBody.PlayCustomAnimation(self, Info.Sequence, () => spriteBody.CancelCustomAnimation(self)); } void INotifyBuildComplete.BuildingComplete(Actor self)