diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index ee96b6545c..c5a35d08db 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -404,7 +404,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/Render/RenderSimple.cs b/OpenRA.Mods.Common/Traits/Render/RenderSimple.cs deleted file mode 100644 index 5bcdd33c73..0000000000 --- a/OpenRA.Mods.Common/Traits/Render/RenderSimple.cs +++ /dev/null @@ -1,73 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2015 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. For more information, - * see COPYING. - */ -#endregion - -using System; -using System.Collections.Generic; -using OpenRA.Graphics; -using OpenRA.Mods.Common.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.Common.Traits -{ - [Desc("Basic render trait for immobile actors. Deprecated, use RenderSprites + WithSpriteBody instead.")] - public class RenderSimpleInfo : RenderSpritesInfo, IRenderActorPreviewSpritesInfo, Requires - { - [SequenceReference] public readonly string Sequence = "idle"; - - public override object Create(ActorInitializer init) { return new RenderSimple(init, this); } - - public virtual IEnumerable RenderPreviewSprites(ActorPreviewInitializer init, RenderSpritesInfo rs, string image, int facings, PaletteReference p) - { - var ifacing = init.Actor.Traits.GetOrDefault(); - var facing = ifacing != null ? init.Contains() ? init.Get() : ifacing.GetInitialFacing() : 0; - - var anim = new Animation(init.World, image, () => facing); - anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence)); - - yield return new SpriteActorPreview(anim, WVec.Zero, 0, p, rs.Scale); - } - } - - public class RenderSimple : RenderSprites, IAutoSelectionSize - { - public readonly Animation DefaultAnimation; - - readonly RenderSimpleInfo info; - - public RenderSimple(ActorInitializer init, RenderSimpleInfo info, Func baseFacing) - : base(init, info) - { - this.info = info; - - DefaultAnimation = new Animation(init.World, GetImage(init.Self), baseFacing); - Add(DefaultAnimation); - } - - public RenderSimple(ActorInitializer init, RenderSimpleInfo info) - : this(init, info, MakeFacingFunc(init.Self)) - { - DefaultAnimation.PlayRepeating(NormalizeSequence(init.Self, info.Sequence)); - } - - public int2 SelectionSize(Actor self) { return AutoSelectionSize(self); } - - public string NormalizeSequence(Actor self, string sequence) - { - return NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence); - } - - public void PlayCustomAnim(Actor self, string name) - { - if (DefaultAnimation.HasSequence(name)) - DefaultAnimation.PlayThen(NormalizeSequence(self, name), - () => DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence))); - } - } -} diff --git a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs index fab7f4f625..2a0d9b7f3e 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs @@ -222,7 +222,7 @@ namespace OpenRA.Mods.Common.Traits return sequence; } - // Required by RenderSimple, WithSpriteBody and WithInfantryBody + // Required by WithSpriteBody and WithInfantryBody public int2 AutoSelectionSize(Actor self) { return anims.Where(b => b.IsVisible diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index b6b42cecfd..51ad3a69e9 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2058,6 +2058,32 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Key = "RotationPaletteEffect"; } + // Replace RenderSimple with RenderSprites + WithSpriteBody + AutoSelectionSize + if (engineVersion < 20150909) + { + if (depth == 0) + { + var rs = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderSimple")); + if (rs != null) + { + rs.Key = "RenderSprites"; + + var wsbNodes = rs.Value.Nodes.Where(n => n.Key == "Sequence").ToList(); + if (wsbNodes.Any()) + node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", new MiniYaml("", wsbNodes))); + else + node.Value.Nodes.Add(new MiniYamlNode("WithSpriteBody", "")); + + node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", "")); + rs.Value.Nodes.RemoveAll(n => wsbNodes.Contains(n)); + } + + var rrs = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderSimple")); + if (rrs != null) + rrs.Key = "-WithSpriteBody"; + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/ra/rules/misc.yaml b/mods/ra/rules/misc.yaml index 2c404a1c98..7ea617fd95 100644 --- a/mods/ra/rules/misc.yaml +++ b/mods/ra/rules/misc.yaml @@ -12,7 +12,9 @@ MINP: NotifyAppliedDamage: false Armor: Type: Light - RenderSimple: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: Cloak: CloakSound: UncloakSound: @@ -43,7 +45,9 @@ MINV: NotifyAppliedDamage: false Armor: Type: Light - RenderSimple: + RenderSprites: + WithSpriteBody: + AutoSelectionSize: Cloak: CloakSound: UncloakSound: