diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 19d67f2cb9..dc59dfc338 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -47,7 +47,6 @@ namespace OpenRa.Game // Build Palette tabs string currentTab = "Building"; bool paletteOpen = false; - static string[] groups = new string[] { "Building", "Infantry", "Vehicle", "Plane", "Ship" }; readonly Dictionary tabImageNames; readonly Dictionary tabSprites; @@ -111,7 +110,6 @@ namespace OpenRa.Game optionsBackground = SpriteSheetBuilder.LoadAllSprites("dd-bkgnd")[Game.CosmeticRandom.Next(4)]; tabSprites = Rules.NewUnitInfo.Values - .Where(x => groups.Contains(x.Category)) .Where(u => u.Traits.Contains()) .ToDictionary( u => u.Name, @@ -121,6 +119,8 @@ namespace OpenRa.Game .ToDictionary( u => u.Key, u => SpriteSheetBuilder.LoadAllSprites(u.Value.Image)[0]); + + var groups = Rules.NewUnitInfo.Values.Select( x => x.Category ).Distinct().ToList(); tabImageNames = groups.Select( (g, i) => Pair.New(g, @@ -644,27 +644,27 @@ namespace OpenRa.Game void StartProduction( string item ) { - var group = Rules.NewUnitInfo[item].Category; - Sound.Play((group == "Building") ? "abldgin1.aud" : "train1.aud"); + var unit = Rules.NewUnitInfo[item]; + Sound.Play(unit.Traits.Contains() ? "abldgin1.aud" : "train1.aud"); Game.controller.AddOrder(Order.StartProduction(Game.LocalPlayer, item)); } void HandleBuildPalette(string item, bool isLmb) { var player = Game.LocalPlayer; - var group = Rules.NewUnitInfo[item].Category; + var unit = Rules.NewUnitInfo[item]; var queue = player.PlayerActor.traits.Get(); - var producing = queue.AllItems(group).FirstOrDefault( a => a.Item == item ); + var producing = queue.AllItems(unit.Category).FirstOrDefault( a => a.Item == item ); Sound.Play("ramenu1.aud"); if (isLmb) { - if (producing != null && producing == queue.CurrentItem(group)) + if (producing != null && producing == queue.CurrentItem(unit.Category)) { if (producing.Done) { - if (group == "Building") + if (unit.Traits.Contains()) Game.controller.orderGenerator = new PlaceBuildingOrderGenerator(player.PlayerActor, item); return; } diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 5271c9683c..8822a908bc 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -75,6 +75,8 @@ namespace OpenRa.Game if( useAftermath ) yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "aftermath.yaml" ), yamlRules ); + yamlRules = MiniYaml.Merge( MiniYaml.FromFile( "[mod]Separate buildqueue for defense.yaml" ), yamlRules ); + NewUnitInfo = new Dictionary(); foreach( var kv in yamlRules ) NewUnitInfo.Add(kv.Key.ToLowerInvariant(), new NewUnitInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules)); diff --git a/OpenRa.Game/Traits/ProductionQueue.cs b/OpenRa.Game/Traits/ProductionQueue.cs index a213a30154..52da243a5b 100755 --- a/OpenRa.Game/Traits/ProductionQueue.cs +++ b/OpenRa.Game/Traits/ProductionQueue.cs @@ -33,8 +33,8 @@ namespace OpenRa.Game.Traits { case "StartProduction": { - string group = Rules.NewUnitInfo[ order.TargetString ].Category; - var ui = Rules.NewUnitInfo[ order.TargetString ].Traits.Get(); + var unit = Rules.NewUnitInfo[ order.TargetString ]; + var ui = unit.Traits.Get(); var time = ui.Cost * Rules.General.BuildSpeed /* todo: country-specific build speed bonus */ * ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */ @@ -42,17 +42,17 @@ namespace OpenRa.Game.Traits time = .08f * time; /* temporary hax so we can build stuff fast for test */ - if( !Rules.TechTree.BuildableItems( order.Player, group ).Contains( order.TargetString ) ) + if( !Rules.TechTree.BuildableItems( order.Player, unit.Category ).Contains( order.TargetString ) ) return; /* you can't build that!! */ bool hasPlayedSound = false; - BeginProduction( group, + BeginProduction( unit.Category, new ProductionItem( order.TargetString, (int)time, ui.Cost, () => Game.world.AddFrameEndTask( _ => { - var isBuilding = group == "Building"; + var isBuilding = unit.Traits.Contains(); if( !hasPlayedSound && order.Player == Game.LocalPlayer ) { Sound.Play( isBuilding ? "conscmp1.aud" : "unitrdy1.aud" ); diff --git a/[mod]Separate buildqueue for defense.yaml b/[mod]Separate buildqueue for defense.yaml new file mode 100755 index 0000000000..57a409f42e --- /dev/null +++ b/[mod]Separate buildqueue for defense.yaml @@ -0,0 +1,23 @@ +IRON: + Category: Defense +PDOX: + Category: Defense +PBOX: + Category: Defense +HBOX: + Category: Defense +TSLA: + Category: Defense +GUN: + Category: Defense +AGUN: + Category: Defense +FTUR: + Category: Defense +GAP: + Category: Defense +SAM: + Category: Defense +MSLO: + Category: Defense +