Merge pull request #5401 from RoosterDragon/nodesdict
Changed MiniYaml.NodesDict property into a method.
This commit is contained in:
@@ -68,10 +68,9 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
static object LoadList<T>(MiniYaml y, string field)
|
||||
{
|
||||
return y.NodesDict.ContainsKey(field)
|
||||
? y.NodesDict[field].NodesDict.ToDictionary(
|
||||
a => a.Key,
|
||||
a => FieldLoader.GetValue<T>(field, a.Value.Value))
|
||||
var nd = y.ToDictionary();
|
||||
return nd.ContainsKey(field)
|
||||
? nd[field].ToDictionary(my => FieldLoader.GetValue<T>(field, my.Value))
|
||||
: new Dictionary<string, T>();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,12 @@ namespace OpenRA.Mods.RA.Move
|
||||
static object LoadSpeeds(MiniYaml y)
|
||||
{
|
||||
Dictionary<string, TerrainInfo> ret = new Dictionary<string, TerrainInfo>();
|
||||
foreach (var t in y.NodesDict["TerrainSpeeds"].Nodes)
|
||||
foreach (var t in y.ToDictionary()["TerrainSpeeds"].Nodes)
|
||||
{
|
||||
var speed = FieldLoader.GetValue<decimal>("speed", t.Value.Value);
|
||||
var cost = t.Value.NodesDict.ContainsKey("PathingCost")
|
||||
? FieldLoader.GetValue<int>("cost", t.Value.NodesDict["PathingCost"].Value)
|
||||
var nodesDict = t.Value.ToDictionary();
|
||||
var cost = nodesDict.ContainsKey("PathingCost")
|
||||
? FieldLoader.GetValue<int>("cost", nodesDict["PathingCost"].Value)
|
||||
: (int)(10000 / speed);
|
||||
ret.Add(t.Key, new TerrainInfo { Speed = speed, Cost = cost });
|
||||
}
|
||||
|
||||
@@ -193,12 +193,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
static IEnumerable<NewsItem> ReadNews(byte[] bytes)
|
||||
{
|
||||
var str = Encoding.UTF8.GetString(bytes);
|
||||
return MiniYaml.FromString(str).Select(node => new NewsItem
|
||||
|
||||
return MiniYaml.FromString(str).Select(node =>
|
||||
{
|
||||
Title = node.Value.NodesDict["Title"].Value,
|
||||
Author = node.Value.NodesDict["Author"].Value,
|
||||
DateTime = FieldLoader.GetValue<DateTime>("DateTime", node.Key),
|
||||
Content = node.Value.NodesDict["Content"].Value
|
||||
var nodesDict = node.Value.ToDictionary();
|
||||
return new NewsItem
|
||||
{
|
||||
Title = nodesDict["Title"].Value,
|
||||
Author = nodesDict["Author"].Value,
|
||||
DateTime = FieldLoader.GetValue<DateTime>("DateTime", node.Key),
|
||||
Content = nodesDict["Content"].Value
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
description = widget.Get<LabelWidget>("MISSION_DESCRIPTION");
|
||||
descriptionFont = Game.Renderer.Fonts[description.Font];
|
||||
|
||||
var yaml = new MiniYaml(null, Game.modData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal)).NodesDict;
|
||||
var yaml = new MiniYaml(null, Game.modData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal)).ToDictionary();
|
||||
|
||||
var missionMapPaths = yaml["Missions"].Nodes.Select(n => Path.GetFullPath(n.Key));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user