diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs index 0acd2cc278..924a7692c8 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithSpriteTurret.cs @@ -25,9 +25,6 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "turret"; - [Desc("Sequence name to use when prepared to fire")] - [SequenceReference] public readonly string AimSequence = null; - [Desc("Turreted 'Turret' key to display")] public readonly string Turret = "primary"; @@ -62,10 +59,9 @@ namespace OpenRA.Mods.Common.Traits.Render } } - public class WithSpriteTurret : ConditionalTrait, INotifyBuildComplete, INotifySold, INotifyTransform, ITick, INotifyDamageStateChanged + public class WithSpriteTurret : ConditionalTrait, INotifyBuildComplete, INotifySold, INotifyTransform, INotifyDamageStateChanged { public readonly Animation DefaultAnimation; - protected readonly AttackBase Attack; readonly RenderSprites rs; readonly BodyOrientation body; readonly Turreted t; @@ -79,7 +75,6 @@ namespace OpenRA.Mods.Common.Traits.Render { rs = self.Trait(); body = self.Trait(); - Attack = self.TraitOrDefault(); t = self.TraitsImplementing() .First(tt => tt.Name == info.Turret); arms = self.TraitsImplementing() @@ -119,26 +114,11 @@ namespace OpenRA.Mods.Common.Traits.Render DefaultAnimation.ReplaceAnim(NormalizeSequence(self, DefaultAnimation.CurrentSequence.Name)); } - protected virtual void Tick(Actor self) - { - if (Info.AimSequence == null) - return; - - var sequence = Attack.IsAiming ? Info.AimSequence : Info.Sequence; - DefaultAnimation.ReplaceAnim(sequence); - } - void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e) { DamageStateChanged(self); } - void ITick.Tick(Actor self) - { - // Split into a protected method to allow subclassing - Tick(self); - } - public void PlayCustomAnimation(Actor self, string name, Action after = null) { DefaultAnimation.PlayThen(NormalizeSequence(self, name), () => diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 2b5decb0b4..541304be4a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1756,6 +1756,24 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Removed AimSequence from WithSpriteTurret, use WithTurretAimAnimation instead + if (engineVersion < 20180224) + { + var spriteTurret = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("WithSpriteTurret", StringComparison.Ordinal)); + if (spriteTurret != null) + { + var aimSequence = spriteTurret.Value.Nodes.FirstOrDefault(n => n.Key == "AimSequence"); + if (aimSequence != null) + { + var aimAnim = new MiniYamlNode("WithTurretAimAnimation", ""); + RenameNodeKey(aimSequence, "Sequence"); + aimAnim.Value.Nodes.Add(aimSequence); + spriteTurret.Value.Nodes.Remove(aimSequence); + node.Value.Nodes.Add(aimAnim); + } + } + } + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } diff --git a/mods/cnc/rules/vehicles.yaml b/mods/cnc/rules/vehicles.yaml index 577a7827e3..92d4e9faea 100644 --- a/mods/cnc/rules/vehicles.yaml +++ b/mods/cnc/rules/vehicles.yaml @@ -496,15 +496,17 @@ MSAM: Weapon: 227mm LocalOffset: 213,128,0, 213,-128,0 Armament@SECONDARY: + Name: secondary Weapon: 227mm LocalOffset: 213,-128,0, 213,128,0 AttackFrontal: WithSpriteTurret: - AimSequence: aim SpawnActorOnDeath: Actor: MSAM.Husk OwnerType: InternalName EffectiveOwnerFromOwner: true + WithTurretAimAnimation: + Sequence: aim MLRS: Inherits: ^Tank