Restore support for inline map rules.

This commit is contained in:
Paul Chote
2016-03-09 19:16:42 +00:00
parent 2d98e41f11
commit 20e8bc249d
11 changed files with 119 additions and 94 deletions

View File

@@ -13,6 +13,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OpenRA.FileSystem;
namespace OpenRA
{
@@ -375,6 +376,21 @@ namespace OpenRA
foreach (var line in Nodes.ToLines(false))
yield return "\t" + line;
}
public static List<MiniYamlNode> Load(IReadOnlyFileSystem fileSystem, IEnumerable<string> files, MiniYaml mapRules)
{
if (mapRules != null && mapRules.Value != null)
{
var mapFiles = FieldLoader.GetValue<string[]>("value", mapRules.Value);
files = files.Append(mapFiles);
}
var yaml = files.Select(s => MiniYaml.FromStream(fileSystem.Open(s)));
if (mapRules != null && mapRules.Nodes.Any())
yaml = yaml.Append(mapRules.Nodes);
return MiniYaml.Merge(yaml);
}
}
[Serializable]