Rules.Categories
This commit is contained in:
@@ -10,6 +10,7 @@ namespace OpenRa.Game
|
||||
static class Rules
|
||||
{
|
||||
public static IniFile AllRules;
|
||||
public static Dictionary<string, List<String>> Categories;
|
||||
public static InfoLoader<UnitInfo> UnitInfo;
|
||||
public static InfoLoader<WeaponInfo> WeaponInfo;
|
||||
public static InfoLoader<WarheadInfo> WarheadInfo;
|
||||
@@ -23,6 +24,16 @@ namespace OpenRa.Game
|
||||
FileSystem.Open( "units.ini" ),
|
||||
FileSystem.Open( "campaignUnits.ini" ) );
|
||||
|
||||
Categories = LoadCategories(
|
||||
"BuildingTypes",
|
||||
"InfantryTypes",
|
||||
"VehicleTypes",
|
||||
"ShipTypes",
|
||||
"PlaneTypes",
|
||||
"WeaponTypes",
|
||||
"WarheadTypes",
|
||||
"ProjectileTypes" );
|
||||
|
||||
UnitInfo = new InfoLoader<UnitInfo>(
|
||||
Pair.New<string,Func<string,UnitInfo>>( "BuildingTypes", s => new UnitInfo.BuildingInfo(s)),
|
||||
Pair.New<string,Func<string,UnitInfo>>( "InfantryTypes", s => new UnitInfo.InfantryInfo(s)),
|
||||
@@ -38,5 +49,14 @@ namespace OpenRa.Game
|
||||
ProjectileInfo = new InfoLoader<ProjectileInfo>(
|
||||
Pair.New<string, Func<string, ProjectileInfo>>("ProjectileTypes", _ => new ProjectileInfo()));
|
||||
}
|
||||
|
||||
static Dictionary<string, List<string>> LoadCategories( params string[] types )
|
||||
{
|
||||
var ret = new Dictionary<string, List<string>>();
|
||||
foreach( var t in types )
|
||||
ret[ t ] = AllRules.GetSection( t ).Select( x => x.Key.ToLowerInvariant() ).ToList();
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user