Use HashSets for AI
This commit is contained in:
@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.AI
|
||||
|
||||
ActorInfo GetProducibleBuilding(string commonName, IEnumerable<ActorInfo> buildables, Func<ActorInfo, int> orderBy = null)
|
||||
{
|
||||
string[] actors;
|
||||
HashSet<string> actors;
|
||||
if (!ai.Info.BuildingCommonNames.TryGetValue(commonName, out actors))
|
||||
throw new InvalidOperationException("Can't find {0} in the HackyAI BuildingCommonNames definition.".F(commonName));
|
||||
|
||||
|
||||
@@ -123,10 +123,10 @@ namespace OpenRA.Mods.Common.AI
|
||||
public readonly Dictionary<string, float> BuildingFractions = null;
|
||||
|
||||
[Desc("Tells the AI what unit types fall under the same common name.")]
|
||||
public readonly Dictionary<string, string[]> UnitsCommonNames = null;
|
||||
public readonly Dictionary<string, HashSet<string>> UnitsCommonNames = null;
|
||||
|
||||
[Desc("Tells the AI what building types fall under the same common name.")]
|
||||
public readonly Dictionary<string, string[]> BuildingCommonNames = null;
|
||||
public readonly Dictionary<string, HashSet<string>> BuildingCommonNames = null;
|
||||
|
||||
[Desc("What buildings should the AI have a maximum limit to build.")]
|
||||
public readonly Dictionary<string, int> BuildingLimits = null;
|
||||
@@ -378,7 +378,7 @@ namespace OpenRA.Mods.Common.AI
|
||||
return GetInfoByCommonName(Info.UnitsCommonNames, commonName, owner);
|
||||
}
|
||||
|
||||
public ActorInfo GetInfoByCommonName(Dictionary<string, string[]> names, string commonName, Player owner)
|
||||
public ActorInfo GetInfoByCommonName(Dictionary<string, HashSet<string>> names, string commonName, Player owner)
|
||||
{
|
||||
if (!names.Any() || !names.ContainsKey(commonName))
|
||||
throw new InvalidOperationException("Can't find {0} in the HackyAI UnitsCommonNames definition.".F(commonName));
|
||||
|
||||
Reference in New Issue
Block a user