Changed MiniYaml.NodesDict property into a method.
Method is now called ToDictionary. - Cached a few invocations into locals which should prevent some redundant evaluation. - Added ToDictionary overloads that take projection functions for the keys and elements, since several callsites were doing a subsequent Linq.ToDictionary call to get this.
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user