From a9339d91ea0c902927d4d2e2ad4c7a8f7c7c643c Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Sat, 6 Jun 2015 14:53:57 +0200 Subject: [PATCH] Fix WithBuildingPlacedAnimation interrupting WithMakeAnimation The bug happens when a second (or third, fourth etc.) Conyard deploys while a building is placed from the first Conyard. The `WithMakeAnimation` running on the second CY uses `Animation::PlayThen` to call `Building::Unlock` in a delegate. `WithBuildingPlacedAnimation::BuildingPlaced` runs when a building placed and replaces the delegate from `WithMakeAnimation` with its own before it has a chance to run, and so the new Conyard never gets unlocked. The fix is then to simply not run `BuildingPlaced` on conyards that haven't completed the make animation yet. --- .../Traits/Render/WithBuildingPlacedAnimation.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs index ef4cabf9c2..feac110c32 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithBuildingPlacedAnimation.cs @@ -21,20 +21,28 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.Self, this); } } - public class WithBuildingPlacedAnimation : INotifyBuildingPlaced + public class WithBuildingPlacedAnimation : INotifyBuildingPlaced, INotifyBuildComplete { WithBuildingPlacedAnimationInfo info; RenderSimple renderSimple; + bool buildComplete; public WithBuildingPlacedAnimation(Actor self, WithBuildingPlacedAnimationInfo info) { this.info = info; renderSimple = self.Trait(); + buildComplete = !self.HasTrait(); + } + + public void BuildingComplete(Actor self) + { + buildComplete = true; } public void BuildingPlaced(Actor self) { - renderSimple.PlayCustomAnim(self, info.Sequence); + if (buildComplete) + renderSimple.PlayCustomAnim(self, info.Sequence); } } } \ No newline at end of file