OpenRA.Mods.Common.Traits.ProductionQueue.GetBuildTime C# (CSharp) Method

GetBuildTime() public method

public GetBuildTime ( ActorInfo unit, OpenRA.Traits.BuildableInfo bi ) : int
unit ActorInfo
bi OpenRA.Traits.BuildableInfo
return int
        public virtual int GetBuildTime(ActorInfo unit, BuildableInfo bi)
        {
            if (developerMode.FastBuild)
                return 0;

            var time = bi.BuildDuration;
            if (time == -1)
            {
                var valued = unit.TraitInfoOrDefault<ValuedInfo>();
                time = valued != null ? valued.Cost : 0;
            }

            time = time * bi.BuildDurationModifier * Info.BuildDurationModifier / 10000;
            return time;
        }

Usage Example

Beispiel #1
0
        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;
        }
All Usage Examples Of OpenRA.Mods.Common.Traits.ProductionQueue::GetBuildTime