diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 59b5f5ecaa..867149f46c 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -450,7 +450,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Render/WithSpriteRotorOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithSpriteRotorOverlay.cs deleted file mode 100644 index 40678b6ecf..0000000000 --- a/OpenRA.Mods.Common/Traits/Render/WithSpriteRotorOverlay.cs +++ /dev/null @@ -1,81 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2016 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 of - * the License, or (at your option) any later version. For more - * information, see COPYING. - */ -#endregion - -using System.Collections.Generic; -using OpenRA.Graphics; -using OpenRA.Mods.Common.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits.Render -{ - [Desc("Displays a helicopter rotor overlay.")] - public class WithSpriteRotorOverlayInfo : ITraitInfo, IRenderActorPreviewSpritesInfo, Requires, Requires - { - [Desc("Sequence name to use when flying")] - [SequenceReference] public readonly string Sequence = "rotor"; - - [Desc("Sequence name to use when landed")] - [SequenceReference] public readonly string GroundSequence = "slow-rotor"; - - [Desc("Position relative to body")] - public readonly WVec Offset = WVec.Zero; - - public object Create(ActorInitializer init) { return new WithSpriteRotorOverlay(init.Self, this); } - - public IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) - { - var body = init.Actor.TraitInfo(); - var facing = init.Contains() ? init.Get() : 0; - var anim = new Animation(init.World, image, () => facing); - anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); - - var orientation = body.QuantizeOrientation(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing)), facings); - var offset = body.LocalToWorld(Offset.Rotate(orientation)); - yield return new SpriteActorPreview(anim, offset, offset.Y + offset.Z + 1, p, rs.Scale); - } - } - - public class WithSpriteRotorOverlay : ITick - { - readonly WithSpriteRotorOverlayInfo info; - readonly Animation rotorAnim; - readonly IMove movement; - - public WithSpriteRotorOverlay(Actor self, WithSpriteRotorOverlayInfo info) - { - this.info = info; - var rs = self.Trait(); - var body = self.Trait(); - movement = self.Trait(); - - rotorAnim = new Animation(self.World, rs.GetImage(self)); - rotorAnim.PlayRepeating(info.Sequence); - rs.Add(new AnimationWithOffset(rotorAnim, - () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))), - null, p => ZOffsetFromCenter(self, p, 1))); - } - - public void Tick(Actor self) - { - var isFlying = movement.IsMoving && !self.IsDead; - if (isFlying ^ (rotorAnim.CurrentSequence.Name != info.Sequence)) - return; - - rotorAnim.ReplaceAnim(isFlying ? info.Sequence : info.GroundSequence); - } - - public static int ZOffsetFromCenter(Actor self, WPos pos, int offset) - { - var delta = self.CenterPosition - pos; - return delta.Y + delta.Z + offset; - } - } -} diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index da302ea48c..98878fcba7 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -130,6 +130,22 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Value.Nodes.Add(new MiniYamlNode("Id", id)); } + if (engineVersion < 20160611) + { + // Deprecated WithSpriteRotorOverlay + if (depth == 1 && node.Key.StartsWith("WithSpriteRotorOverlay")) + { + var parts = node.Key.Split('@'); + node.Key = "WithIdleOverlay"; + if (parts.Length > 1) + node.Key += "@" + parts[1]; + + Console.WriteLine("The 'WithSpriteRotorOverlay' trait has been removed."); + Console.WriteLine("Its functionality can be fully replicated with 'WithIdleOverlay' + upgrades."); + Console.WriteLine("Look at the helicopters in our RA / C&C1 mods for implementation details."); + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/cnc/rules/aircraft.yaml b/mods/cnc/rules/aircraft.yaml index d21c628fe9..e1a5cacaf5 100644 --- a/mods/cnc/rules/aircraft.yaml +++ b/mods/cnc/rules/aircraft.yaml @@ -23,12 +23,26 @@ TRAN: RevealsShroud: Range: 10c0 Type: CenterPosition - WithSpriteRotorOverlay@PRIMARY: + WithIdleOverlay@ROTOR1AIR: + Offset: 597,0,85 + Sequence: rotor + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTOR1GROUND: + Offset: 597,0,85 + Sequence: slow-rotor + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 + WithIdleOverlay@ROTOR2AIR: Offset: -597,0,171 Sequence: rotor2 - GroundSequence: slow-rotor2 - WithSpriteRotorOverlay@SECONDARY: - Offset: 597,0,85 + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTOR2GROUND: + Offset: -597,0,171 + Sequence: slow-rotor2 + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 Cargo: Types: Infantry MaxWeight: 10 @@ -81,8 +95,16 @@ HELI: SelfReloads: true ReloadCount: 10 SelfReloadDelay: 200 - WithSpriteRotorOverlay: + WithIdleOverlay@ROTORAIR: Offset: 0,0,85 + Sequence: rotor + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTORGROUND: + Offset: 0,0,85 + Sequence: slow-rotor + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 WithMuzzleOverlay: SpawnActorOnDeath: Actor: HELI.Husk @@ -227,10 +249,12 @@ TRAN.Husk: RevealsShroud: Range: 8c0 Type: CenterPosition - WithSpriteRotorOverlay@PRIMARY: - Offset: -597,0,171 - WithSpriteRotorOverlay@SECONDARY: + WithIdleOverlay@ROTOR1: Offset: 597,0,85 + Sequence: rotor + WithIdleOverlay@ROTOR2: + Offset: -597,0,171 + Sequence: rotor2 RenderSprites: Image: tran @@ -244,8 +268,9 @@ HELI.Husk: RevealsShroud: Range: 10c0 Type: CenterPosition - WithSpriteRotorOverlay: + WithIdleOverlay: Offset: 0,0,85 + Sequence: rotor RenderSprites: Image: heli diff --git a/mods/ra/rules/aircraft.yaml b/mods/ra/rules/aircraft.yaml index 76e028a199..c70f48f4e4 100644 --- a/mods/ra/rules/aircraft.yaml +++ b/mods/ra/rules/aircraft.yaml @@ -212,12 +212,26 @@ TRAN: Speed: 112 LandableTerrainTypes: Clear,Rough,Road,Ore,Beach,Gems AltitudeVelocity: 0c100 - WithSpriteRotorOverlay@PRIMARY: + WithIdleOverlay@ROTOR1AIR: + Offset: 597,0,213 + Sequence: rotor + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTOR1GROUND: + Offset: 597,0,213 + Sequence: slow-rotor + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 + WithIdleOverlay@ROTOR2AIR: Offset: -597,0,341 Sequence: rotor2 - GroundSequence: slow-rotor2 - WithSpriteRotorOverlay@SECONDARY: - Offset: 597,0,213 + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTOR2GROUND: + Offset: -597,0,341 + Sequence: slow-rotor2 + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 Cargo: Types: Infantry MaxWeight: 8 @@ -262,8 +276,16 @@ HELI: AutoTarget: InitialStance: HoldFire InitialStanceAI: HoldFire - WithSpriteRotorOverlay: + WithIdleOverlay@ROTORAIR: Offset: 0,0,85 + Sequence: rotor + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTORGROUND: + Offset: 0,0,85 + Sequence: slow-rotor + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 AmmoPool: Ammo: 8 SelectionDecorations: @@ -313,7 +335,14 @@ HIND: AutoTarget: InitialStance: HoldFire InitialStanceAI: HoldFire - WithSpriteRotorOverlay: + WithIdleOverlay@ROTORAIR: + Sequence: rotor + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTORGROUND: + Sequence: slow-rotor + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 AmmoPool: Ammo: 24 PipCount: 6 diff --git a/mods/ra/rules/husks.yaml b/mods/ra/rules/husks.yaml index 79f532afa3..66161255eb 100644 --- a/mods/ra/rules/husks.yaml +++ b/mods/ra/rules/husks.yaml @@ -88,10 +88,12 @@ TRAN.Husk: Aircraft: TurnSpeed: 4 Speed: 149 - WithSpriteRotorOverlay@PRIMARY: + WithIdleOverlay@PRIMARY: Offset: -597,0,341 - WithSpriteRotorOverlay@SECONDARY: + Sequence: rotor + WithIdleOverlay@SECONDARY: Offset: 597,0,213 + Sequence: rotor2 RevealsShroud: Range: 12c0 Type: CenterPosition @@ -177,8 +179,9 @@ HELI.Husk: Aircraft: TurnSpeed: 4 Speed: 149 - WithSpriteRotorOverlay: + WithIdleOverlay: Offset: 0,0,85 + Sequence: rotor SmokeTrailWhenDamaged: Offset: -427,0,0 MinDamage: Undamaged @@ -195,7 +198,8 @@ HIND.Husk: Aircraft: TurnSpeed: 4 Speed: 112 - WithSpriteRotorOverlay: + WithIdleOverlay: + Sequence: rotor SmokeTrailWhenDamaged: Offset: -427,0,0 MinDamage: Undamaged diff --git a/mods/ts/rules/aircraft.yaml b/mods/ts/rules/aircraft.yaml index 739f50166a..5a1eafd1e1 100644 --- a/mods/ts/rules/aircraft.yaml +++ b/mods/ts/rules/aircraft.yaml @@ -307,8 +307,16 @@ APACHE: PipType: Ammo PipTypeEmpty: AmmoEmpty AutoTarget: - WithSpriteRotorOverlay: + WithIdleOverlay@ROTORAIR: Offset: 85,0,384 + Sequence: rotor + UpgradeTypes: airborne + UpgradeMinEnabledLevel: 1 + WithIdleOverlay@ROTORGROUND: + Offset: 85,0,384 + Sequence: slow-rotor + UpgradeTypes: airborne + UpgradeMaxEnabledLevel: 0 RenderSprites: SpawnActorOnDeath: Actor: APACHE.Husk diff --git a/mods/ts/rules/husks.yaml b/mods/ts/rules/husks.yaml index 01357b6648..4b31fbfa3a 100644 --- a/mods/ts/rules/husks.yaml +++ b/mods/ts/rules/husks.yaml @@ -77,8 +77,9 @@ APACHE.Husk: Aircraft: TurnSpeed: 5 Speed: 130 - WithSpriteRotorOverlay: + WithIdleOverlay: Offset: 85,0,384 + Sequence: rotor RenderSprites: Image: apache RenderVoxels: