removed UnitCategory. removed the last unit-based use of Categories (Categories is still used for weapons)

This commit is contained in:
Bob
2010-01-14 14:30:51 +13:00
parent 73f6d5c71c
commit 8aae1ff7d5
7 changed files with 21 additions and 32 deletions

View File

@@ -21,9 +21,6 @@ namespace OpenRa.Game.GameRules
if( mergedNode.TryGetValue( "Category", out categoryNode ) )
Category = categoryNode.Value;
if( Rules.UnitCategory.ContainsKey( name ) && Category != Rules.UnitCategory[ name ] )
throw new NotImplementedException( "wrong category");
foreach( var t in mergedNode )
if( t.Key != "Inherits" && t.Key != "Category" )
Traits.Add( LoadTraitInfo( t.Key, t.Value ) );

View File

@@ -12,7 +12,6 @@ namespace OpenRa.Game
{
public static IniFile AllRules;
public static Dictionary<string, List<string>> Categories = new Dictionary<string, List<string>>();
public static Dictionary<string, string> UnitCategory;
public static InfoLoader<WeaponInfo> WeaponInfo;
public static InfoLoader<WarheadInfo> WarheadInfo;
public static InfoLoader<ProjectileInfo> ProjectileInfo;
@@ -54,14 +53,6 @@ namespace OpenRa.Game
if (useAftermath)
FieldLoader.Load(Aftermath, AllRules.GetSection("Aftermath"));
LoadCategories(
"Building",
"Infantry",
"Vehicle",
"Ship",
"Plane");
UnitCategory = Categories.SelectMany(x => x.Value.Select(y => new KeyValuePair<string, string>(y, x.Key))).ToDictionary(x => x.Key, x => x.Value);
LoadCategories(
"Weapon",
"Warhead",

View File

@@ -46,7 +46,7 @@ namespace OpenRa.Game.GameRules
if( playerBuildings[ p ].Count == 0 )
return false;
if( producesIndex[ Rules.UnitCategory[ info.Name ] ].All( x => playerBuildings[ x.Name ].Count == 0 ) )
if( producesIndex[ info.Category ].All( x => playerBuildings[ x.Name ].Count == 0 ) )
return false;
return true;
@@ -64,7 +64,7 @@ namespace OpenRa.Game.GameRules
{
return Rules.NewUnitInfo.Values
.Where( x => x.Name[ 0 ] != '^' )
.Where( x => categories.Contains( Rules.UnitCategory[ x.Name ] ) )
.Where( x => categories.Contains( x.Category ) )
.Where( x => x.Traits.Contains<BuildableInfo>() );
}
@@ -74,7 +74,7 @@ namespace OpenRa.Game.GameRules
if( builtAt.Length != 0 )
return builtAt.Select( x => Rules.NewUnitInfo[ x.ToLowerInvariant() ] );
else
return producesIndex[ Rules.UnitCategory[ info.Name ] ];
return producesIndex[ info.Category ];
}
}
}