From 0d0d2e0ae30f1603274e23d0a9bc1efb4e70f237 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 17 May 2018 09:18:14 +0200 Subject: [PATCH] Play WithAcceptDeliveredCashAnimation only on the assigned WithSpriteBody --- .../Render/WithAcceptDeliveredCashAnimation.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithAcceptDeliveredCashAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithAcceptDeliveredCashAnimation.cs index 05aaa1130a..a61f45a264 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithAcceptDeliveredCashAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithAcceptDeliveredCashAnimation.cs @@ -20,19 +20,22 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "active"; + [Desc("Which sprite body to play the animation on.")] + public readonly string Body = "body"; + public object Create(ActorInitializer init) { return new WithAcceptDeliveredCashAnimation(init.Self, this); } } public class WithAcceptDeliveredCashAnimation : INotifyCashTransfer, INotifyBuildComplete, INotifySold { readonly WithAcceptDeliveredCashAnimationInfo info; - readonly WithSpriteBody[] wsbs; + readonly WithSpriteBody wsb; bool buildComplete; public WithAcceptDeliveredCashAnimation(Actor self, WithAcceptDeliveredCashAnimationInfo info) { this.info = info; - wsbs = self.TraitsImplementing().ToArray(); + wsb = self.TraitsImplementing().Single(w => w.Info.Name == info.Body); } void INotifyBuildComplete.BuildingComplete(Actor self) @@ -53,11 +56,8 @@ namespace OpenRA.Mods.Common.Traits.Render if (!buildComplete || playing) return; - foreach (var wsb in wsbs) - { - playing = true; - wsb.PlayCustomAnimation(self, info.Sequence, () => playing = false); - } + playing = true; + wsb.PlayCustomAnimation(self, info.Sequence, () => playing = false); } void INotifyCashTransfer.OnDeliveringCash(Actor self, Actor acceptor) { }