From faf2634e3d3ff1a7abaa17fb89abe8b957d58331 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 21 Oct 2017 14:05:47 +0000 Subject: [PATCH] Upgrade mod rules. --- .../UtilityCommands/UpgradeRules.cs | 50 +++++++++++++++++++ mods/cnc/rules/defaults.yaml | 4 +- mods/ra/maps/allies-03a/rules.yaml | 2 +- mods/ra/maps/allies-03b/rules.yaml | 2 +- mods/ra/maps/infiltration/rules.yaml | 2 +- mods/ra/maps/intervention/rules.yaml | 6 +-- mods/ra/rules/defaults.yaml | 6 +-- mods/ts/rules/defaults.yaml | 2 +- 8 files changed, 61 insertions(+), 13 deletions(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 534135985d..02d87f948a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -15,6 +15,7 @@ using System.IO; using System.Linq; using System.Text; using OpenRA.FileSystem; +using OpenRA.Traits; namespace OpenRA.Mods.Common.UtilityCommands { @@ -1003,6 +1004,55 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + if (engineVersion < 20171021) + { + if (node.Key.StartsWith("Capturable", StringComparison.Ordinal) || node.Key.StartsWith("ExternalCapturable", StringComparison.Ordinal)) + { + // Type renamed to Types + var type = node.Value.Nodes.FirstOrDefault(n => n.Key == "Type"); + if (type != null) + RenameNodeKey(type, "Types"); + + // Allow(Allies|Neutral|Enemies) replaced with a ValidStances enum + var stance = Stance.Neutral | Stance.Enemy; + var allowAllies = node.Value.Nodes.FirstOrDefault(n => n.Key == "AllowAllies"); + if (allowAllies != null) + { + if (FieldLoader.GetValue("AllowAllies", allowAllies.Value.Value)) + stance |= Stance.Ally; + else + stance &= ~Stance.Ally; + + node.Value.Nodes.Remove(allowAllies); + } + + var allowNeutral = node.Value.Nodes.FirstOrDefault(n => n.Key == "AllowNeutral"); + if (allowNeutral != null) + { + if (FieldLoader.GetValue("AllowNeutral", allowNeutral.Value.Value)) + stance |= Stance.Neutral; + else + stance &= ~Stance.Neutral; + + node.Value.Nodes.Remove(allowNeutral); + } + + var allowEnemies = node.Value.Nodes.FirstOrDefault(n => n.Key == "AllowEnemies"); + if (allowEnemies != null) + { + if (FieldLoader.GetValue("AllowEnemies", allowEnemies.Value.Value)) + stance |= Stance.Enemy; + else + stance &= ~Stance.Enemy; + + node.Value.Nodes.Remove(allowEnemies); + } + + if (stance != (Stance.Neutral | Stance.Enemy)) + node.Value.Nodes.Add(new MiniYamlNode("ValidStances", stance.ToString())); + } + } + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 1706de231d..4622a15e62 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -940,9 +940,9 @@ RequiresForceFire: yes TargetTypes: Ground, Husk Capturable: - Type: husk - AllowAllies: yes + Types: husk CaptureThreshold: 100 + ValidStances: Enemy, Neutral, Ally TransformOnCapture: ForceHealthPercentage: 25 Tooltip: diff --git a/mods/ra/maps/allies-03a/rules.yaml b/mods/ra/maps/allies-03a/rules.yaml index 68228ffcc2..4c6f6c6ec4 100644 --- a/mods/ra/maps/allies-03a/rules.yaml +++ b/mods/ra/maps/allies-03a/rules.yaml @@ -20,7 +20,7 @@ World: ^TechBuilding: Capturable: - Type: ~disabled + Types: ~disabled powerproxy.paratroopers: ParatroopersPower: diff --git a/mods/ra/maps/allies-03b/rules.yaml b/mods/ra/maps/allies-03b/rules.yaml index 485c28fa76..357f5ac7af 100644 --- a/mods/ra/maps/allies-03b/rules.yaml +++ b/mods/ra/maps/allies-03b/rules.yaml @@ -20,7 +20,7 @@ World: ^TechBuilding: Capturable: - Type: ~disabled + Types: ~disabled powerproxy.paratroopers: ParatroopersPower: diff --git a/mods/ra/maps/infiltration/rules.yaml b/mods/ra/maps/infiltration/rules.yaml index b46f7e67d7..2bf693e254 100644 --- a/mods/ra/maps/infiltration/rules.yaml +++ b/mods/ra/maps/infiltration/rules.yaml @@ -81,7 +81,7 @@ TRUK.Hijackable: TargetTypes: Ground, Repair, Vehicle, NoAutoTarget -Huntable: ExternalCapturable: - Type: MissionObjective + Types: MissionObjective CaptureCompleteTime: 1 -DeliversCash: RenderSprites: diff --git a/mods/ra/maps/intervention/rules.yaml b/mods/ra/maps/intervention/rules.yaml index 5cc41c6ca6..0a6d9233a2 100644 --- a/mods/ra/maps/intervention/rules.yaml +++ b/mods/ra/maps/intervention/rules.yaml @@ -23,11 +23,9 @@ MISS: Tooltip: Name: Soviet Air Force HQ Capturable: - Type: building - AllowAllies: False - AllowNeutral: False - AllowEnemies: True + Types: building CaptureThreshold: 100 + ValidStances: Enemy E6.MOD: Inherits: E6 diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index f75c7eae3d..d75045dde3 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -248,7 +248,7 @@ Tooltip: GenericName: Vehicle Capturable: - Type: vehicle + Types: vehicle CaptureThreshold: 100 CancelActivity: True CaptureNotification: @@ -893,9 +893,9 @@ Burns: Damage: 2 Capturable: - Type: husk - AllowAllies: true + Types: husk CaptureThreshold: 100 + ValidStances: Enemy, Neutral, Ally TransformOnCapture: ForceHealthPercentage: 25 WithColoredOverlay@IDISABLE: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index aa69d48deb..a750fe45f6 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -725,7 +725,7 @@ HiddenUnderFog: ActorLostNotification: Capturable: - Type: Vehicle + Types: Vehicle CaptureThreshold: 100 CancelActivity: True Guard: