From 668f377301b74ce2d4957c2f889ef988e24c15fa Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 21 Mar 2010 20:53:49 +1300 Subject: [PATCH] holding shift while building adds 5 --- OpenRA.Game/Chrome.cs | 2 +- OpenRA.Game/Controller.cs | 1 + OpenRA.Game/Network/Order.cs | 4 +- OpenRA.Game/Traits/Player/ProductionQueue.cs | 49 +++++++++++--------- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/OpenRA.Game/Chrome.cs b/OpenRA.Game/Chrome.cs index 9a3033ffcf..424aebe80e 100644 --- a/OpenRA.Game/Chrome.cs +++ b/OpenRA.Game/Chrome.cs @@ -996,7 +996,7 @@ namespace OpenRA var unit = Rules.Info[item]; Sound.Play(unit.Traits.Contains() ? eva.BuildingSelectAudio : eva.UnitSelectAudio); - Game.IssueOrder(Order.StartProduction(world.LocalPlayer, item)); + Game.IssueOrder(Order.StartProduction(world.LocalPlayer, item, Game.controller.GetModifiers().HasModifier(Modifiers.Shift) ? 5 : 1)); } void HandleBuildPalette( World world, string item, bool isLmb ) diff --git a/OpenRA.Game/Controller.cs b/OpenRA.Game/Controller.cs index 3bb1d77817..3b40601c12 100644 --- a/OpenRA.Game/Controller.cs +++ b/OpenRA.Game/Controller.cs @@ -145,5 +145,6 @@ namespace OpenRA } public void SetModifiers(Modifiers mods) { modifiers = mods; } + public Modifiers GetModifiers() { return modifiers; } } } diff --git a/OpenRA.Game/Network/Order.cs b/OpenRA.Game/Network/Order.cs index cf0dad188c..7c1b97494f 100755 --- a/OpenRA.Game/Network/Order.cs +++ b/OpenRA.Game/Network/Order.cs @@ -164,9 +164,9 @@ namespace OpenRA return new Order("Chat", null, text) { IsImmediate = true }; } - public static Order StartProduction(Player subject, string item) + public static Order StartProduction(Player subject, string item, int count) { - return new Order("StartProduction", subject.PlayerActor, item ); + return new Order("StartProduction", subject.PlayerActor, new int2( count, 0 ), item ); } public static Order PauseProduction(Player subject, string item, bool pause) diff --git a/OpenRA.Game/Traits/Player/ProductionQueue.cs b/OpenRA.Game/Traits/Player/ProductionQueue.cs index c3e5c36c7b..d61c5fff4e 100644 --- a/OpenRA.Game/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Game/Traits/Player/ProductionQueue.cs @@ -52,33 +52,36 @@ namespace OpenRA.Traits { case "StartProduction": { - var unit = Rules.Info[ 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 */ - / 1000; + for (var n = 0; n < order.TargetLocation.X; n++) // repeat count + { + var unit = Rules.Info[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 */ + / 1000; - if( !Rules.TechTree.BuildableItems( order.Player, unit.Category ).Contains( order.TargetString ) ) - return; /* you can't build that!! */ + if (!Rules.TechTree.BuildableItems(order.Player, unit.Category).Contains(order.TargetString)) + return; /* you can't build that!! */ - bool hasPlayedSound = false; + bool hasPlayedSound = false; - BeginProduction( unit.Category, - new ProductionItem( order.TargetString, (int)time, ui.Cost, - () => self.World.AddFrameEndTask( - _ => - { - var isBuilding = unit.Traits.Contains(); - if( !hasPlayedSound ) + BeginProduction(unit.Category, + new ProductionItem(order.TargetString, (int)time, ui.Cost, + () => self.World.AddFrameEndTask( + _ => { - var eva = self.World.WorldActor.Info.Traits.Get(); - Sound.PlayToPlayer( order.Player, isBuilding ? eva.BuildingReadyAudio : eva.UnitReadyAudio ); - hasPlayedSound = true; - } - if( !isBuilding ) - BuildUnit( order.TargetString ); - } ) ) ); + var isBuilding = unit.Traits.Contains(); + if (!hasPlayedSound) + { + var eva = self.World.WorldActor.Info.Traits.Get(); + Sound.PlayToPlayer(order.Player, isBuilding ? eva.BuildingReadyAudio : eva.UnitReadyAudio); + hasPlayedSound = true; + } + if (!isBuilding) + BuildUnit(order.TargetString); + }))); + } break; } case "PauseProduction":