Overhaul WithDecoration trait.

This commit is contained in:
Paul Chote
2015-12-13 15:29:08 +00:00
parent cec2c584e6
commit 372bbaf7b6
17 changed files with 133 additions and 165 deletions

View File

@@ -14,6 +14,7 @@ using System.Drawing;
using System.Globalization;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.UtilityCommands
{
@@ -2702,6 +2703,44 @@ namespace OpenRA.Mods.Common.UtilityCommands
node.Value.Nodes.Add(new MiniYamlNode("ParticleSize", "1, 1"));
}
// Overhauled the actor decorations traits
if (engineVersion < 20151226)
{
if (depth == 1 && (node.Key.StartsWith("WithDecoration") || node.Key.StartsWith("WithRankDecoration")))
{
node.Value.Nodes.RemoveAll(n => n.Key == "Scale");
node.Value.Nodes.RemoveAll(n => n.Key == "Offset");
var sd = node.Value.Nodes.FirstOrDefault(n => n.Key == "SelectionDecoration");
if (sd != null)
sd.Key = "RequiresSelection";
var reference = node.Value.Nodes.FirstOrDefault(n => n.Key == "ReferencePoint");
if (reference != null)
{
var values = FieldLoader.GetValue<string[]>("ReferencePoint", reference.Value.Value);
values = values.Where(v => v != "HCenter" && v != "VCenter").ToArray();
if (values.Length == 0)
values = new[] { "Center" };
reference.Value.Value = FieldSaver.FormatValue(values);
}
var stance = Stance.Ally;
var showToAllies = node.Value.Nodes.FirstOrDefault(n => n.Key == "ShowToAllies");
if (showToAllies != null && !FieldLoader.GetValue<bool>("ShowToAllies", showToAllies.Value.Value))
stance ^= Stance.Ally;
var showToEnemies = node.Value.Nodes.FirstOrDefault(n => n.Key == "ShowToEnemies");
if (showToEnemies != null && FieldLoader.GetValue<bool>("ShowToEnemies", showToEnemies.Value.Value))
stance |= Stance.Enemy;
if (stance != Stance.Ally)
node.Value.Nodes.Add(new MiniYamlNode("Stance", FieldSaver.FormatValue(stance)));
node.Value.Nodes.RemoveAll(n => n.Key == "ShowToAllies");
node.Value.Nodes.RemoveAll(n => n.Key == "ShowToEnemies");
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}