From 21f9547fed70a6327aad8f0ae38389cde3122e40 Mon Sep 17 00:00:00 2001 From: Pavel Penev Date: Fri, 21 Aug 2015 16:46:05 +0300 Subject: [PATCH] Add facing to DeployToUpgrade Make the actor turn to a desired facing before starting to deploy (and before granting the upgrade). --- OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs index 7c047661b9..7aa3c1e42e 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; using System.Linq; using OpenRA.Activities; +using OpenRA.Mods.Common.Activities; using OpenRA.Mods.Common.Orders; using OpenRA.Traits; @@ -36,6 +37,9 @@ namespace OpenRA.Mods.Common.Traits [SequenceReference, Desc("Animation to play for deploying/undeploying.")] public readonly string DeployAnimation = null; + [Desc("Facing that the actor must face before deploying. Set to -1 to deploy regardless of facing.")] + public readonly int Facing = -1; + public object Create(ActorInitializer init) { return new DeployToUpgrade(init.Self, this); } } @@ -45,6 +49,7 @@ namespace OpenRA.Mods.Common.Traits readonly DeployToUpgradeInfo info; readonly UpgradeManager manager; readonly bool checkTerrainType; + readonly bool canTurn; readonly Lazy body; bool isUpgraded; @@ -55,6 +60,7 @@ namespace OpenRA.Mods.Common.Traits this.info = info; manager = self.Trait(); checkTerrainType = info.AllowedTerrainTypes.Length > 0; + canTurn = self.Info.Traits.WithInterface().Any(); body = Exts.Lazy(self.TraitOrDefault); } @@ -101,6 +107,10 @@ namespace OpenRA.Mods.Common.Traits { self.CancelActivity(); + // Turn + if (info.Facing != -1 && canTurn) + self.QueueActivity(new Turn(self, info.Facing)); + // Grant the upgrade self.QueueActivity(new CallFunc(GrantUpgrades));