From bd077d337fbce578cf45e841a7a84369777df536 Mon Sep 17 00:00:00 2001 From: Stephen Holdaway Date: Sun, 9 Mar 2014 13:38:57 +1200 Subject: [PATCH] Set ProductionItem build time when building starts The build time for a unit/structure was previously set at the time that item was added to a production queue. This meant modifiers of the production time (multiple production facilities in ClassicProductionQueue or "instant build" in debug) were not applied to items already in a queue. This change modifies ProductionQueue so that build time is set at the instant an item starts building (reaches the front of it's queue). This was done primarily to make the production bonuses in ClassicProductionQueue more apparent, though it also makes the "instant build" debug option more responsive when items are queued prior to enabling. --- CHANGELOG | 1 + OpenRA.Mods.RA/Player/ProductionQueue.cs | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 89de5e11a0..5eeb5ee6ed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -23,6 +23,7 @@ NEW: Order lines are now shown on unit selection. Fixed chat synchronization in replays. Fixed the game sometimes crashing when deploying and activating the guard cursor at the same time. + Build time is now set when an item reaches the front of a queue, instead of immediately when queued. Dune 2000: Added the Atreides grenadier from the 1.06 patch. Added randomized tiles for Sand and Rock terrain. diff --git a/OpenRA.Mods.RA/Player/ProductionQueue.cs b/OpenRA.Mods.RA/Player/ProductionQueue.cs index 3a824bf627..02336b1396 100755 --- a/OpenRA.Mods.RA/Player/ProductionQueue.cs +++ b/OpenRA.Mods.RA/Player/ProductionQueue.cs @@ -232,7 +232,7 @@ namespace OpenRA.Mods.RA for (var n = 0; n < order.TargetLocation.X; n++) // repeat count { bool hasPlayedSound = false; - BeginProduction(new ProductionItem(this, order.TargetString, time, cost, PlayerPower, + BeginProduction(new ProductionItem(this, order.TargetString, cost, PlayerPower, () => self.World.AddFrameEndTask( _ => { @@ -347,7 +347,7 @@ namespace OpenRA.Mods.RA public readonly string Item; public readonly ProductionQueue Queue; readonly PowerManager pm; - public readonly int TotalTime; + public int TotalTime; public readonly int TotalCost; public int RemainingTime { get; private set; } public int RemainingCost { get; private set; } @@ -360,15 +360,14 @@ namespace OpenRA.Mods.RA } } - public bool Paused = false, Done = false; + public bool Paused = false, Done = false, Started = false; public Action OnComplete; public int slowdown = 0; - public ProductionItem(ProductionQueue queue, string item, int time, int cost, PowerManager pm, Action onComplete) + public ProductionItem(ProductionQueue queue, string item, int cost, PowerManager pm, Action onComplete) { - if (time <= 0) time = 1; Item = item; - RemainingTime = TotalTime = time; + RemainingTime = TotalTime = 1; RemainingCost = TotalCost = cost; OnComplete = onComplete; Queue = queue; @@ -378,6 +377,13 @@ namespace OpenRA.Mods.RA public void Tick(PlayerResources pr) { + if (!Started) + { + var time = Queue.GetBuildTime(Item); + if (time > 0) RemainingTime = TotalTime = time; + Started = true; + } + if (Done) { if (OnComplete != null) OnComplete();