Permalink
Browse files

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.
  • Loading branch information...
1 parent c95114d commit bd077d337fbce578cf45e841a7a84369777df536 @stecman stecman committed Mar 9, 2014
Showing with 13 additions and 6 deletions.
  1. +1 −0 CHANGELOG
  2. +12 −6 OpenRA.Mods.RA/Player/ProductionQueue.cs
View
@@ -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.
@@ -232,7 +232,7 @@ public void ResolveOrder( Actor self, Order order )
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 @@ public class ProductionItem
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 @@ public int RemainingTimeActual
}
}
- 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 @@ public ProductionItem(ProductionQueue queue, string item, int time, int cost, Po
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();

0 comments on commit bd077d3

Please sign in to comment.