Example #1
0
        public void Tick(PlayerResources pr)
        {
            if (!Started)
            {
                var time = Queue.GetBuildTime(ai, bi);
                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;
        }
Example #2
0
        public ProductionQueue(ActorInitializer init, Actor playerActor, ProductionQueueInfo info)
        {
            self            = init.Self;
            Info            = info;
            playerResources = playerActor.Trait <PlayerResources>();
            playerPower     = playerActor.Trait <PowerManager>();
            developerMode   = playerActor.Trait <DeveloperMode>();

            Faction        = init.Contains <FactionInit>() ? init.Get <FactionInit, string>() : self.Owner.Faction.InternalName;
            IsValidFaction = !info.Factions.Any() || info.Factions.Contains(Faction);

            Enabled = IsValidFaction;
            CacheProducibles(playerActor);

            allProducibles       = producible.Where(a => a.Value.Buildable || a.Value.Visible).Select(a => a.Key);
            buildableProducibles = producible.Where(a => a.Value.Buildable).Select(a => a.Key);
        }
 public ResourceStorageWarning(Actor self, ResourceStorageWarningInfo info)
 {
     this.info = info;
     resources = self.Trait <PlayerResources>();
 }
Example #4
0
 public WithSiloAnimation(ActorInitializer init, WithSiloAnimationInfo info)
 {
     this.info       = info;
     wsb             = init.Self.Trait <WithSpriteBody>();
     playerResources = init.Self.Owner.PlayerActor.Trait <PlayerResources>();
 }
Example #5
0
 void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
 {
     player = newOwner.PlayerActor.Trait <PlayerResources>();
 }
Example #6
0
 public StoresResources(Actor self, StoresResourcesInfo info)
 {
     this.info = info;
     player    = self.Owner.PlayerActor.Trait <PlayerResources>();
 }