Try to avoid adding duplicate values through upgrade rules
This commit is contained in:
@@ -1907,6 +1907,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
// Introduce QuantizeFacingsFromSequence
|
||||
// This will only do roughly the right thing and probably require the modder to do some manual cleanup
|
||||
if (depth == 0)
|
||||
{
|
||||
// Check if the upgrade rule ran already before
|
||||
var qffs = node.Value.Nodes.FirstOrDefault(n => n.Key == "QuantizeFacingsFromSequence");
|
||||
if (qffs == null)
|
||||
{
|
||||
var inftraits = node.Value.Nodes.FirstOrDefault(n =>
|
||||
n.Key.StartsWith("WithInfantryBody")
|
||||
@@ -1929,6 +1933,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
node.Value.Nodes.Add(new MiniYamlNode("QuantizeFacingsFromSequence", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (engineVersion < 20150920)
|
||||
{
|
||||
@@ -2123,7 +2128,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
// Add `WhileCloakedUpgrades: underwater` to Cloak trait if `CloakTypes: Underwater`
|
||||
var cloak = node.Value.Nodes.FirstOrDefault(n => (n.Key == "Cloak" || n.Key.StartsWith("Cloak@"))
|
||||
&& n.Value.Nodes.Any(p => p.Key == "CloakTypes" && p.Value.Value == "Underwater"));
|
||||
if (cloak != null)
|
||||
if (cloak != null && !cloak.Value.Nodes.Any(n => n.Key == "WhileCloakedUpgrades"))
|
||||
cloak.Value.Nodes.Add(new MiniYamlNode("WhileCloakedUpgrades", "underwater"));
|
||||
|
||||
// Remove split traits if TargetableSubmarine was removed
|
||||
@@ -2213,12 +2218,13 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
// Make Range WDist for all traits with circular ranges.
|
||||
if (engineVersion < 20150920 && depth == 2 && node.Key == "Range")
|
||||
{
|
||||
if (parentKey == "DetectCloaked"
|
||||
if ((parentKey == "DetectCloaked"
|
||||
|| parentKey == "JamsMissiles"
|
||||
|| parentKey == "JamsRadar"
|
||||
|| parentKey == "Guardable"
|
||||
|| parentKey == "BaseProvider"
|
||||
|| parentKey == "ProximityCapturable")
|
||||
&& !node.Value.Value.Contains("c0"))
|
||||
node.Value.Value = node.Value.Value + "c0";
|
||||
}
|
||||
|
||||
@@ -2401,7 +2407,8 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (depth == 1 && node.Key == "AutoTarget")
|
||||
{
|
||||
var stance = node.Value.Nodes.FirstOrDefault(n => n.Key == "InitialStance");
|
||||
if (stance != null)
|
||||
var aiStance = node.Value.Nodes.FirstOrDefault(n => n.Key == "InitialStanceAI");
|
||||
if (stance != null && aiStance == null)
|
||||
node.Value.Nodes.Add(new MiniYamlNode("InitialStanceAI", stance.Value.Value));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user