Exemplo n.º 1
0
 protected override void Update(float dt)
 {
     if (this.nodeList == null)
     {
         return;
     }
     this.timeSinceViewUpdate     += dt;
     this.timeSinceFullnessUpdate += dt;
     if (this.timeSinceViewUpdate >= 1f)
     {
         bool flag = false;
         if (this.timeSinceFullnessUpdate >= 5f)
         {
             flag = true;
             this.timeSinceFullnessUpdate = 0f;
         }
         for (GeneratorViewNode generatorViewNode = this.nodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next)
         {
             if (!this.postBattleRepairController.IsEntityInRepair(generatorViewNode.Entity))
             {
                 this.currencyController.UpdateGeneratorAccruedCurrency((SmartEntity)generatorViewNode.Entity);
                 if (flag)
                 {
                     this.storageEffects.UpdateFillState(generatorViewNode.Entity, generatorViewNode.BuildingComp.BuildingType);
                 }
             }
         }
         this.timeSinceViewUpdate = 0f;
     }
 }
Exemplo n.º 2
0
        public static void ProcessResouceGenPerkEffectsIntoStorage(List <ActivatedPerkData> allPerks)
        {
            ISupportController           supportController = Service.Get <ISupportController>();
            NodeList <GeneratorViewNode> nodeList          = Service.Get <EntityController>().GetNodeList <GeneratorViewNode>();

            for (GeneratorViewNode generatorViewNode = nodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next)
            {
                BuildingComponent buildingComp = generatorViewNode.BuildingComp;
                Building          buildingTO   = buildingComp.BuildingTO;
                BuildingTypeVO    buildingType = buildingComp.BuildingType;
                Contract          contract     = supportController.FindCurrentContract(buildingComp.BuildingTO.Key);
                if (buildingType.Type == BuildingType.Resource && contract == null)
                {
                    uint time            = ServerTime.Time;
                    uint lastCollectTime = buildingTO.LastCollectTime;
                    buildingTO.LastCollectTime = time;
                    int perkAdjustedAccruedCurrency = ResourceGenerationPerkUtils.GetPerkAdjustedAccruedCurrency(buildingType, lastCollectTime, time, allPerks);
                    buildingTO.CurrentStorage += perkAdjustedAccruedCurrency;
                    if (buildingTO.CurrentStorage > buildingType.Storage)
                    {
                        buildingTO.CurrentStorage = buildingType.Storage;
                    }
                    buildingTO.AccruedCurrency = buildingTO.CurrentStorage;
                }
            }
        }
Exemplo n.º 3
0
 public override void RemoveFromGame(IGame game)
 {
     for (GeneratorViewNode generatorViewNode = this.nodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next)
     {
         if (generatorViewNode.GeneratorView != null)
         {
             generatorViewNode.GeneratorView.ShowCollectButton(false);
             generatorViewNode.GeneratorView.SetEnabled(false);
         }
     }
     this.entityController = null;
     this.nodeList         = null;
 }
Exemplo n.º 4
0
        public override void Execute()
        {
            base.Execute();
            List <SmartEntity> buildingListByType = Service.BuildingLookupController.GetBuildingListByType(this.type);

            for (int i = 0; i < buildingListByType.Count; i++)
            {
                SmartEntity       smartEntity  = buildingListByType[i];
                BuildingComponent buildingComp = smartEntity.BuildingComp;
                if (this.area.Contains(new Vector2((float)buildingComp.BuildingTO.X, (float)buildingComp.BuildingTO.Z)))
                {
                    if (!ContractUtils.IsBuildingConstructing(smartEntity))
                    {
                        if (smartEntity.HealthViewComp != null)
                        {
                            smartEntity.HealthViewComp.SetEnabled(this.show);
                        }
                        if (smartEntity.SupportViewComp != null)
                        {
                            smartEntity.SupportViewComp.SetEnabled(this.show);
                        }
                        if (smartEntity.GeneratorViewComp != null)
                        {
                            GeneratorViewComponent generatorViewComp = smartEntity.GeneratorViewComp;
                            if (this.show)
                            {
                                generatorViewComp.SetEnabled(this.show);
                                NodeList <GeneratorViewNode> nodeList = Service.EntityController.GetNodeList <GeneratorViewNode>();
                                for (GeneratorViewNode generatorViewNode = nodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next)
                                {
                                    if (generatorViewNode.Entity == smartEntity)
                                    {
                                        Service.ICurrencyController.UpdateGeneratorAccruedCurrency(smartEntity);
                                    }
                                }
                            }
                            else
                            {
                                generatorViewComp.ShowCollectButton(false);
                                generatorViewComp.SetEnabled(this.show);
                            }
                        }
                        if (this.show)
                        {
                            Service.BuildingTooltipController.EnsureBuildingTooltip(smartEntity);
                        }
                    }
                }
            }
            this.parent.ChildComplete(this);
        }
Exemplo n.º 5
0
 public override void AddToGame(IGame game)
 {
     this.entityController           = Service.Get <EntityController>();
     this.currencyController         = Service.Get <ICurrencyController>();
     this.postBattleRepairController = Service.Get <PostBattleRepairController>();
     this.nodeList       = this.entityController.GetNodeList <GeneratorViewNode>();
     this.storageEffects = Service.Get <StorageEffects>();
     for (GeneratorViewNode generatorViewNode = this.nodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next)
     {
         if (generatorViewNode.GeneratorView != null)
         {
             generatorViewNode.GeneratorView.SetEnabled(true);
         }
     }
 }
        public override void Execute()
        {
            base.Execute();
            EntityController          entityController = Service.Get <EntityController>();
            NodeList <HealthViewNode> nodeList         = entityController.GetNodeList <HealthViewNode>();

            for (HealthViewNode healthViewNode = nodeList.Head; healthViewNode != null; healthViewNode = healthViewNode.Next)
            {
                healthViewNode.HealthView.SetEnabled(this.show);
                if (this.show)
                {
                    Service.Get <BuildingTooltipController>().EnsureBuildingTooltip((SmartEntity)healthViewNode.Entity);
                }
            }
            NodeList <SupportViewNode> nodeList2 = Service.Get <EntityController>().GetNodeList <SupportViewNode>();

            for (SupportViewNode supportViewNode = nodeList2.Head; supportViewNode != null; supportViewNode = supportViewNode.Next)
            {
                supportViewNode.SupportView.SetEnabled(this.show);
                if (this.show)
                {
                    Service.Get <BuildingTooltipController>().EnsureBuildingTooltip((SmartEntity)supportViewNode.Entity);
                }
            }
            NodeList <GeneratorViewNode> nodeList3 = Service.Get <EntityController>().GetNodeList <GeneratorViewNode>();

            for (GeneratorViewNode generatorViewNode = nodeList3.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next)
            {
                if (this.show)
                {
                    generatorViewNode.GeneratorView.SetEnabled(this.show);
                    Service.Get <ICurrencyController>().UpdateGeneratorAccruedCurrency((SmartEntity)generatorViewNode.Entity);
                }
                else
                {
                    generatorViewNode.GeneratorView.ShowCollectButton(false);
                    generatorViewNode.GeneratorView.SetEnabled(this.show);
                }
            }
            this.parent.ChildComplete(this);
        }
Exemplo n.º 7
0
        public int CalculateTimeUntilAllGeneratorsFull()
        {
            NodeList <GeneratorViewNode> generatorViewNodeList = Service.Get <BuildingLookupController>().GeneratorViewNodeList;
            ISupportController           supportController     = Service.Get <ISupportController>();
            int num = 0;

            if (generatorViewNodeList != null)
            {
                for (GeneratorViewNode generatorViewNode = generatorViewNodeList.Head; generatorViewNode != null; generatorViewNode = generatorViewNode.Next)
                {
                    if (generatorViewNode.BuildingComp != null && supportController.FindCurrentContract(generatorViewNode.BuildingComp.BuildingTO.Key) == null)
                    {
                        int num2 = this.CalculateGeneratorFillTimeRemaining(generatorViewNode.Entity);
                        if (num2 > num)
                        {
                            num = num2;
                        }
                    }
                }
            }
            return(num);
        }