- Replaces WithSiloAnimation with WithResourceLevelSpriteBody. PlayFetchIndex on a With*Animation trait conflicts with the animation concept, as it's bound to conflict with pretty much all 'normal' animation traits and blocks progress on the animation priority system. We also already have multiple similar SpriteBody traits, like WithGateSpriteBody and WithWallSpriteBody. - Rename WithResources to WithResourceLevelOverlay Make name more accurate and consistent with sprite body equivalent. Also fix TS silo yaml setup (bleed setup stems from times before WithResources was introduced).
77 lines
2.2 KiB
C#
77 lines
2.2 KiB
C#
#region Copyright & License Information
|
|
/*
|
|
* Copyright 2007-2018 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 System.Linq;
|
|
|
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
|
{
|
|
public class RefactorResourceLevelAnimating : UpdateRule
|
|
{
|
|
public override string Name { get { return "Streamlined traits animating player resource level"; } }
|
|
public override string Description
|
|
{
|
|
get
|
|
{
|
|
return "Replaced WithSiloAnimation with WithResourceLevelSpriteBody and\n" +
|
|
"renamed WithResources to WithResourceLevelOverlay.";
|
|
}
|
|
}
|
|
|
|
readonly List<string> locations = new List<string>();
|
|
|
|
public override IEnumerable<string> AfterUpdate(ModData modData)
|
|
{
|
|
if (locations.Any())
|
|
yield return "WithSiloAnimation has been replaced by WithResourceLevelSpriteBody.\n" +
|
|
"You may need to disable/remove any previous (including inherited) *SpriteBody traits\n" +
|
|
"on the following actors:\n" +
|
|
UpdateUtils.FormatMessageList(locations);
|
|
|
|
locations.Clear();
|
|
}
|
|
|
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
|
{
|
|
foreach (var wr in actorNode.ChildrenMatching("WithResources"))
|
|
wr.RenameKey("WithResourceLevelOverlay");
|
|
|
|
var siloAnims = actorNode.ChildrenMatching("WithSiloAnimation");
|
|
foreach (var sa in siloAnims)
|
|
{
|
|
// If it's a trait removal, we only rename it.
|
|
if (sa.IsRemoval())
|
|
{
|
|
sa.RenameKey("WithResourceLevelSpriteBody");
|
|
continue;
|
|
}
|
|
|
|
var sequence = sa.LastChildMatching("Sequence");
|
|
var body = sa.LastChildMatching("Body");
|
|
|
|
if (sequence == null)
|
|
{
|
|
var newSequenceNode = new MiniYamlNode("Sequence", "stages");
|
|
sa.AddNode(newSequenceNode);
|
|
}
|
|
|
|
if (body != null)
|
|
sa.RemoveNode(body);
|
|
|
|
sa.RenameKey("WithResourceLevelSpriteBody");
|
|
locations.Add("{0} ({1})".F(actorNode.Key, sa.Location.Filename));
|
|
}
|
|
|
|
yield break;
|
|
}
|
|
}
|
|
}
|