コード例 #1
0
 private void OnSelectGeoConstructibleCB(GameObject obj)
 {
     if (base.PlayerController != null)
     {
         AgeControlButton component = obj.GetComponent <AgeControlButton>();
         GeoConstructibleLabel.PointOfInterestPair pointOfInterestPair = component.OnActivateDataObject as GeoConstructibleLabel.PointOfInterestPair;
         PointOfInterest pointOfInterest = pointOfInterestPair.PointOfInterest;
         PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition = pointOfInterestPair.PointOfInterestImprovementDefinition;
         OrderQueueConstruction order = new OrderQueueConstruction(this.City.Empire.Index, this.City.GUID, pointOfInterestImprovementDefinition, pointOfInterest.WorldPosition, string.Empty);
         base.PlayerController.PostOrder(order);
     }
 }
コード例 #2
0
    private bool CheckPointOfInterestImprovementPrerequisites(PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition, ref List <StaticString> failureFlags)
    {
        if (this.lastFailureFlags.Contains(ConstructionFlags.Discard))
        {
            return(false);
        }
        IWorldPositionningService service = base.Game.Services.GetService <IWorldPositionningService>();

        if (service == null)
        {
            this.lastFailureFlags.Add(ConstructionFlags.Discard);
            return(false);
        }
        DepartmentOfIndustry agency = this.City.Empire.GetAgency <DepartmentOfIndustry>();

        if (agency == null)
        {
            this.lastFailureFlags.Add(ConstructionFlags.Discard);
            return(false);
        }
        ConstructionQueue constructionQueue = agency.GetConstructionQueue(this.City);

        if (constructionQueue == null)
        {
            this.lastFailureFlags.Add(ConstructionFlags.Discard);
            return(false);
        }
        int num  = constructionQueue.Count(pointOfInterestImprovementDefinition);
        int num2 = 0;

        for (int i = 0; i < this.city.Region.PointOfInterests.Length; i++)
        {
            PointOfInterest pointOfInterest = this.city.Region.PointOfInterests[i];
            if (!(pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName != pointOfInterestImprovementDefinition.PointOfInterestTemplateName))
            {
                if (pointOfInterest.PointOfInterestImprovement == null)
                {
                    int explorationBits = service.GetExplorationBits(pointOfInterest.WorldPosition);
                    if ((explorationBits & this.city.Empire.Bits) != 0)
                    {
                        num2++;
                    }
                }
            }
        }
        if (num2 <= num)
        {
            this.lastFailureFlags.Add(ConstructionFlags.Discard);
            return(false);
        }
        return(true);
    }
コード例 #3
0
 public override void RefreshContent()
 {
     base.RefreshContent();
     this.validPointsOfInterest.Clear();
     this.validImprovements.Clear();
     if (this.City != null && this.City.BesiegingEmpire == null && base.Empire == this.City.Empire && !this.City.IsInfected)
     {
         DepartmentOfIndustry    agency  = this.City.Empire.GetAgency <DepartmentOfIndustry>();
         DepartmentOfTheInterior agency2 = this.City.Empire.GetAgency <DepartmentOfTheInterior>();
         DepartmentOfTheTreasury agency3 = this.City.Empire.GetAgency <DepartmentOfTheTreasury>();
         ConstructibleElement[]  availableConstructibleElements = agency.ConstructibleElementDatabase.GetAvailableConstructibleElements(new StaticString[0]);
         ConstructibleElement[]  array = availableConstructibleElements;
         List <StaticString>     list  = new List <StaticString>();
         for (int i = 0; i < this.City.Region.PointOfInterests.Length; i++)
         {
             PointOfInterest pointOfInterest = this.City.Region.PointOfInterests[i];
             if (pointOfInterest.PointOfInterestImprovement == null && pointOfInterest.CreepingNodeImprovement == null && (base.WorldPositionningService.GetExplorationBits(pointOfInterest.WorldPosition) & this.City.Empire.Bits) > 0)
             {
                 List <PointOfInterestImprovementDefinition> list2 = new List <PointOfInterestImprovementDefinition>();
                 List <ConstructibleDistrictDefinition>      list3 = new List <ConstructibleDistrictDefinition>();
                 for (int j = 0; j < array.Length; j++)
                 {
                     if (array[j] is PointOfInterestImprovementDefinition)
                     {
                         PointOfInterestImprovementDefinition pointOfInterestImprovementDefinition = array[j] as PointOfInterestImprovementDefinition;
                         if (pointOfInterestImprovementDefinition.PointOfInterestTemplateName == pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName)
                         {
                             list.Clear();
                             DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.City, pointOfInterestImprovementDefinition, ref list, new string[]
                             {
                                 ConstructionFlags.Prerequisite
                             });
                             if (!list.Contains(ConstructionFlags.Discard) && agency3.CheckConstructibleInstantCosts(this.City, pointOfInterestImprovementDefinition))
                             {
                                 list2.Add(agency2.GetBestImprovementDefinition(this.City, pointOfInterest, pointOfInterestImprovementDefinition, list));
                             }
                         }
                     }
                     else if (array[j] is ConstructibleDistrictDefinition)
                     {
                         ConstructibleDistrictDefinition constructibleDistrictDefinition = array[j] as ConstructibleDistrictDefinition;
                         if (constructibleDistrictDefinition != null)
                         {
                             list3.Add(constructibleDistrictDefinition);
                         }
                     }
                 }
                 if (list2.Count > 0)
                 {
                     ConstructionQueue constructionQueue = agency.GetConstructionQueue(this.City);
                     bool flag = false;
                     for (int k = 0; k < list2.Count; k++)
                     {
                         for (int l = 0; l < constructionQueue.Length; l++)
                         {
                             Construction construction = constructionQueue.PeekAt(l);
                             if (construction.ConstructibleElement == list2[k] && construction.WorldPosition == pointOfInterest.WorldPosition)
                             {
                                 flag = true;
                                 break;
                             }
                         }
                     }
                     if (!flag)
                     {
                         for (int m = 0; m < list3.Count; m++)
                         {
                             for (int n = 0; n < constructionQueue.Length; n++)
                             {
                                 Construction construction2 = constructionQueue.PeekAt(n);
                                 if (construction2.ConstructibleElement == list3[m] && construction2.WorldPosition == pointOfInterest.WorldPosition)
                                 {
                                     flag = true;
                                     break;
                                 }
                             }
                         }
                     }
                     if (!flag)
                     {
                         for (int num = 0; num < list2.Count; num++)
                         {
                             this.validPointsOfInterest.Add(pointOfInterest);
                             this.validImprovements.Add(list2[num]);
                         }
                     }
                 }
             }
         }
     }
     this.LabelsTable.ReserveChildren(this.validPointsOfInterest.Count, this.LabelPrefab, "ConstructibleLabel");
     this.LabelsTable.RefreshChildrenIList <PointOfInterest>(this.validPointsOfInterest, new AgeTransform.RefreshTableItem <PointOfInterest>(this.RefreshPointOfInterest), true, false);
     this.LabelsTable.Enable = this.interactionsAllowed;
     this.UnbindAndHideLabels(this.validPointsOfInterest.Count);
 }