Example #1
0
    private bool IsSpellAlreadyCasted(SpellDefinitionTooltipData spellDefinitionTooltipData, ref bool isThisSpellActive)
    {
        Contender firstAlliedContenderFromEmpireWithUnits = spellDefinitionTooltipData.Encounter.GetFirstAlliedContenderFromEmpireWithUnits(spellDefinitionTooltipData.Empire);

        foreach (SpellDefinition spellDefinition in this.spellDefinitionDatabase)
        {
            if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(spellDefinitionTooltipData.Empire, spellDefinition, new string[]
            {
                ConstructionFlags.Prerequisite
            }))
            {
                for (int i = 0; i < spellDefinition.SpellBattleActions.Length; i++)
                {
                    StaticString       name = spellDefinition.SpellBattleActions[i].BattleActionUserDefinitionReference.Name;
                    BattleAction.State state;
                    if (firstAlliedContenderFromEmpireWithUnits.TryGetBattleActionUserState(name, out state) && state != BattleAction.State.Available)
                    {
                        isThisSpellActive = (spellDefinition.Name == spellDefinitionTooltipData.SpellDefinition.Name);
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Example #2
0
    protected List <AILayer_CreepingNode.EvaluableCreepingNode> GetAvailableNodes()
    {
        List <AILayer_CreepingNode.EvaluableCreepingNode> list = new List <AILayer_CreepingNode.EvaluableCreepingNode>();
        List <StaticString> list2 = new List <StaticString>();

        CreepingNodeImprovementDefinition[] values = this.creepingNodeDefinitionDatabase.GetValues();
        for (int i = 0; i < this.worldPositionningService.World.Regions.Length; i++)
        {
            Region region = this.worldPositionningService.World.Regions[i];
            int    num    = region.IsRegionColonized() ? 1 : 0;
            bool   flag   = region.Kaiju != null;
            bool   flag2  = region.BelongToEmpire(base.AIEntity.Empire);
            bool   flag3  = false;
            if (ELCPUtilities.UseELCPPeacefulCreepingNodes && !flag2 && region.Owner != null && region.Owner is MajorEmpire)
            {
                flag3 = (this.departmentOfForeignAffairs.IsFriend(region.Owner) && this.departmentOfForeignAffairs.CanMoveOn(region.Index, false));
            }
            bool flag4 = false;
            if (flag)
            {
                flag4 = (region.Kaiju.IsWild() || region.Kaiju.OwnerEmpireIndex == base.AIEntity.Empire.Index);
            }
            if (num == 0 || flag2 || flag3 || (flag && flag4))
            {
                foreach (PointOfInterest pointOfInterest in region.PointOfInterests)
                {
                    bool flag5 = this.departmentOfCreepingNodes.POIIsOnCooldown(pointOfInterest.GUID);
                    if ((!flag3 || pointOfInterest.Type == "QuestLocation") && !flag5)
                    {
                        bool flag6 = this.IsPoiUnlocked(pointOfInterest);
                        if (pointOfInterest.CreepingNodeImprovement == null && (!(pointOfInterest.Type != "Village") || pointOfInterest.PointOfInterestImprovement == null) && ((this.worldPositionningService.GetExplorationBits(pointOfInterest.WorldPosition) & base.AIEntity.Empire.Bits) > 0 && flag6))
                        {
                            foreach (CreepingNodeImprovementDefinition creepingNodeImprovementDefinition in values)
                            {
                                if (creepingNodeImprovementDefinition.PointOfInterestTemplateName == pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName && (!(pointOfInterest.Type == "Village") || (pointOfInterest.SimulationObject.Tags.Contains(Village.PacifiedVillage) && !pointOfInterest.SimulationObject.Tags.Contains(Village.ConvertedVillage))))
                                {
                                    list2.Clear();
                                    DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.aiEntityCity.City, creepingNodeImprovementDefinition, ref list2, new string[]
                                    {
                                        ConstructionFlags.Prerequisite
                                    });
                                    if (!list2.Contains(ConstructionFlags.Discard) && this.departmentOfTheTreasury.CheckConstructibleInstantCosts(this.aiEntityCity.City, creepingNodeImprovementDefinition))
                                    {
                                        CreepingNodeImprovementDefinition          bestCreepingNodeDefinition = this.departmentOfCreepingNodes.GetBestCreepingNodeDefinition(this.aiEntityCity.City, pointOfInterest, creepingNodeImprovementDefinition, list2);
                                        AILayer_CreepingNode.EvaluableCreepingNode item = new AILayer_CreepingNode.EvaluableCreepingNode(pointOfInterest, bestCreepingNodeDefinition);
                                        if (!list.Contains(item))
                                        {
                                            list.Add(item);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return(list);
    }
Example #3
0
    public void FilterHighestItemTier()
    {
        this.HighestItemTiers.Clear();
        string       itemType = string.Empty;
        string       text     = string.Empty;
        StaticString x        = StaticString.Empty;

        foreach (ItemDefinition itemDefinition in this.allItems)
        {
            if (!itemDefinition.Hidden && DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.editableUnitDesign.GetSimulationObject(), itemDefinition, new string[]
            {
                "Discard"
            }))
            {
                itemType = itemDefinition.SubCategory;
                for (int i = 0; i < itemDefinition.Descriptors.Length; i++)
                {
                    if (itemDefinition.Descriptors[i].Type == "ItemTier")
                    {
                        x = itemDefinition.Descriptors[i].Name;
                    }
                    if (itemDefinition.Descriptors[i].Type == "ItemMaterial")
                    {
                        text = itemDefinition.Descriptors[i].Name;
                    }
                }
                bool flag = false;
                if (x != ForgePanel.ItemTier4)
                {
                    for (int j = 0; j < this.HighestItemTiers.Count; j++)
                    {
                        if (this.HighestItemTiers[j].MatchesTypeAndRessource(itemType, text))
                        {
                            if (string.Compare(x, this.HighestItemTiers[j].Tier) > 0)
                            {
                                this.HighestItemTiers[j].Tier = x;
                            }
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag)
                {
                    this.HighestItemTiers.Add(new ForgePanel.ObsolescenceGroup(itemType, text, x));
                }
            }
        }
    }
Example #4
0
    private void BuildAvailableSpellsDefinitions()
    {
        this.availableSpellDefinitions.Clear();
        IDatabase <SpellDefinition> database = Databases.GetDatabase <SpellDefinition>(false);

        if (database != null)
        {
            this.availableSpellDefinitions.AddRange(from spellDefinition in database.GetValues()
                                                    where DepartmentOfTheTreasury.CheckConstructiblePrerequisites(base.Empire, spellDefinition, new string[]
            {
                ConstructionFlags.Prerequisite
            })
                                                    select spellDefinition);
        }
    }
Example #5
0
    public DepartmentOfScience.ConstructibleElement.State GetTechnologyState(ConstructibleElement technology, Empire empire)
    {
        if (technology == null)
        {
            throw new ArgumentNullException("technology");
        }
        ConstructionQueue constructionQueue = null;

        if (!this.researchQueues.TryGetValue(empire.Index, out constructionQueue))
        {
            Diagnostics.LogError("The provided empire does not have a construction queue. Make sure one is created.");
            return(DepartmentOfScience.ConstructibleElement.State.NotAvailable);
        }
        if (this.researchedTechNames.Contains(technology.Name))
        {
            if (empire is MajorEmpire && !DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, technology, new string[]
            {
                ConstructionFlags.Prerequisite
            }))
            {
                return(DepartmentOfScience.ConstructibleElement.State.ResearchedButUnavailable);
            }
            return(DepartmentOfScience.ConstructibleElement.State.Researched);
        }
        else
        {
            Diagnostics.Assert(constructionQueue != null);
            Construction construction = constructionQueue.Get(technology);
            if (construction != null && construction.ConstructibleElement.Name == technology.Name)
            {
                return(DepartmentOfScience.ConstructibleElement.State.InProgress);
            }
            if (constructionQueue.Contains(technology))
            {
                return(DepartmentOfScience.ConstructibleElement.State.Queued);
            }
            if (!DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, technology, new string[]
            {
                ConstructionFlags.Prerequisite
            }))
            {
                return(DepartmentOfScience.ConstructibleElement.State.NotAvailable);
            }
            return(DepartmentOfScience.ConstructibleElement.State.Available);
        }
    }
Example #6
0
    private SynchronousJobState SynchronousJob_StartValidatedBoosters()
    {
        if (this.aiEntityCity.City == null || !this.aiEntityCity.City.GUID.IsValid || this.aiEntityCity.City.Empire.Index != base.AIEntity.Empire.Index || this.aiEntityCity.City.BesiegingEmpireIndex >= 0)
        {
            return(SynchronousJobState.Success);
        }
        float num = 0f;

        this.departmentOfTheTreasury.TryGetResourceStockValue(base.AIEntity.Empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpireMoney, out num, false);
        if (num <= this.MoneyAtTurnBegin * (this.departmentOfForeignAffairs.IsInWarWithSomeone() ? 0.5f : 0.25f))
        {
            return(SynchronousJobState.Success);
        }
        this.decisionMaker.UnregisterAllOutput();
        this.decisionMaker.ClearAIParametersOverrides();
        base.AIEntity.Context.InitializeDecisionMaker <PillarDefinition>(AICityState.ProductionParameterModifier, this.decisionMaker);
        List <PillarDefinition> elements = (from pillarDefinition in this.PillarDatabase.GetValues()
                                            where DepartmentOfTheTreasury.CheckConstructiblePrerequisites(base.AIEntity.Empire, pillarDefinition, new string[]
        {
            ConstructionFlags.Prerequisite
        })
                                            select pillarDefinition).ToList <PillarDefinition>();

        this.decisionResults.Clear();
        this.decisionMaker.EvaluateDecisions(elements, ref this.decisionResults);
        if (this.decisionResults != null && this.decisionResults.Count > 0 && this.decisionResults[0].Score > 0f)
        {
            if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && ELCPUtilities.ELCPVerboseMode)
            {
                foreach (DecisionResult decisionResult in this.decisionResults)
                {
                    PillarDefinition pillarDefinition3 = decisionResult.Element as PillarDefinition;
                    Diagnostics.Log("ELCP {0}/{1} AILayer_Pillar evaluations {2} {3}", new object[]
                    {
                        base.AIEntity.Empire,
                        this.aiEntityCity.City.LocalizedName,
                        pillarDefinition3.Name,
                        decisionResult.Score
                    });
                }
            }
            PillarDefinition pillarDefinition2 = this.decisionResults[0].Element as PillarDefinition;
            if (pillarDefinition2.Name == AILayer_Pillar.DustPillarName && pillarDefinition2.GetPillarCount(base.AIEntity.Empire) > 2f)
            {
                if (this.decisionResults.Count <= 1 || this.decisionResults[1].Score <= 0f)
                {
                    return(SynchronousJobState.Failure);
                }
                pillarDefinition2 = (this.decisionResults[1].Element as PillarDefinition);
            }
            int           num2           = 0;
            WorldPosition targetPosition = this.ComputeMostOverlappingPositionForRange(pillarDefinition2, out num2);
            if (num2 < 5)
            {
                return(SynchronousJobState.Success);
            }
            float pillarDustCost = this.GetPillarDustCost(pillarDefinition2);
            if (!float.IsPositiveInfinity(pillarDustCost) && num >= pillarDustCost && targetPosition.IsValid)
            {
                OrderBuyoutAndActivatePillar order = new OrderBuyoutAndActivatePillar(base.AIEntity.Empire.Index, pillarDefinition2.Name, targetPosition);
                base.AIEntity.Empire.PlayerControllers.AI.PostOrder(order);
                return(SynchronousJobState.Running);
            }
        }
        return(SynchronousJobState.Success);
    }
Example #7
0
 public override void RefreshContent()
 {
     if (Services.GetService <IDownloadableContentService>().IsShared(DownloadableContent16.ReadOnlyName) && this.editableUnitDesign.UnitBodyDefinition.Tags.Contains(DownloadableContent16.TagSeafaring))
     {
         this.ForgeTitle.Text = "%ArsenalPanelTitle";
     }
     else
     {
         this.ForgeTitle.Text = "%ForgePanelTitle";
     }
     this.filter = ForgePanel.ItemCategory.Default;
     for (int i = 0; i < this.FilterTable.GetChildren().Count; i++)
     {
         AgeControlToggle ageControlToggle = this.filterToggles[i];
         if (ageControlToggle.State)
         {
             this.filter |= this.filtersByToggle[ageControlToggle];
         }
     }
     this.filteredItems.Clear();
     this.itemEnableState.Clear();
     if (this.editableUnitDesign != null)
     {
         foreach (ItemDefinition itemDefinition in this.allItems)
         {
             if (!itemDefinition.Hidden)
             {
                 this.failuresFlags.Clear();
                 DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.editableUnitDesign.GetSimulationObject(), itemDefinition, ref this.failuresFlags, new string[]
                 {
                     ConstructionFlags.Prerequisite
                 });
                 if (!this.failuresFlags.Contains(ConstructionFlags.Discard))
                 {
                     bool flag  = this.failuresFlags.Count > 0;
                     bool flag2 = false;
                     int  j     = 0;
                     while (j < itemDefinition.Descriptors.Length)
                     {
                         if (itemDefinition.Descriptors[j].Type == "ItemCategory")
                         {
                             if ((this.filter & ForgePanel.ItemCategory.Weapon) > ForgePanel.ItemCategory.Default)
                             {
                                 flag2 = (itemDefinition.Descriptors[j].Name == "ItemCategory" + ForgePanel.ItemCategory.Weapon);
                             }
                             if (!flag2 && (this.filter & ForgePanel.ItemCategory.Armor) > ForgePanel.ItemCategory.Default)
                             {
                                 flag2 = (itemDefinition.Descriptors[j].Name == "ItemCategory" + ForgePanel.ItemCategory.Armor);
                             }
                             if (!flag2 && (this.filter & ForgePanel.ItemCategory.Accessory) > ForgePanel.ItemCategory.Default)
                             {
                                 flag2 = (itemDefinition.Descriptors[j].Name == "ItemCategory" + ForgePanel.ItemCategory.Accessory);
                                 break;
                             }
                             break;
                         }
                         else
                         {
                             j++;
                         }
                     }
                     if (flag2 && !this.ShowMissingResourceToggle.State)
                     {
                         for (int k = 0; k < itemDefinition.Descriptors.Length; k++)
                         {
                             if (itemDefinition.Descriptors[k].Type == "ItemMaterial")
                             {
                                 this.resourceName = itemDefinition.Descriptors[k].Name;
                                 this.resourceName = this.resourceName.Remove(0, "ItemMaterial".Length);
                                 float num;
                                 if (!this.departmentOfTheTreasury.TryGetResourceStockValue(this.Empire.SimulationObject, this.resourceName, out num, true))
                                 {
                                     num = 1f;
                                 }
                                 if (num < 1f)
                                 {
                                     flag2 = false;
                                 }
                             }
                         }
                     }
                     if (flag2 && !this.ShowObsoleteToggle.State && !itemDefinition.Tags.Contains("NeverObsolete"))
                     {
                         string itemType = string.Empty;
                         string text     = string.Empty;
                         string strA     = string.Empty;
                         itemType = itemDefinition.SubCategory;
                         for (int l = 0; l < itemDefinition.Descriptors.Length; l++)
                         {
                             if (itemDefinition.Descriptors[l].Type == "ItemTier")
                             {
                                 strA = itemDefinition.Descriptors[l].Name;
                             }
                             if (itemDefinition.Descriptors[l].Type == "ItemMaterial")
                             {
                                 text = itemDefinition.Descriptors[l].Name;
                             }
                         }
                         int m = 0;
                         while (m < this.HighestItemTiers.Count)
                         {
                             if (this.HighestItemTiers[m].MatchesTypeAndRessource(itemType, text))
                             {
                                 if (string.Compare(strA, this.HighestItemTiers[m].Tier) < 0)
                                 {
                                     flag2 = false;
                                     break;
                                 }
                                 break;
                             }
                             else
                             {
                                 m++;
                             }
                         }
                     }
                     if (flag2)
                     {
                         this.filteredItems.Add(itemDefinition);
                         this.itemEnableState.Add(!flag);
                     }
                 }
             }
         }
     }
     this.ForgeItemTable.Height = 0f;
     this.ForgeItemTable.ReserveChildren(this.filteredItems.Count, this.ForgeItemPrefab, "Item");
     this.ForgeItemTable.RefreshChildrenIList <ItemDefinition>(this.filteredItems, this.refreshForgeItemDelegate, true, false);
     this.ForgeItemTable.ArrangeChildren();
     base.RefreshContent();
 }
Example #8
0
    private void OrderCityBuilding()
    {
        DepartmentOfTheInterior agency  = this.Empire.GetAgency <DepartmentOfTheInterior>();
        DepartmentOfIndustry    agency2 = this.Empire.GetAgency <DepartmentOfIndustry>();

        if (this.CityLocation.IsValid && agency != null)
        {
            City closestCityFromWorldPosition = agency.GetClosestCityFromWorldPosition(this.CityLocation, true);
            if ((closestCityFromWorldPosition != null || closestCityFromWorldPosition.Empire == this.Empire) && agency2.GetConstructionQueue(closestCityFromWorldPosition).PendingConstructions.Count <= 0)
            {
                List <string> list = new List <string>
                {
                    "CityImprovementIndustry0",
                    "CityImprovementDust0",
                    "CityImprovementFood0",
                    "CityImprovementApproval1",
                    "CityImprovementScience0"
                };
                List <DepartmentOfIndustry.ConstructibleElement> list2 = new List <DepartmentOfIndustry.ConstructibleElement>();
                DepartmentOfIndustry.ConstructibleElement        constructibleElement = null;
                foreach (DepartmentOfIndustry.ConstructibleElement constructibleElement2 in agency2.ConstructibleElementDatabase.GetAvailableConstructibleElements(new StaticString[]
                {
                    CityImprovementDefinition.ReadOnlyCategory
                }))
                {
                    if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(closestCityFromWorldPosition, constructibleElement2, new string[]
                    {
                        ConstructionFlags.Prerequisite
                    }))
                    {
                        if (agency.Cities.Count == 1 && constructibleElement2.ToString().Contains("CityImprovementFIDS"))
                        {
                            constructibleElement = constructibleElement2;
                            break;
                        }
                        if (list.Contains(constructibleElement2.ToString()))
                        {
                            list2.Add(constructibleElement2);
                        }
                    }
                }
                if (constructibleElement == null && list2.Count > 0)
                {
                    using (List <string> .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            string important = enumerator.Current;
                            if (list2.Any((DepartmentOfIndustry.ConstructibleElement item) => item.Name == important))
                            {
                                constructibleElement = list2.First((DepartmentOfIndustry.ConstructibleElement item) => item.Name == important);
                                break;
                            }
                        }
                    }
                }
                if (constructibleElement != null)
                {
                    OrderQueueConstruction order = new OrderQueueConstruction(this.Empire.Index, closestCityFromWorldPosition.GUID, constructibleElement, string.Empty);
                    Ticket ticket;
                    this.Empire.PlayerControllers.AI.PostOrder(order, out ticket, null);
                }
            }
        }
    }
Example #9
0
    public void Refresh(global::Empire empire, DepartmentOfScience.ConstructibleElement.State state)
    {
        if (this.Button != null)
        {
            this.Button.AgeTransform.Enable = true;
        }
        TechnologyDefinitionVisibility visibility = this.TechnologyDefinition.Visibility;

        if (visibility != TechnologyDefinitionVisibility.VisibleWhenUnlocked)
        {
            if (visibility == TechnologyDefinitionVisibility.BasedOnPrerequisites)
            {
                bool flag = DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, this.TechnologyDefinition, new string[]
                {
                    "Visibility"
                });
                if (flag)
                {
                    this.AgeTransform.Visible = true;
                }
                else
                {
                    this.AgeTransform.Visible = false;
                }
            }
        }
        else
        {
            if (state != DepartmentOfScience.ConstructibleElement.State.Researched)
            {
                this.AgeTransform.Visible = false;
                return;
            }
            if (!this.AgeTransform.Visible)
            {
                this.AgeTransform.Visible = true;
                this.SetSimpleMode(false);
            }
        }
        this.UnlockDisabled.Visible = false;
        this.InProgressSector.AgeTransform.Visible = false;
        this.OrderCaption.AgeTransform.Visible     = false;
        DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>();
        bool flag2 = false;
        int  num   = 0;
        ConstructionQueue constructionQueueForTech = agency.GetConstructionQueueForTech(this.TechnologyDefinition);

        if ((state == DepartmentOfScience.ConstructibleElement.State.Queued || state == DepartmentOfScience.ConstructibleElement.State.InProgress) && constructionQueueForTech.Length > 1)
        {
            flag2 = true;
            if (state == DepartmentOfScience.ConstructibleElement.State.Queued)
            {
                for (int i = 0; i < constructionQueueForTech.Length; i++)
                {
                    DepartmentOfScience.ConstructibleElement constructibleElement = constructionQueueForTech.PeekAt(i).ConstructibleElement as DepartmentOfScience.ConstructibleElement;
                    if (constructibleElement.Name == this.TechnologyDefinition.Name)
                    {
                        num = i;
                        break;
                    }
                }
            }
        }
        bool  flag3 = this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Affinity) || this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Medal) || this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.Quest);
        bool  flag4 = this.TechnologyDefinition.HasTechnologyFlag(DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock);
        Color tintColor;
        Color tintColor2;
        Color tintColor3;
        Color tintColor4;

        switch (state)
        {
        case DepartmentOfScience.ConstructibleElement.State.Available:
            tintColor  = ((!flag4) ? this.AvailableColor : this.AvailableOrbUnlockColor);
            tintColor2 = ((!flag3) ? ((!flag4) ? this.AvailableBackdropColor : this.AvailableOrbUnlockBackdropColor) : this.AvailableBackdropColorAffinity);
            tintColor3 = this.AvailableSymbolColor;
            tintColor4 = this.GlowAvailableColor;
            break;

        case DepartmentOfScience.ConstructibleElement.State.Queued:
            tintColor  = this.QueuedColor;
            tintColor2 = ((!flag3) ? this.QueuedBackdropColor : this.QueuedBackdropColorAffinity);
            tintColor3 = this.QueuedSymbolColor;
            tintColor4 = this.GlowAvailableColor;
            this.OrderCaption.AgeTransform.Visible = true;
            this.OrderCaption.TintColor            = this.QueuedColor;
            this.OrderLabel.Text = (num + 1).ToString();
            break;

        case DepartmentOfScience.ConstructibleElement.State.InProgress:
            tintColor  = this.InProgressColor;
            tintColor2 = ((!flag3) ? this.InProgressBackdropColor : this.InProgressBackdropColorAffinity);
            tintColor3 = this.InProgressSymbolColor;
            tintColor4 = this.GlowAvailableColor;
            this.InProgressSector.AgeTransform.Visible = true;
            if (flag2)
            {
                this.OrderCaption.AgeTransform.Visible = true;
                this.OrderCaption.TintColor            = this.InProgressColor;
                this.OrderLabel.Text = (num + 1).ToString();
            }
            break;

        case DepartmentOfScience.ConstructibleElement.State.Researched:
            if (this.Button != null)
            {
                this.Button.AgeTransform.Enable = false;
            }
            tintColor  = ((!flag4) ? this.ResearchedColor : this.ResearchedOrbUnlockColor);
            tintColor2 = ((!flag3) ? this.ResearchedBackdropColor : this.ResearchedBackdropColorAffinity);
            tintColor3 = this.ResearchedSymbolColor;
            tintColor4 = this.GlowAvailableColor;
            break;

        case DepartmentOfScience.ConstructibleElement.State.ResearchedButUnavailable:
            if (this.Button != null)
            {
                this.Button.AgeTransform.Enable = false;
            }
            tintColor  = this.ResearchedButUnavailableColor;
            tintColor2 = ((!flag3) ? this.ResearchedBackdropColor : this.ResearchedBackdropColorAffinity);
            tintColor3 = this.ResearchedSymbolColor;
            tintColor4 = this.GlowNotAvailableColor;
            this.UnlockDisabled.Visible = true;
            break;

        default:
            tintColor  = this.NotAvailableColor;
            tintColor2 = ((!flag3) ? this.NotAvailableBackdropColor : this.NotAvailableBackdropColorAffinity);
            tintColor3 = this.NotAvailableSymbolColor;
            tintColor4 = this.GlowNotAvailableColor;
            if (this.Button != null)
            {
                this.Button.AgeTransform.Enable = false;
            }
            this.UnlockDisabled.Visible = true;
            break;
        }
        this.CircularFrame.TintColor           = tintColor;
        this.CaptionFullBackground.TintColor   = tintColor2;
        this.CaptionTopBackground.TintColor    = tintColor2;
        this.CaptionBottomBackground.TintColor = tintColor2;
        this.EraLabel.TintColor            = tintColor3;
        this.CategoryIcon.TintColor        = tintColor3;
        this.SubCategoryIcon.TintColor     = tintColor3;
        this.CategoryFullIcon.TintColor    = tintColor3;
        this.SubCategoryFullIcon.TintColor = tintColor3;
        this.GlowImage.TintColor           = tintColor4;
        this.RefreshCostGroup(state);
    }
Example #10
0
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        this.averageMaximumMovementPoint = 4f;
        AIEmpireData aiempireData;

        if (this.empireDataAIHelper.TryGet(base.AIEntity.Empire.Index, out aiempireData) && aiempireData.AverageUnitDesignMaximumMovement > 0f)
        {
            this.averageMaximumMovementPoint = aiempireData.AverageUnitDesignMaximumMovement;
            this.hasShips = aiempireData.HasShips;
        }
        this.numberOfLivingMajorEmpire = 0;
        global::Game game = this.gameService.Game as global::Game;

        for (int i = 0; i < game.Empires.Length; i++)
        {
            if (game.Empires[i] is MajorEmpire)
            {
                MajorEmpire majorEmpire = game.Empires[i] as MajorEmpire;
                if (!majorEmpire.IsEliminated)
                {
                    this.numberOfLivingMajorEmpire++;
                }
                if (i != base.AIEntity.Empire.Index)
                {
                    this.UpdateHarassingScore(majorEmpire);
                }
            }
        }
        this.UpdateCitiesDefenseScore();
        this.UpdateArmiesSupportScore();
        this.canCreateAnotherColossus = false;
        this.buildableColossusUnitDesignData.Clear();
        this.colossusUnitDesignData.Clear();
        this.unitDesignDataRepository.FillUnitDesignByTags(base.AIEntity.Empire.Index, ref this.colossusUnitDesignData, this.colossusTags);
        for (int j = 0; j < this.colossusUnitDesignData.Count; j++)
        {
            UnitDesign unitDesign;
            if (this.departmentOfDefense.UnitDesignDatabase.TryGetValue(this.colossusUnitDesignData[j].UnitDesignModel, out unitDesign, false) && DepartmentOfTheTreasury.CheckConstructiblePrerequisites(base.AIEntity.Empire, unitDesign, new string[]
            {
                ConstructionFlags.AIColossusPrerequisite
            }))
            {
                this.canCreateAnotherColossus = true;
                break;
            }
        }
        if (!this.canCreateAnotherColossus)
        {
            return;
        }
        for (int k = this.colossusUnitDesignData.Count - 1; k >= 0; k--)
        {
            UnitDesign unitDesign;
            if (this.departmentOfDefense.UnitDesignDatabase.TryGetValue(this.colossusUnitDesignData[k].UnitDesignModel, out unitDesign, false))
            {
                this.missingResources = this.departmentOfTheTreasury.GetConstructibleMissingRessources(base.AIEntity.Empire, unitDesign);
                if (this.missingResources != null && this.missingResources.Count > 0)
                {
                    float num = 0f;
                    for (int l = 0; l < this.missingResources.Count; l++)
                    {
                        num += this.missingResources[l].MissingResourceValue / this.missingResources[l].AskedResourceValue;
                    }
                    float num2 = 0f;
                    for (int m = 0; m < unitDesign.Costs.Length; m++)
                    {
                        if (unitDesign.Costs[m].Instant)
                        {
                            num2 += 1f;
                        }
                    }
                    num /= num2;
                    if (num >= 0.4f)
                    {
                        goto IL_30E;
                    }
                }
                this.buildableColossusUnitDesignData.Add(this.colossusUnitDesignData[k]);
            }
            IL_30E :;
        }
        if (this.buildableColossusUnitDesignData.Count == 0)
        {
            return;
        }
        float      num3        = 0f;
        UnitDesign unitDesign2 = null;

        for (int n = 0; n < this.buildableColossusUnitDesignData.Count; n++)
        {
            UnitDesign unitDesign;
            if (this.departmentOfDefense.UnitDesignDatabase.TryGetValue(this.buildableColossusUnitDesignData[n].UnitDesignModel, out unitDesign, false))
            {
                float num4 = this.ComputeColossusScore(this.buildableColossusUnitDesignData[n], unitDesign);
                if (num4 > num3)
                {
                    num3        = num4;
                    unitDesign2 = unitDesign;
                }
            }
        }
        if (unitDesign2 == null)
        {
            return;
        }
        EvaluableMessage_Colossus evaluableMessage_Colossus = base.AIEntity.AIPlayer.Blackboard.FindFirst <EvaluableMessage_Colossus>(BlackboardLayerID.Empire, (EvaluableMessage_Colossus match) => match.State != BlackboardMessage.StateValue.Message_Canceled || match.State != BlackboardMessage.StateValue.Message_Failed);

        if (evaluableMessage_Colossus != null)
        {
            if (evaluableMessage_Colossus.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending || evaluableMessage_Colossus.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending_MissingResource || evaluableMessage_Colossus.EvaluationState == EvaluableMessage.EvaluableMessageState.Validate)
            {
                evaluableMessage_Colossus.ResetState();
                evaluableMessage_Colossus.ResetUnitDesign(unitDesign2);
            }
            else if (evaluableMessage_Colossus.EvaluationState != EvaluableMessage.EvaluableMessageState.Obtaining)
            {
                evaluableMessage_Colossus = null;
            }
        }
        if (evaluableMessage_Colossus == null)
        {
            evaluableMessage_Colossus = new EvaluableMessage_Colossus(new HeuristicValue(0f), new HeuristicValue(0f), unitDesign2, -1, 1, AILayer_AccountManager.MilitaryAccountName);
            base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_Colossus);
        }
        float globalMotivation = this.ComputeGlobalPriority();
        float localOpportunity = this.ComputeLocalPriority();

        evaluableMessage_Colossus.Refresh(globalMotivation, localOpportunity);
        evaluableMessage_Colossus.TimeOut = 1;
    }
Example #11
0
    public static bool IsAbleToColonize(global::Empire empire)
    {
        ReadOnlyCollection <UnitBodyDefinition> availableUnitBodyDefinitions = ((IUnitDesignDatabase)empire.GetAgency <DepartmentOfDefense>()).AvailableUnitBodyDefinitions;

        for (int i = 0; i < availableUnitBodyDefinitions.Count; i++)
        {
            if (!availableUnitBodyDefinitions[i].Tags.Contains("Hidden") && (availableUnitBodyDefinitions[i].CheckUnitAbility(UnitAbility.ReadonlyColonize, -1) || availableUnitBodyDefinitions[i].CheckUnitAbility(UnitAbility.ReadonlyResettle, -1)) && DepartmentOfTheTreasury.CheckConstructiblePrerequisites(empire, availableUnitBodyDefinitions[i], new string[]
            {
                "Prerequisites"
            }))
            {
                return(true);
            }
        }
        return(false);
    }
Example #12
0
    protected override void EvaluateNeeds(StaticString context, StaticString pass)
    {
        base.EvaluateNeeds(context, pass);
        if (!this.CanUseAltar())
        {
            return;
        }
        if (!this.seasonService.IsAlive || this.seasonService.Target == null)
        {
            return;
        }
        Season winterSeason = this.seasonService.Target.GetWinterSeason();

        if (this.seasonService.Target.IsCurrentSeason(winterSeason))
        {
            return;
        }
        global::Game        game = Services.GetService <IGameService>().Game as global::Game;
        List <SeasonEffect> candidateEffectsForSeasonType = this.seasonService.Target.GetCandidateEffectsForSeasonType(Season.ReadOnlyWinter);

        Diagnostics.Assert(this.elementEvaluator != null);
        this.decisions.Clear();
        this.RegisterInterpreterContextData();
        if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools)
        {
            EvaluationData <SeasonEffect, InterpreterContext> evaluationData = new EvaluationData <SeasonEffect, InterpreterContext>();
            this.elementEvaluator.Evaluate(candidateEffectsForSeasonType, ref this.decisions, evaluationData);
            evaluationData.Turn = game.Turn;
            this.SeasonEffectsEvaluationDataHistoric.Add(evaluationData);
        }
        else
        {
            this.elementEvaluator.Evaluate(candidateEffectsForSeasonType, ref this.decisions, null);
        }
        if (this.decisions.Count <= 0)
        {
            return;
        }
        int num  = 0;
        int num2 = 0;

        for (int i = 0; i < candidateEffectsForSeasonType.Count; i++)
        {
            SeasonEffect seasonEffect = candidateEffectsForSeasonType[i];
            int          seasonEffectDisplayedScoreForEmpire = this.seasonService.Target.GetSeasonEffectDisplayedScoreForEmpire(base.AIEntity.Empire, seasonEffect);
            if (seasonEffectDisplayedScoreForEmpire > num)
            {
                num  = seasonEffectDisplayedScoreForEmpire;
                num2 = 1;
            }
            else if (seasonEffectDisplayedScoreForEmpire == num)
            {
                num2++;
            }
        }
        DecisionResult decisionResult = this.decisions[0];
        float          score          = decisionResult.Score;
        float          score2         = this.decisions[this.decisions.Count - 1].Score;
        float          num3           = score - score2;

        num3 = Mathf.Clamp01(num3 / this.maximumGainFromXml);
        SeasonEffect seasonEffect2 = decisionResult.Element as SeasonEffect;

        Diagnostics.Assert(seasonEffect2 != null);
        int seasonEffectScore = this.seasonService.Target.GetSeasonEffectScore(seasonEffect2);

        if (seasonEffectScore == num && num2 == 1)
        {
            return;
        }
        int neededVoteCount = num - seasonEffectScore + 1;
        List <EvaluableMessage_VoteForSeasonEffect> list = new List <EvaluableMessage_VoteForSeasonEffect>(base.AIEntity.AIPlayer.Blackboard.GetMessages <EvaluableMessage_VoteForSeasonEffect>(BlackboardLayerID.Empire, (EvaluableMessage_VoteForSeasonEffect message) => message.EvaluationState != EvaluableMessage.EvaluableMessageState.Obtained && message.EvaluationState != EvaluableMessage.EvaluableMessageState.Cancel));
        EvaluableMessage_VoteForSeasonEffect        evaluableMessage_VoteForSeasonEffect;

        if (list.Count == 0)
        {
            evaluableMessage_VoteForSeasonEffect = new EvaluableMessage_VoteForSeasonEffect(seasonEffect2.SeasonEffectDefinition.Name, 1, AILayer_AccountManager.OrbAccountName);
            base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_VoteForSeasonEffect);
        }
        else
        {
            evaluableMessage_VoteForSeasonEffect = list[0];
            if (seasonEffect2.SeasonEffectDefinition.Name != evaluableMessage_VoteForSeasonEffect.SeasonEffectReference)
            {
                Diagnostics.Log("AI don't want to vote for the season effect {0} anymore. AI now wants season effect {1}.", new object[]
                {
                    evaluableMessage_VoteForSeasonEffect.SeasonEffectReference,
                    seasonEffect2.SeasonEffectDefinition.Name
                });
                evaluableMessage_VoteForSeasonEffect.Cancel();
                evaluableMessage_VoteForSeasonEffect = new EvaluableMessage_VoteForSeasonEffect(seasonEffect2.SeasonEffectDefinition.Name, 1, AILayer_AccountManager.OrbAccountName);
                base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_VoteForSeasonEffect);
            }
        }
        float num4 = this.seasonService.Target.ComputePrayerOrbCost(base.AIEntity.Empire);
        float num5 = 10f * base.AIEntity.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier);
        int   num6 = this.seasonService.Target.GetExactSeasonStartTurn(winterSeason) - game.Turn;
        float num7 = Mathf.Clamp01((num5 - (float)num6) / num5);
        float num8 = num3 * (0.5f + num7 / 2f);

        num8 = Mathf.Clamp01(num8);
        int num9 = this.ComputeWantedNumberOfOrbs(neededVoteCount);
        DepartmentOfScience agency = base.AIEntity.Empire.GetAgency <DepartmentOfScience>();
        float num10 = 0f;
        float num11 = 0f;

        for (int j = 0; j < this.orbUnlockDefinitions.Length; j++)
        {
            TechnologyDefinition technologyDefinition = this.orbUnlockDefinitions[j];
            if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(base.AIEntity.Empire, technologyDefinition, new string[]
            {
                ConstructionFlags.Prerequisite
            }))
            {
                DepartmentOfScience.ConstructibleElement.State technologyState = agency.GetTechnologyState(technologyDefinition);
                if (technologyState != DepartmentOfScience.ConstructibleElement.State.Researched && technologyState != DepartmentOfScience.ConstructibleElement.State.NotAvailable)
                {
                    num11 += 1f;
                }
                else if (technologyState == DepartmentOfScience.ConstructibleElement.State.Researched)
                {
                    num10 += 1f;
                }
            }
        }
        float num12 = num11 / (num11 + num10);

        num12 = Mathf.Min(1f, Mathf.Max(0f, 2f * num12 - 0.6f));
        if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools)
        {
            Diagnostics.Log("[ELCP: AILayer_Altar] {0} has reasearched {1} of {2} Orb Techs", new object[]
            {
                base.AIEntity.Empire,
                num10,
                num11 + num10
            });
            Diagnostics.Log("... Season Effect Voting score altered from {0} to {1}", new object[]
            {
                num8,
                num8 * num12
            });
        }
        evaluableMessage_VoteForSeasonEffect.VoteCount = num9;
        evaluableMessage_VoteForSeasonEffect.Refresh(0.5f, num8 * num12, (float)num9 * num4, int.MaxValue);
    }
Example #13
0
    private float GenerateMessageScoreForIndustry()
    {
        float result = 0f;

        if (!AILayer_Colonization.IsAbleToColonize(base.AIEntity.Empire))
        {
            result = 1f;
        }
        else if (this.aiEntityCity.City.BesiegingEmpire == null && this.constructionQueue.PendingConstructions.Count > 0)
        {
            ConstructibleElement constructibleElement = this.constructionQueue.Peek().ConstructibleElement;
            if (constructibleElement != null && (constructibleElement.SubCategory == "SubCategoryWonder" || constructibleElement.SubCategory == "SubCategoryVictory"))
            {
                return(1f);
            }
        }
        else
        {
            float num = 0f;
            float num2;
            for (int i = 0; i < this.departmentOfTheInterior.Cities.Count; i++)
            {
                num2 = (float)this.departmentOfTheInterior.Cities[i].CityImprovements.Count;
                if (num2 > num)
                {
                    num = num2;
                }
            }
            num2 = (float)this.aiEntityCity.City.CityImprovements.Count;
            float num3 = 1f - num2 / num;
            float num4 = 0f;
            if (!this.departmentOfTheTreasury.TryGetNetResourceValue(this.aiEntityCity.City, "Production", out num4, false))
            {
                num4 = 0f;
            }
            if (num4 == 0f)
            {
                num4 = 1f;
            }
            bool  flag  = false;
            bool  flag2 = false;
            float num5  = 0f;
            if (!this.departmentOfTheTreasury.TryGetResourceStockValue(this.aiEntityCity.City, DepartmentOfTheTreasury.Resources.Production, out num5, false))
            {
                num5 = 0f;
            }
            num5 += this.aiEntityCity.City.GetPropertyValue(SimulationProperties.NetCityProduction);
            num5  = Math.Max(1f, num5);
            for (int j = 0; j < this.constructionQueue.Length; j++)
            {
                Construction construction = this.constructionQueue.PeekAt(j);
                if (DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.aiEntityCity.City, construction.ConstructibleElement, new string[]
                {
                    ConstructionFlags.Prerequisite
                }))
                {
                    if (!flag2)
                    {
                        float num6 = 0f;
                        for (int k = 0; k < construction.CurrentConstructionStock.Length; k++)
                        {
                            if (construction.CurrentConstructionStock[k].PropertyName == "Production")
                            {
                                num6 += construction.CurrentConstructionStock[k].Stock;
                                if (construction.IsBuyout)
                                {
                                    num6 = DepartmentOfTheTreasury.GetProductionCostWithBonus(this.aiEntityCity.City, construction.ConstructibleElement, "Production");
                                }
                            }
                        }
                        float num7 = DepartmentOfTheTreasury.GetProductionCostWithBonus(this.aiEntityCity.City, construction.ConstructibleElement, "Production") - num6;
                        num5 -= num7;
                        if (num5 < 0f && !construction.ConstructibleElementName.ToString().Contains("BoosterGenerator"))
                        {
                            flag  = true;
                            flag2 = true;
                        }
                        if (construction.ConstructibleElementName.ToString().Contains("BoosterGenerator"))
                        {
                            flag2 = true;
                        }
                    }
                    float num8 = 0f;
                    for (int l = 0; l < construction.CurrentConstructionStock.Length; l++)
                    {
                        if (construction.CurrentConstructionStock[l].PropertyName == "Production")
                        {
                            num8 += construction.CurrentConstructionStock[l].Stock;
                        }
                    }
                    float num9 = DepartmentOfTheTreasury.GetProductionCostWithBonus(this.aiEntityCity.City, construction.ConstructibleElement, "Production") - num8;
                    num3 = AILayer.Boost(num3, this.ComputeCostBoost(num9 / num4));
                }
            }
            if (this.aiEntityCity.City.BesiegingEmpire != null)
            {
                num3 = AILayer.Boost(num3, 0.5f);
            }
            if (!flag && !flag2)
            {
                flag = true;
            }
            if (!flag)
            {
                num3 = 0f;
            }
            result = num3;
        }
        return(result);
    }
 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);
 }
    protected override void RefreshLayerLabel()
    {
        if (!base.IsVisible)
        {
            return;
        }
        if (base.Empire == null || this.departmentOfTheInterior.MainCity == null)
        {
            return;
        }
        if (this.departmentOfTheInterior == null || this.departmentOfTheInterior.MainCity == null)
        {
            return;
        }
        this.validPointsOfInterest.Clear();
        this.validImprovements.Clear();
        if (this.departmentOfTheInterior.MainCity != null && base.Empire.SimulationObject.Tags.Contains("FactionTraitMimics1"))
        {
            List <StaticString> list = new List <StaticString>();
            CreepingNodeImprovementDefinition[] values = Databases.GetDatabase <CreepingNodeImprovementDefinition>(true).GetValues();
            if (this.entities == null)
            {
                this.entities = new List <IWorldEntityWithCulling>();
            }
            else
            {
                this.entities.Clear();
            }
            ReadOnlyCollection <IWorldEntityWithCulling> collection;
            if (base.WorldEntityCullingService.TryGetVisibleEntities <WorldPointOfInterest_QuestLocation>(out collection))
            {
                this.entities.AddRange(collection);
            }
            ReadOnlyCollection <IWorldEntityWithCulling> collection2;
            if (base.WorldEntityCullingService.TryGetVisibleEntities <WorldPointOfInterest>(out collection2))
            {
                this.entities.AddRange(collection2);
            }
            for (int i = 0; i < this.entities.Count; i++)
            {
                PointOfInterest pointOfInterest = (this.entities[i] as WorldPointOfInterest).PointOfInterest;
                Region          region          = base.WorldPositionningService.GetRegion(pointOfInterest.WorldPosition);
                int             num             = region.IsRegionColonized() ? 1 : 0;
                bool            flag            = region.Kaiju != null;
                bool            flag2           = region.BelongToEmpire(base.Empire);
                bool            flag3           = this.departmentOfCreepingNodes.POIIsOnCooldown(pointOfInterest.GUID);
                if (ELCPUtilities.UseELCPPeacefulCreepingNodes && !flag2 && region.Owner != null && region.Owner is MajorEmpire && pointOfInterest.Type == "QuestLocation")
                {
                    flag2 = (this.departmentOfForeignAffairs.IsFriend(region.Owner) && this.departmentOfForeignAffairs.CanMoveOn(region.Index, false));
                }
                bool flag4 = false;
                if (flag)
                {
                    flag4 = (region.Kaiju.IsWild() || region.Kaiju.OwnerEmpireIndex == base.Empire.Index);
                }
                if ((num == 0 || flag2 || (flag && flag4)) && !flag3)
                {
                    bool flag5 = this.IsPoiUnlocked(pointOfInterest);
                    if (pointOfInterest.CreepingNodeImprovement == null && (!(pointOfInterest.Type != "Village") || pointOfInterest.PointOfInterestImprovement == null) && ((base.WorldPositionningService.GetExplorationBits(pointOfInterest.WorldPosition) & base.Empire.Bits) > 0 && flag5))
                    {
                        List <CreepingNodeImprovementDefinition> list2 = new List <CreepingNodeImprovementDefinition>();
                        foreach (CreepingNodeImprovementDefinition creepingNodeImprovementDefinition in values)
                        {
                            if (creepingNodeImprovementDefinition.PointOfInterestTemplateName == pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName && (!(pointOfInterest.Type == "Village") || (pointOfInterest.SimulationObject.Tags.Contains(Village.PacifiedVillage) && !pointOfInterest.SimulationObject.Tags.Contains(Village.ConvertedVillage))))
                            {
                                list.Clear();
                                DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.departmentOfTheInterior.MainCity, creepingNodeImprovementDefinition, ref list, new string[]
                                {
                                    ConstructionFlags.Prerequisite
                                });
                                if (!list.Contains(ConstructionFlags.Discard) && this.departmentOfTheTreasury.CheckConstructibleInstantCosts(this.departmentOfTheInterior.MainCity, creepingNodeImprovementDefinition))
                                {
                                    CreepingNodeImprovementDefinition bestCreepingNodeDefinition = this.departmentOfCreepingNodes.GetBestCreepingNodeDefinition(this.departmentOfTheInterior.MainCity, pointOfInterest, creepingNodeImprovementDefinition, list);
                                    if (!list2.Contains(bestCreepingNodeDefinition))
                                    {
                                        list2.Add(bestCreepingNodeDefinition);
                                    }
                                }
                            }
                        }
                        if (list2.Count > 0)
                        {
                            for (int k = 0; k < list2.Count; k++)
                            {
                                this.validPointsOfInterest.Add(pointOfInterest);
                                this.validImprovements.Add(list2[k]);
                            }
                        }
                    }
                }
            }
        }
        this.LabelsTable.ReserveChildren(this.validPointsOfInterest.Count, this.LabelPrefab, "ConstructibleLabel");
        this.LabelsTable.RefreshChildrenIList <PointOfInterest>(this.validPointsOfInterest, new AgeTransform.RefreshTableItem <PointOfInterest>(this.RefreshPointOfInterest), true, false);
        Transform transform = this.cameraController.Camera.transform;
        List <CreepingNodeImprovementLabel> children = this.LabelsTable.GetChildren <CreepingNodeImprovementLabel>(true);

        for (int l = 0; l < children.Count; l++)
        {
            CreepingNodeImprovementLabel creepingNodeImprovementLabel = children[l];
            PointOfInterest pointOfInterest2 = creepingNodeImprovementLabel.CreepingNodeInfo.PointOfInterest;
            if (pointOfInterest2 != null)
            {
                List <int> list3 = new List <int>();
                for (int m = 0; m < this.validPointsOfInterest.Count; m++)
                {
                    if (this.validPointsOfInterest[m] == pointOfInterest2)
                    {
                        list3.Add(m);
                    }
                }
                int     num2   = list3.IndexOf(l);
                Vector3 vector = this.GlobalPositionningService.Get3DPosition(pointOfInterest2.WorldPosition);
                bool    flag6  = this.IsInsideCamera(this.cameraController.Camera, vector, creepingNodeImprovementLabel.Width, creepingNodeImprovementLabel.Height, 1f);
                creepingNodeImprovementLabel.AgeTransform.Visible = flag6;
                if (flag6)
                {
                    Vector3 lhs     = vector - transform.position;
                    Vector3 forward = transform.forward;
                    float   num3    = Vector3.Dot(lhs, forward);
                    float   num4    = 0.01f;
                    if (num3 < num4)
                    {
                        vector += forward * (num4 - num3);
                    }
                    Vector3 vector2 = this.cameraController.Camera.WorldToScreenPoint(vector);
                    Vector2 vector3 = new Vector3(vector2.x + ((float)num2 + (float)list3.Count * 0.5f * -1f) * creepingNodeImprovementLabel.Width, (float)Screen.height - vector2.y - this.LabelsTable.Y);
                    creepingNodeImprovementLabel.Foreground.TiltAngle = 0f;
                    if (vector3.x < 0f)
                    {
                        vector3.x  = 0f;
                        vector3.y += ((float)num2 + (float)list3.Count * 0.5f * -1f) * creepingNodeImprovementLabel.Height;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 270f;
                    }
                    if (vector3.x > this.LabelsTable.Width - creepingNodeImprovementLabel.Width)
                    {
                        vector3.x  = this.LabelsTable.Width - creepingNodeImprovementLabel.Width;
                        vector3.y += ((float)num2 + (float)list3.Count * 0.5f * -1f) * creepingNodeImprovementLabel.Height;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 90f;
                    }
                    if (vector3.y < 0f)
                    {
                        vector3.y = 0f;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 0f;
                    }
                    if (vector3.y > this.LabelsTable.Height - creepingNodeImprovementLabel.Height)
                    {
                        vector3.y = this.LabelsTable.Height - creepingNodeImprovementLabel.Height;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 180f;
                    }
                    creepingNodeImprovementLabel.AgeTransform.X = vector3.x;
                    creepingNodeImprovementLabel.AgeTransform.Y = vector3.y;
                }
            }
        }
        if (base.LabelLayer != null)
        {
            base.AgeTransform.Alpha = base.LabelLayer.Opacity;
        }
    }