Ejemplo n.º 1
0
        public void CollectCurrency(Entity buildingEntity)
        {
            if (buildingEntity == null)
            {
                return;
            }
            GeneratorComponent     generatorComponent     = buildingEntity.Get <GeneratorComponent>();
            BuildingComponent      buildingComponent      = buildingEntity.Get <BuildingComponent>();
            GeneratorViewComponent generatorViewComponent = buildingEntity.Get <GeneratorViewComponent>();

            if (buildingComponent == null || generatorComponent == null)
            {
                return;
            }
            Building     buildingTO = buildingComponent.BuildingTO;
            int          num        = this.CollectCurrencyFromGenerator(buildingEntity, true);
            string       contextId  = string.Empty;
            CurrencyType currency   = buildingComponent.BuildingType.Currency;

            if (currency != CurrencyType.Credits)
            {
                if (currency != CurrencyType.Materials)
                {
                    if (currency == CurrencyType.Contraband)
                    {
                        contextId = "Contraband";
                    }
                }
                else
                {
                    contextId = "Materials";
                }
            }
            else
            {
                contextId = "Credits";
            }
            if (buildingTO.AccruedCurrency < 1)
            {
                Service.UXController.HUD.ToggleContextButton(contextId, false);
            }
            if (num > 0)
            {
                this.OnCollectCurrency(buildingEntity, buildingComponent, num);
            }
            else if (num == 0)
            {
                this.HandleUnableToCollect(currency);
            }
            if (buildingTO.CurrentStorage == 0)
            {
                generatorViewComponent.ShowCollectButton(false);
            }
        }
Ejemplo n.º 2
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);
        }