From 536f5f05a88f992f154887532a72f2904775e90a Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Sun, 30 Sep 2018 11:16:20 +0300 Subject: [PATCH] Make WithBuildingPlacedAnimation conditional --- .../Traits/Render/WithBuildingPlacedAnimation.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs index f8593e488c..771a830229 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits.Render { [Desc("Changes the animation when the actor constructed a building.")] - public class WithBuildingPlacedAnimationInfo : ITraitInfo, Requires + public class WithBuildingPlacedAnimationInfo : ConditionalTraitInfo, Requires { [Desc("Sequence name to use"), SequenceReference] public readonly string Sequence = "build"; @@ -23,18 +23,17 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Which sprite body to play the animation on.")] public readonly string Body = "body"; - public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.Self, this); } + public override object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.Self, this); } } - public class WithBuildingPlacedAnimation : INotifyBuildingPlaced, INotifyBuildComplete, INotifySold, INotifyTransform + public class WithBuildingPlacedAnimation : ConditionalTrait, INotifyBuildingPlaced, INotifyBuildComplete, INotifySold, INotifyTransform { - readonly WithBuildingPlacedAnimationInfo info; readonly WithSpriteBody wsb; bool buildComplete; public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info) + : base(info) { - this.info = info; wsb = self.TraitsImplementing().Single(w => w.Info.Name == info.Body); buildComplete = !self.Info.HasTraitInfo(); } @@ -60,8 +59,8 @@ namespace OpenRA.Mods.Common.Traits.Render void INotifyBuildingPlaced.BuildingPlaced(Actor self) { - if (buildComplete) - wsb.PlayCustomAnimation(self, info.Sequence); + if (!IsTraitDisabled && buildComplete) + wsb.PlayCustomAnimation(self, Info.Sequence); } } } \ No newline at end of file