public GetBuildTime ( ActorInfo unit, OpenRA.Traits.BuildableInfo bi ) : int | ||
unit | ActorInfo | |
bi | OpenRA.Traits.BuildableInfo | |
return | int |
public void Tick(PlayerResources pr) { if (!Started) { var time = Queue.GetBuildTime(ai, bi); if (time > 0) { RemainingTime = TotalTime = time; } Started = true; } if (Done) { if (OnComplete != null) { OnComplete(); } return; } if (Paused) { return; } if (pm != null && pm.PowerState != PowerState.Normal) { Slowdown -= 100; if (Slowdown < 0) { Slowdown = Queue.Info.LowPowerModifier + Slowdown; } else { return; } } var expectedRemainingCost = RemainingTime == 1 ? 0 : TotalCost * RemainingTime / Math.Max(1, TotalTime); var costThisFrame = RemainingCost - expectedRemainingCost; if (costThisFrame != 0 && !pr.TakeCash(costThisFrame, true)) { return; } RemainingCost -= costThisFrame; RemainingTime -= 1; if (RemainingTime > 0) { return; } Done = true; }
public void Tick(PlayerResources pr) { if (!Started) { var time = Queue.GetBuildTime(ai, bi); if (time > 0) { RemainingTime = TotalTime = time; } Started = true; } if (Done) { if (OnComplete != null) { OnComplete(); } return; } if (Paused) { return; } if (pm.PowerState != PowerState.Normal) { if (--Slowdown <= 0) { Slowdown = Queue.Info.LowPowerSlowdown; } else { return; } } var costThisFrame = RemainingCost / RemainingTime; if (costThisFrame != 0 && !pr.TakeCash(costThisFrame, true)) { return; } RemainingCost -= costThisFrame; RemainingTime -= 1; if (RemainingTime > 0) { return; } Done = true; }