From 0527c883b9e0409d47e27916510e3597d6e708d8 Mon Sep 17 00:00:00 2001 From: ScottNZ Date: Fri, 29 Nov 2013 22:56:24 +1300 Subject: [PATCH] Move DeployTransform logic into its own method, and remove its CancelActivity call so it works properly when queued --- OpenRA.Mods.RA/Transforms.cs | 42 +++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/OpenRA.Mods.RA/Transforms.cs b/OpenRA.Mods.RA/Transforms.cs index 229db3eea4..2cc411ae33 100644 --- a/OpenRA.Mods.RA/Transforms.cs +++ b/OpenRA.Mods.RA/Transforms.cs @@ -68,29 +68,31 @@ namespace OpenRA.Mods.RA return null; } + public void DeployTransform() + { + var b = self.TraitOrDefault(); + + if (!CanDeploy() || (b != null && !b.Lock())) + { + foreach (var s in Info.NoTransformSounds) + Sound.PlayToPlayer(self.Owner, s); + return; + } + + if (self.HasTrait()) + self.QueueActivity(new Turn(Info.Facing)); + + var rb = self.TraitOrDefault(); + if (rb != null && self.Info.Traits.Get().HasMakeAnimation) + self.QueueActivity(new MakeAnimation(self, true, () => rb.PlayCustomAnim(self, "make"))); + + self.QueueActivity(new Transform(self, Info.IntoActor) { Offset = (CVec)Info.Offset, Facing = Info.Facing, Sounds = Info.TransformSounds }); + } + public void ResolveOrder( Actor self, Order order ) { if (order.OrderString == "DeployTransform") - { - var b = self.TraitOrDefault(); - - if (!CanDeploy() || (b != null && !b.Lock())) - { - foreach (var s in Info.NoTransformSounds) - Sound.PlayToPlayer(self.Owner, s); - return; - } - self.CancelActivity(); - - if (self.HasTrait()) - self.QueueActivity(new Turn(Info.Facing)); - - var rb = self.TraitOrDefault(); - if (rb != null && self.Info.Traits.Get().HasMakeAnimation) - self.QueueActivity(new MakeAnimation(self, true, () => rb.PlayCustomAnim(self, "make"))); - - self.QueueActivity(new Transform(self, Info.IntoActor) { Offset = (CVec)Info.Offset, Facing = Info.Facing, Sounds = Info.TransformSounds }); - } + DeployTransform(); } } }