Add a HasChild helper command
This commit is contained in:
committed by
Gustas Kažukauskas
parent
a2a7b30727
commit
58088ecabe
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
harvesters[actorNode.Key] = harvesterNode.ChildrenMatching("DeliveryBuildings", includeRemovals: false)
|
||||
.FirstOrDefault()?.NodeValue<HashSet<string>>() ?? [];
|
||||
|
||||
if (actorNode.ChildrenMatching("Refinery", includeRemovals: false).Any())
|
||||
if (actorNode.HasChild("Refinery"))
|
||||
refineries.Add(actorNode.Key.ToLowerInvariant());
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
foreach (var actor in resolvedActors)
|
||||
foreach (var cloak in actor.ChildrenMatching("Cloak"))
|
||||
if (cloak.LastChildMatching("Palette", false) == null)
|
||||
if (cloak.HasChild("Palette"))
|
||||
actorsWithDefault.Add((actor.Key, cloak.Key));
|
||||
|
||||
yield break;
|
||||
|
||||
@@ -471,6 +471,13 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
return node.Value.Nodes.Where(n => n.KeyMatches(match, ignoreSuffix, includeRemovals));
|
||||
}
|
||||
|
||||
/// <summary>Returns true if node exists and is not being removed.</summary>
|
||||
public static bool HasChild(
|
||||
this MiniYamlNodeBuilder node, string match, bool ignoreSuffix = true)
|
||||
{
|
||||
return ChildrenMatching(node, match, ignoreSuffix).LastOrDefault()?.IsRemoval() == false;
|
||||
}
|
||||
|
||||
/// <summary>Returns children whose keys contain 'match' (optionally in the suffix).</summary>
|
||||
public static IEnumerable<MiniYamlNodeBuilder> ChildrenContaining(
|
||||
this MiniYamlNodeBuilder node, string match, bool ignoreSuffix = true, bool includeRemovals = true)
|
||||
|
||||
Reference in New Issue
Block a user