Added WithHarvestAnimation + WithDockingAnimation

Removed RenderHarvester.
This commit is contained in:
reaperrr
2015-06-23 20:17:08 +02:00
parent de72db83db
commit 76aaafe37c
13 changed files with 221 additions and 107 deletions

View File

@@ -1268,6 +1268,55 @@ namespace OpenRA.Mods.Common.UtilityCommands
if (rrlc != null)
rrlc.Key = "-WithLandingCraftAnimation";
}
// Replaced RenderHarvester with WithFacingSpriteBody + WithHarvestAnimation + WithDockingAnimation.
// 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 childKeyIBF = new[] { "ImagesByFullness" };
var childKeysExcludeFromRS = new[] { "Sequence", "ImagesByFullness", "HarvestSequence" };
var rh = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("RenderHarvester"));
if (rh != null)
{
rh.Key = "WithHarvestAnimation";
var rsNodes = rh.Value.Nodes.Where(n => !childKeysExcludeFromRS.Contains(n.Key)).ToList();
var wfsbNodes = rh.Value.Nodes.Where(n => childKeySequence.Contains(n.Key)).ToList();
var ibfNode = rh.Value.Nodes.Where(n => childKeyIBF.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", ""));
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", ""));
node.Value.Nodes.Add(new MiniYamlNode("WithDockingAnimation", ""));
rh.Value.Nodes.RemoveAll(n => rsNodes.Contains(n));
rh.Value.Nodes.RemoveAll(n => wfsbNodes.Contains(n));
if (ibfNode.Any())
rh.Value.Nodes.RemoveAll(n => ibfNode.Contains(n));
Console.WriteLine("The 'ImagesByFullness' property from the removed RenderHarvester trait has been");
Console.WriteLine("replaced with a 'PrefixByFullness' property on the new WithHarvestAnimation trait.");
Console.WriteLine("This cannot be reliably upgraded, as the actor sequences need to be adapted as well.");
Console.WriteLine("Therefore, WithHarvestAnimation will use the default (no prefix) after upgrading.");
Console.WriteLine("See RA's harvester for reference on how to re-implement this feature using the new trait.");
}
var rrh = node.Value.Nodes.FirstOrDefault(n => n.Key.StartsWith("-RenderHarvester"));
if (rrh != null)
rrh.Key = "-WithHarvestAnimation";
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);