From 7325f0e733d40a53a458f716b0528d921e15237c Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 9 Jul 2016 11:11:31 +0100 Subject: [PATCH] Fix service depot animation breaking sell. --- .../Traits/Render/WithRepairAnimation.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs index d939856479..e6aea22b8a 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithRepairAnimation.cs @@ -24,20 +24,34 @@ namespace OpenRA.Mods.Common.Traits.Render public object Create(ActorInitializer init) { return new WithRepairAnimation(init.Self, this); } } - public class WithRepairAnimation : INotifyRepair + public class WithRepairAnimation : INotifyRepair, INotifyBuildComplete, INotifySold { readonly WithRepairAnimationInfo info; + readonly WithSpriteBody spriteBody; + bool buildComplete; public WithRepairAnimation(Actor self, WithRepairAnimationInfo info) { this.info = info; + spriteBody = self.TraitOrDefault(); } public void Repairing(Actor self, Actor host) { - var spriteBody = host.TraitOrDefault(); - if (spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled())) + if (buildComplete && spriteBody != null && !(info.PauseOnLowPower && self.IsDisabled())) spriteBody.PlayCustomAnimation(host, info.Sequence, () => spriteBody.CancelCustomAnimation(host)); } + + public void BuildingComplete(Actor self) + { + buildComplete = true; + } + + public void Selling(Actor self) + { + buildComplete = false; + } + + public void Sold(Actor self) { } } } \ No newline at end of file