removed UnitCategory. removed the last unit-based use of Categories (Categories is still used for weapons)
This commit is contained in:
@@ -110,12 +110,12 @@ namespace OpenRa.Game
|
||||
optionsBottomRight = SpriteSheetBuilder.LoadAllSprites("dd-crnr")[3];
|
||||
optionsBackground = SpriteSheetBuilder.LoadAllSprites("dd-bkgnd")[Game.CosmeticRandom.Next(4)];
|
||||
|
||||
tabSprites = groups
|
||||
.SelectMany(g => Rules.Categories[g])
|
||||
.Where(u => Rules.NewUnitInfo[u].Traits.Contains<BuildableInfo>())
|
||||
tabSprites = Rules.NewUnitInfo.Values
|
||||
.Where(x => groups.Contains(x.Category))
|
||||
.Where(u => u.Traits.Contains<BuildableInfo>())
|
||||
.ToDictionary(
|
||||
u => u,
|
||||
u => SpriteSheetBuilder.LoadAllSprites(Rules.NewUnitInfo[u].Traits.Get<BuildableInfo>().Icon ?? (u + "icon"))[0]);
|
||||
u => u.Name,
|
||||
u => SpriteSheetBuilder.LoadAllSprites(u.Traits.Get<BuildableInfo>().Icon ?? (u.Name + "icon"))[0]);
|
||||
|
||||
spsprites = Rules.SupportPowerInfo
|
||||
.ToDictionary(
|
||||
@@ -644,7 +644,7 @@ namespace OpenRa.Game
|
||||
|
||||
void StartProduction( string item )
|
||||
{
|
||||
var group = Rules.UnitCategory[item];
|
||||
var group = Rules.NewUnitInfo[item].Category;
|
||||
Sound.Play((group == "Building") ? "abldgin1.aud" : "train1.aud");
|
||||
Game.controller.AddOrder(Order.StartProduction(Game.LocalPlayer, item));
|
||||
}
|
||||
@@ -652,7 +652,7 @@ namespace OpenRa.Game
|
||||
void HandleBuildPalette(string item, bool isLmb)
|
||||
{
|
||||
var player = Game.LocalPlayer;
|
||||
var group = Rules.UnitCategory[item];
|
||||
var group = Rules.NewUnitInfo[item].Category;
|
||||
var queue = player.PlayerActor.traits.Get<Traits.ProductionQueue>();
|
||||
var producing = queue.AllItems(group).FirstOrDefault( a => a.Item == item );
|
||||
|
||||
|
||||
@@ -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 ) );
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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 ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRa.Game.Orders
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.UnitCategory[ Building ] );
|
||||
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.NewUnitInfo[ Building ].Category );
|
||||
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
@@ -16,18 +16,19 @@ namespace OpenRa.Game.Orders
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
var queue = order.Player.PlayerActor.traits.Get<ProductionQueue>();
|
||||
var producing = queue.CurrentItem(Rules.UnitCategory[order.TargetString]);
|
||||
var unit = Rules.NewUnitInfo[ order.TargetString ];
|
||||
var producing = queue.CurrentItem(unit.Category);
|
||||
if( producing == null || producing.Item != order.TargetString || producing.RemainingTime != 0 )
|
||||
return;
|
||||
|
||||
Game.world.Add( new Actor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( Rules.NewUnitInfo[ order.TargetString ].Traits.Get<BuildingInfo>() ), order.Player ) );
|
||||
Game.world.Add( new Actor( order.TargetString, order.TargetLocation - Footprint.AdjustForBuildingSize( unit.Traits.Get<BuildingInfo>() ), order.Player ) );
|
||||
if (order.Player == Game.LocalPlayer)
|
||||
{
|
||||
Sound.Play("placbldg.aud");
|
||||
Sound.Play("build5.aud");
|
||||
}
|
||||
|
||||
queue.FinishProduction(Rules.UnitCategory[order.TargetString]);
|
||||
queue.FinishProduction(unit.Category);
|
||||
} );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
case "StartProduction":
|
||||
{
|
||||
string group = Rules.UnitCategory[ order.TargetString ];
|
||||
string group = Rules.NewUnitInfo[ order.TargetString ].Category;
|
||||
var ui = Rules.NewUnitInfo[ order.TargetString ].Traits.Get<BuildableInfo>();
|
||||
var time = ui.Cost
|
||||
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||
@@ -65,7 +65,7 @@ namespace OpenRa.Game.Traits
|
||||
}
|
||||
case "PauseProduction":
|
||||
{
|
||||
var producing = CurrentItem( Rules.UnitCategory[ order.TargetString ] );
|
||||
var producing = CurrentItem( Rules.NewUnitInfo[ order.TargetString ].Category );
|
||||
if( producing != null && producing.Item == order.TargetString )
|
||||
producing.Paused = ( order.TargetLocation.X != 0 );
|
||||
break;
|
||||
@@ -95,7 +95,7 @@ namespace OpenRa.Game.Traits
|
||||
|
||||
public void CancelProduction( string itemName )
|
||||
{
|
||||
var category = Rules.UnitCategory[itemName];
|
||||
var category = Rules.NewUnitInfo[itemName].Category;
|
||||
var queue = production[ category ];
|
||||
if (queue.Count == 0) return;
|
||||
|
||||
@@ -160,12 +160,12 @@ namespace OpenRa.Game.Traits
|
||||
// Something went wrong somewhere...
|
||||
if( producer == null )
|
||||
{
|
||||
CancelProduction( Rules.UnitCategory[ name ] );
|
||||
CancelProduction( newUnitType.Category );
|
||||
return;
|
||||
}
|
||||
|
||||
if( producer.traits.WithInterface<IProducer>().Any( p => p.Produce( producer, newUnitType ) ) )
|
||||
FinishProduction( Rules.UnitCategory[ name ] );
|
||||
FinishProduction( newUnitType.Category );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user