diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs
index 89d4a01988..26456975ab 100644
--- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs
+++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs
@@ -1227,6 +1227,47 @@ namespace OpenRA.Mods.Common.UtilityCommands
// Renamed WithHarvestAnimation to WithHarvestOverlay
if (node.Key == "WithHarvestAnimation")
node.Key = "WithHarvestOverlay";
+
+ // Replaced RenderLandingCraft with WithFacingSpriteBody + WithLandingCraftAnimation.
+ // Note: These rules are set up to do approximately the right thing for maps, but
+ // mods might need additional manual tweaks. This is the best we can do without having
+ // much smarter rules parsing, because we currently can't reason about inherited traits.
+ if (depth == 0)
+ {
+ var childKeySequence = new[] { "Sequence" };
+ var childKeysExcludeFromRS = new[] { "Sequence", "OpenTerrainTypes", "OpenSequence", "UnloadSequence" };
+
+ var rlc = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderLandingCraft"));
+ if (rlc != null)
+ {
+ rlc.Key = "WithLandingCraftAnimation";
+
+ var rsNodes = rlc.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList();
+ var wfsbNodes = rlc.Value.Nodes.Where(n => childKeySequence.Contains(n.Key)).ToList();
+
+ if (rsNodes.Any())
+ node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", new MiniYaml("", rsNodes)));
+ else
+ node.Value.Nodes.Add(new MiniYamlNode("RenderSprites", ""));
+
+ // Note: For the RA landing craft WithSpriteBody would be sufficient since it has no facings,
+ // but WithFacingSpriteBody works as well and covers the potential case where a third-party mod
+ // might have given their landing craft multiple facings.
+ if (wfsbNodes.Any())
+ node.Value.Nodes.Add(new MiniYamlNode("WithFacingSpriteBody", new MiniYaml("", wfsbNodes)));
+ else
+ node.Value.Nodes.Add(new MiniYamlNode("WithFacingSpriteBody", ""));
+
+ node.Value.Nodes.Add(new MiniYamlNode("AutoSelectionSize", ""));
+
+ rlc.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
+ rlc.Value.Nodes.RemoveAll(n => wfsbNodes.Contains(n));
+ }
+
+ var rrlc = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderLandingCraft"));
+ if (rrlc != null)
+ rrlc.Key = "-WithLandingCraftAnimation";
+ }
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 74e023c30b..4f91d64281 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -104,7 +104,7 @@
-
+
diff --git a/OpenRA.Mods.RA/Traits/Render/RenderLandingCraft.cs b/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs
similarity index 52%
rename from OpenRA.Mods.RA/Traits/Render/RenderLandingCraft.cs
rename to OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs
index 27ed41eef2..740434f0f0 100644
--- a/OpenRA.Mods.RA/Traits/Render/RenderLandingCraft.cs
+++ b/OpenRA.Mods.RA/Traits/Render/WithLandingCraftAnimation.cs
@@ -14,30 +14,31 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
{
- public class RenderLandingCraftInfo : RenderUnitInfo, Requires, Requires
+ public class WithLandingCraftAnimationInfo : ITraitInfo, Requires, Requires, Requires
{
public readonly string[] OpenTerrainTypes = { "Clear" };
- [SequenceReference] public readonly string OpenAnim = "open";
- [SequenceReference] public readonly string UnloadAnim = "unload";
+ [SequenceReference] public readonly string OpenSequence = "open";
+ [SequenceReference] public readonly string UnloadSequence = "unload";
- public override object Create(ActorInitializer init) { return new RenderLandingCraft(init, this); }
+ public object Create(ActorInitializer init) { return new WithLandingCraftAnimation(init, this); }
}
- public class RenderLandingCraft : RenderUnit
+ public class WithLandingCraftAnimation : ITick
{
- readonly RenderLandingCraftInfo info;
+ readonly WithLandingCraftAnimationInfo info;
readonly Actor self;
readonly Cargo cargo;
readonly IMove move;
+ readonly WithSpriteBody wsb;
bool open;
- public RenderLandingCraft(ActorInitializer init, RenderLandingCraftInfo info)
- : base(init, info)
+ public WithLandingCraftAnimation(ActorInitializer init, WithLandingCraftAnimationInfo info)
{
this.info = info;
self = init.Self;
cargo = self.Trait();
move = self.Trait();
+ wsb = init.Self.Trait();
}
public bool ShouldBeOpen()
@@ -51,34 +52,32 @@ namespace OpenRA.Mods.RA.Traits
void Open()
{
- if (open || !DefaultAnimation.HasSequence(info.OpenAnim))
+ if (open || !wsb.DefaultAnimation.HasSequence(info.OpenSequence))
return;
open = true;
- PlayCustomAnimation(self, info.OpenAnim, () =>
+ wsb.PlayCustomAnimation(self, info.OpenSequence, () =>
{
- if (DefaultAnimation.HasSequence(info.UnloadAnim))
- PlayCustomAnimationRepeating(self, info.UnloadAnim);
+ if (wsb.DefaultAnimation.HasSequence(info.UnloadSequence))
+ wsb.PlayCustomAnimationRepeating(self, info.UnloadSequence);
});
}
void Close()
{
- if (!open || !DefaultAnimation.HasSequence(info.OpenAnim))
+ if (!open || !wsb.DefaultAnimation.HasSequence(info.OpenSequence))
return;
open = false;
- PlayCustomAnimationBackwards(self, info.OpenAnim, null);
+ wsb.PlayCustomAnimationBackwards(self, info.OpenSequence, null);
}
- public override void Tick(Actor self)
+ public void Tick(Actor self)
{
if (ShouldBeOpen())
Open();
else
Close();
-
- base.Tick(self);
}
}
}
diff --git a/mods/ra/maps/allies-05a/map.yaml b/mods/ra/maps/allies-05a/map.yaml
index aca6603176..e5ae9d780d 100644
--- a/mods/ra/maps/allies-05a/map.yaml
+++ b/mods/ra/maps/allies-05a/map.yaml
@@ -1658,7 +1658,7 @@ Rules:
ShowOwnerRow: false
LST.IN:
Inherits: LST
- RenderLandingCraft:
+ RenderSprites:
Image: LST
Cargo:
Types: disabled
diff --git a/mods/ra/rules/ships.yaml b/mods/ra/rules/ships.yaml
index 3508758e6e..88a30d1686 100644
--- a/mods/ra/rules/ships.yaml
+++ b/mods/ra/rules/ships.yaml
@@ -218,10 +218,7 @@ LST:
Range: 6c0
SelectionDecorations:
VisualBounds: 36,36
- -AutoSelectionSize:
- -RenderSprites:
- -WithFacingSpriteBody:
- RenderLandingCraft:
+ WithLandingCraftAnimation:
OpenTerrainTypes: Clear, Rough, Road, Ore, Gems, Beach
Cargo:
Types: Infantry, Vehicle