bug #997 -- remove duplication from HackyAIInfo
This commit is contained in:
@@ -43,21 +43,15 @@ namespace OpenRA.Mods.RA
|
|||||||
[FieldLoader.LoadUsing("LoadBuildings")]
|
[FieldLoader.LoadUsing("LoadBuildings")]
|
||||||
public readonly Dictionary<string, float> BuildingFractions = null;
|
public readonly Dictionary<string, float> BuildingFractions = null;
|
||||||
|
|
||||||
static object LoadUnits(MiniYaml y)
|
static object LoadActorList(MiniYaml y, string field)
|
||||||
{
|
{
|
||||||
Dictionary<string, float> ret = new Dictionary<string, float>();
|
return y.NodesDict[field].Nodes.ToDictionary(
|
||||||
foreach (var t in y.NodesDict["UnitsToBuild"].Nodes)
|
t => t.Key,
|
||||||
ret.Add(t.Key, (float)FieldLoader.GetValue("units", typeof(float), t.Value.Value));
|
t => FieldLoader.GetValue<float>(field, t.Value.Value));
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static object LoadBuildings(MiniYaml y)
|
static object LoadUnits(MiniYaml y) { return LoadActorList(y, "UnitsToBuild"); }
|
||||||
{
|
static object LoadBuildings(MiniYaml y) { return LoadActorList(y, "BuildingFractions"); }
|
||||||
Dictionary<string, float> ret = new Dictionary<string, float>();
|
|
||||||
foreach (var t in y.NodesDict["BuildingFractions"].Nodes)
|
|
||||||
ret.Add(t.Key, (float)FieldLoader.GetValue("units", typeof(float), t.Value.Value));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new HackyAI(this); }
|
public object Create(ActorInitializer init) { return new HackyAI(this); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user