diff --git a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs index 24338ef1f3..7b3fec2658 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs @@ -52,13 +52,13 @@ namespace OpenRA.Mods.Common.Traits [Desc("Sound to play when undeploying.")] public readonly string UndeploySound = null; - public object Create(ActorInitializer init) { return new DeployToUpgrade(init.Self, this); } + public object Create(ActorInitializer init) { return new DeployToUpgrade(init, this); } } + public enum DeployState { Undeployed, Deploying, Deployed, Undeploying } + public class DeployToUpgrade : IResolveOrder, IIssueOrder, INotifyCreated { - enum DeployState { Undeployed, Deploying, Deployed } - readonly Actor self; readonly DeployToUpgradeInfo info; readonly UpgradeManager manager; @@ -68,19 +68,44 @@ namespace OpenRA.Mods.Common.Traits DeployState deployState; - public DeployToUpgrade(Actor self, DeployToUpgradeInfo info) + public DeployToUpgrade(ActorInitializer init, DeployToUpgradeInfo info) { - this.self = self; + this.self = init.Self; this.info = info; manager = self.Trait(); checkTerrainType = info.AllowedTerrainTypes.Count > 0; canTurn = self.Info.HasTraitInfo(); body = Exts.Lazy(self.TraitOrDefault); + if (init.Contains()) + deployState = init.Get(); } public void Created(Actor self) { - OnUndeployCompleted(); + switch (deployState) + { + case DeployState.Undeployed: + OnUndeployCompleted(); + break; + case DeployState.Deploying: + if (canTurn) + self.Trait().Facing = info.Facing; + + Deploy(true); + break; + case DeployState.Deployed: + if (canTurn) + self.Trait().Facing = info.Facing; + + OnDeployCompleted(); + break; + case DeployState.Undeploying: + if (canTurn) + self.Trait().Facing = info.Facing; + + Undeploy(true); + break; + } } public IEnumerable Orders @@ -99,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits public void ResolveOrder(Actor self, Order order) { - if (order.OrderString != "DeployToUpgrade" || deployState == DeployState.Deploying) + if (order.OrderString != "DeployToUpgrade" || deployState == DeployState.Deploying || deployState == DeployState.Undeploying) return; if (!order.Queued) @@ -157,10 +182,11 @@ namespace OpenRA.Mods.Common.Traits } /// Play deploy sound and animation. - void Deploy() + void Deploy() { Deploy(false); } + void Deploy(bool init) { // Something went wrong, most likely due to deploy order spam and the fact that this is a delayed action. - if (deployState != DeployState.Undeployed) + if (!init && deployState != DeployState.Undeployed) return; if (!IsOnValidTerrain()) @@ -170,7 +196,8 @@ namespace OpenRA.Mods.Common.Traits Game.Sound.Play(info.DeploySound, self.CenterPosition); // Revoke upgrades that are used while undeployed. - OnDeployStarted(); + if (!init) + OnDeployStarted(); // If there is no animation to play just grant the upgrades that are used while deployed. // Alternatively, play the deploy animation and then grant the upgrades. @@ -181,16 +208,18 @@ namespace OpenRA.Mods.Common.Traits } /// Play undeploy sound and animation and after that revoke the upgrades. - void Undeploy() + void Undeploy() { Undeploy(false); } + void Undeploy(bool init) { // Something went wrong, most likely due to deploy order spam and the fact that this is a delayed action. - if (deployState != DeployState.Deployed) + if (!init && deployState != DeployState.Deployed) return; if (!string.IsNullOrEmpty(info.UndeploySound)) Game.Sound.Play(info.UndeploySound, self.CenterPosition); - OnUndeployStarted(); + if (!init) + OnUndeployStarted(); // If there is no animation to play just grant the upgrades that are used while undeployed. // Alternatively, play the undeploy animation and then grant the upgrades. @@ -232,4 +261,13 @@ namespace OpenRA.Mods.Common.Traits deployState = DeployState.Undeployed; } } + + public class DeployStateInit : IActorInit + { + [FieldFromYamlKey] + readonly DeployState value = DeployState.Deployed; + public DeployStateInit() { } + public DeployStateInit(DeployState init) { value = init; } + public DeployState Value(World world) { return value; } + } } diff --git a/mods/ts/rules/shared-support.yaml b/mods/ts/rules/shared-support.yaml index 2b53aa6031..e8b5ccc468 100644 --- a/mods/ts/rules/shared-support.yaml +++ b/mods/ts/rules/shared-support.yaml @@ -1,29 +1,3 @@ -GADPSA: - Inherits: ^DeployedVehicle - Valued: - Cost: 950 - Tooltip: - Name: Deployed Sensor Array - Health: - HP: 600 - Armor: - Type: Wood - RevealsShroud: - Range: 8c0 - Transforms: - IntoActor: lpst - Facing: 159 - TransformSounds: place2.aud - NoTransformSounds: - Voice: Move - -AutoTarget: - -DrawLineToTarget: - -AttackTurreted: - -RenderRangeCircle: - RenderDetectionCircle: - DetectCloaked: - Range: 6c0 - NAPULS: Inherits: ^Defense Valued: diff --git a/mods/ts/rules/shared-vehicles.yaml b/mods/ts/rules/shared-vehicles.yaml index a57d58bd26..d1fe767309 100644 --- a/mods/ts/rules/shared-vehicles.yaml +++ b/mods/ts/rules/shared-vehicles.yaml @@ -139,7 +139,6 @@ LPST: UpgradeTypes: undeployed UpgradeMinEnabledLevel: 1 WithSpriteBody@deployed: - StartSequence: make UpgradeTypes: undeployed UpgradeMaxEnabledLevel: 0 DisableOnUpgrade: diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml index 69e215633c..6c223e7515 100644 --- a/mods/ts/sequences/structures.yaml +++ b/mods/ts/sequences/structures.yaml @@ -573,19 +573,6 @@ gaicbm: Length: 30 ShadowStart: 30 -gadpsa: - Defaults: - Offset: 0, -12 - UseTilesetCode: true - idle: - ShadowStart: 3 - damaged-idle: - Start: 1 - ShadowStart: 4 - make: gadpsamk - Length: 36 - ShadowStart: 36 - gaarty: Defaults: Offset: 0, -12