diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index b363c85d5e..63e1d1e8d8 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -72,7 +72,6 @@ - diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index c335b2d834..1b6be932f6 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -388,6 +388,7 @@ + diff --git a/OpenRA.Mods.Cnc/Traits/RenderUnitFlying.cs b/OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs similarity index 55% rename from OpenRA.Mods.Cnc/Traits/RenderUnitFlying.cs rename to OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs index a7ea686b2b..67b391ef23 100644 --- a/OpenRA.Mods.Cnc/Traits/RenderUnitFlying.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithMoveAnimation.cs @@ -8,47 +8,47 @@ */ #endregion -using OpenRA.Mods.Common.Traits; +using System.Linq; using OpenRA.Traits; -namespace OpenRA.Mods.Cnc.Traits +namespace OpenRA.Mods.Common.Traits { - class RenderUnitFlyingInfo : RenderUnitInfo, Requires + public class WithMoveAnimationInfo : ITraitInfo, Requires, Requires { + [Desc("Displayed while moving.")] public readonly string MoveSequence = "move"; - public override object Create(ActorInitializer init) { return new RenderUnitFlying(init, this); } + public object Create(ActorInitializer init) { return new WithMoveAnimation(init, this); } } - class RenderUnitFlying : RenderUnit, ITick + public class WithMoveAnimation : ITick { - readonly RenderUnitFlyingInfo info; + readonly WithMoveAnimationInfo info; readonly IMove movement; + readonly WithFacingSpriteBody wfsb; WPos cachedPosition; - public RenderUnitFlying(ActorInitializer init, RenderUnitFlyingInfo info) - : base(init, info) + public WithMoveAnimation(ActorInitializer init, WithMoveAnimationInfo info) { this.info = info; movement = init.Self.Trait(); + wfsb = init.Self.Trait(); cachedPosition = init.Self.CenterPosition; } - public override void Tick(Actor self) + public void Tick(Actor self) { - base.Tick(self); - var oldCachedPosition = cachedPosition; cachedPosition = self.CenterPosition; // Flying units set IsMoving whenever they are airborne, which isn't enough for our purposes var isMoving = movement.IsMoving && !self.IsDead && (oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0; - if (isMoving ^ (DefaultAnimation.CurrentSequence.Name != info.MoveSequence)) + if (isMoving ^ (wfsb.DefaultAnimation.CurrentSequence.Name != info.MoveSequence)) return; - DefaultAnimation.ReplaceAnim(isMoving ? info.MoveSequence : info.Sequence); + wfsb.DefaultAnimation.ReplaceAnim(isMoving ? info.MoveSequence : wfsb.Info.Sequence); } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 9d0d30114c..09ffe25d62 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1066,6 +1066,23 @@ namespace OpenRA.Mods.Common.UtilityCommands if (rrur != null) rrur.Key = "-WithFacingSpriteBody"; } + + // For RenderUnitFlying + var ruf = node.Value.Nodes.Where(x => x.Key == "RenderUnitFlying"); + if (ruf.Any()) + { + ruf.Do(x => x.Key = "RenderSprites"); + node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", "")); + node.Value.Nodes.Add(new MiniYamlNode("WithFacingSpriteBody", "")); + node.Value.Nodes.Add(new MiniYamlNode("WithMoveAnimation", "", new List + { + new MiniYamlNode("MoveSequence", "move") + })); + + var rruf = node.Value.Nodes.FirstOrDefault(n => n.Key == "-RenderUnitFlying"); + if (rruf != null) + rruf.Key = "-WithFacingSpriteBody"; + } } UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); diff --git a/mods/cnc/rules/aircraft.yaml b/mods/cnc/rules/aircraft.yaml index ffae216000..4ab0ba9de4 100644 --- a/mods/cnc/rules/aircraft.yaml +++ b/mods/cnc/rules/aircraft.yaml @@ -129,13 +129,16 @@ ORCA: SelfReloads: true ReloadCount: 2 SelfReloadTicks: 100 - RenderUnitFlying: + RenderSprites: LeavesHusk: HuskActor: ORCA.Husk AutoTarget: Explodes: Weapon: HeliExplode EmptyWeapon: HeliExplode + AutoSelectionSize: + WithMoveAnimation: + MoveSequence: move C17: ParaDrop: