Merge pull request #5401 from RoosterDragon/nodesdict

Changed MiniYaml.NodesDict property into a method.
This commit is contained in:
Paul Chote
2014-06-12 17:34:59 +12:00
21 changed files with 104 additions and 74 deletions

View File

@@ -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 });
}