コード例 #1
0
 private void ComputeGlobalPriority()
 {
     base.GlobalPriority.Reset();
     if (this.departmentOfTheInterior.Cities.Count == 0)
     {
         base.GlobalPriority.Subtract(1f, "We should focus on getting a city!", new object[0]);
     }
     else
     {
         AILayer_Strategy layer = base.AIEntity.GetLayer <AILayer_Strategy>();
         base.GlobalPriority.Add(layer.StrategicNetwork.GetAgentValue("Expansion"), "Expansion strategic network score", new object[0]);
         float num = 1f;
         if (this.kaijuAdquisitionFactor != 0f)
         {
             num = this.kaijuAdquisitionFactor;
         }
         base.GlobalPriority.Add(layer.StrategicNetwork.GetAgentValue("Expansion") * num, "Want war but not at war", new object[0]);
         if (this.aiLayerStrategy.IsAtWar())
         {
             base.GlobalPriority.Boost(0.4f, "At war", new object[0]);
         }
         else if (this.aiLayerStrategy.WantWarWithSomeone())
         {
             base.GlobalPriority.Boost(0.2f, "Want war but not at war", new object[0]);
         }
     }
 }
コード例 #2
0
    private void ComputeGlobalPriority()
    {
        base.GlobalPriority.Reset();
        if (this.departmentOfTheInterior.Cities.Count == 0)
        {
            base.GlobalPriority.Subtract(1f, "We should focus on getting a city!", new object[0]);
            return;
        }
        AILayer_Strategy layer = base.AIEntity.GetLayer <AILayer_Strategy>();

        base.GlobalPriority.Add(layer.StrategicNetwork.GetAgentValue("Expansion"), "Expansion strategic network score", new object[0]);
        if (this.aiLayerStrategy.IsAtWar())
        {
            base.GlobalPriority.Boost(-0.4f, "At war", new object[0]);
            return;
        }
        if (this.aiLayerStrategy.WantWarWithSomeone())
        {
            base.GlobalPriority.Boost(-0.2f, "Want war but not at war", new object[0]);
            return;
        }
        if (this.departmentOfTheInterior.Cities.Count >= 1)
        {
            base.GlobalPriority.Boost(0.4f, "I am sure you want to improve your cities", new object[0]);
        }
    }
コード例 #3
0
    private void ComputeObjectivePriority()
    {
        base.GlobalPriority.Reset();
        AILayer_Strategy layer = base.AIEntity.GetLayer <AILayer_Strategy>();

        base.GlobalPriority.Add(layer.StrategicNetwork.GetAgentValue("Pacification"), "Startegic network 'Pacification'", new object[0]);
        for (int i = 0; i < this.globalObjectiveMessages.Count; i++)
        {
            GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages[i];
            HeuristicValue         heuristicValue         = new HeuristicValue(0f);
            heuristicValue.Add(0.5f, "(constant)", new object[0]);
            Region region = this.worldPositionningService.GetRegion(globalObjectiveMessage.RegionIndex);
            if (region.City != null && region.City.Empire == base.AIEntity.Empire)
            {
                if (base.AIEntity.Empire.GetAgency <DepartmentOfForeignAffairs>().IsInWarWithSomeone())
                {
                    heuristicValue.Boost(0.5f, "At war", new object[0]);
                }
                if ((float)region.City.UnitsCount < (float)region.City.MaximumUnitSlot * 0.5f)
                {
                    heuristicValue.Boost(0.2f, "City defense low", new object[0]);
                }
            }
            globalObjectiveMessage.LocalPriority  = heuristicValue;
            globalObjectiveMessage.GlobalPriority = base.GlobalPriority;
            globalObjectiveMessage.TimeOut        = 1;
        }
    }
コード例 #4
0
    private void ComputeGlobalPriority()
    {
        base.GlobalPriority.Reset();
        if (this.departmentOfTheInterior.Cities.Count == 0)
        {
            base.GlobalPriority.Add(1f, "No more city!", new object[0]);
        }
        else
        {
            AILayer_Strategy layer = base.AIEntity.GetLayer <AILayer_Strategy>();
            base.GlobalPriority.Add(layer.StrategicNetwork.GetAgentValue("Expansion"), "Expansion strategic network score", new object[0]);
            if (this.aiLayerStrategy.IsAtWar() && this.CurrentSettlerCount < 2)
            {
                base.GlobalPriority.Boost(-0.5f, "At war", new object[0]);
            }
            else if (this.aiLayerStrategy.WantWarWithSomeone() && this.CurrentSettlerCount < 2)
            {
                base.GlobalPriority.Boost(-0.2f, "Want war but not at war", new object[0]);
            }
            else if (this.departmentOfTheInterior.Cities.Count == 1)
            {
                base.GlobalPriority.Boost(0.2f, "I am sure you want more than one city...", new object[0]);
            }
        }
        global::Game game = Services.GetService <IGameService>().Game as global::Game;

        if (!this.aiLayerStrategy.IsAtWar() && this.departmentOfTheInterior.Cities.Count < 5 && this.departmentOfTheInterior.Cities.Count * 20 < game.Turn && base.AIEntity.Empire.GetPropertyValue(SimulationProperties.NetEmpireApproval) > 70f)
        {
            float operand = Mathf.Min(1f, 0.04f * (float)(game.Turn - this.departmentOfTheInterior.Cities.Count * 20));
            base.GlobalPriority.Boost(operand, "low city count boost", new object[0]);
        }
    }
コード例 #5
0
    private void FillDecisionMakerVariables()
    {
        if (this.decisionMaker.Context == null)
        {
            return;
        }
        this.decisionMaker.Context.Register("GlobalWarNeed", this.aiLayerDiplomacy.GetGlobalWarNeed());
        this.decisionMaker.Context.Register("IndustryReferenceTurnCount", this.aiLayerResourceAmas.Amas.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.IndustryReferenceTurnCount));
        this.decisionMaker.Context.Register("TechnologyReferenceTurnCount", this.aiLayerResourceAmas.Amas.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.TechnologyReferenceTurnCount));
        this.decisionMaker.Context.Register("MoneyReferenceRatio", this.aiLayerResourceAmas.Amas.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.MoneyReferenceRatio));
        int num  = this.departmentOfScience.CurrentTechnologyEraNumber - 1;
        int num2 = 0;
        int num3 = 0;

        foreach (DepartmentOfScience.ConstructibleElement constructibleElement in this.departmentOfScience.TechnologyDatabase)
        {
            TechnologyDefinition technologyDefinition = constructibleElement as TechnologyDefinition;
            if (technologyDefinition != null)
            {
                int technologyEraNumber = DepartmentOfScience.GetTechnologyEraNumber(technologyDefinition);
                DepartmentOfScience.ConstructibleElement.State technologyState = this.departmentOfScience.GetTechnologyState(constructibleElement);
                if (technologyState == DepartmentOfScience.ConstructibleElement.State.Available)
                {
                    num3++;
                    if (technologyEraNumber < num)
                    {
                        num2++;
                    }
                }
            }
        }
        float num4 = 0f;

        if (num3 > 0)
        {
            num4 = (float)num2 / (float)num3;
        }
        this.decisionMaker.Context.Register("OldTechnologyRatio", num4);
        AILayer_Strategy layer      = base.AIEntity.GetLayer <AILayer_Strategy>();
        float            agentValue = layer.StrategicNetwork.GetAgentValue("Expansion");

        this.decisionMaker.Context.Register("ColonizationPriority", agentValue);
        DepartmentOfTheInterior agency = base.AIEntity.Empire.GetAgency <DepartmentOfTheInterior>();
        float num5 = 0f;

        if (agency.Cities.Count > 0)
        {
            for (int i = 0; i < agency.Cities.Count; i++)
            {
                AgentGroup cityAgentGroup = this.aiLayerResourceAmas.GetCityAgentGroup(agency.Cities[i]);
                if (cityAgentGroup != null)
                {
                    num5 += cityAgentGroup.GetAgentCriticityMaxIntensity(AILayer_ResourceAmas.AgentNames.PopulationReferenceTurnCount);
                }
            }
            num5 /= (float)agency.Cities.Count;
        }
        this.decisionMaker.Context.Register("PopulationReferenceTurnCount", num5);
    }
コード例 #6
0
    protected override void CreateLocalNeeds(StaticString context, StaticString pass)
    {
        base.CreateLocalNeeds(context, pass);
        AILayer_Strategy layer = base.AIEntity.GetLayer <AILayer_Strategy>();

        for (int i = 0; i < this.accounts.Count; i++)
        {
            this.accounts[i].CurrentProfitPercent = layer.GetScore(AILayer_Strategy.AccountManagerParameterModifier, this.accounts[i].AccountTag);
        }
        int[] array = this.accountIndexByResource[DepartmentOfTheTreasury.Resources.EmpirePoint];
        for (int j = 0; j < array.Length; j++)
        {
            this.ApplyExecutedMessages(this.accounts[array[j]]);
        }
        this.UpdateAccountBalance(DepartmentOfTheTreasury.Resources.EmpirePoint, array);
    }
コード例 #7
0
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        AILayer_Military layer = base.AIEntity.GetLayer <AILayer_Military>();

        base.GlobalPriority.Reset();
        AILayer_Strategy layer2 = base.AIEntity.GetLayer <AILayer_Strategy>();

        base.GlobalPriority.Add(layer2.StrategicNetwork.GetAgentValue("InternalMilitary"), "Strategic network 'InternalMilitary'", new object[0]);
        base.GlobalPriority.Boost(-0.5f, "Avoid patrol to be high", new object[0]);
        base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Patrol.ToString(), ref this.patrolObjectives);
        base.ValidateMessages(ref this.patrolObjectives);
        if (base.AIEntity.Empire is MajorEmpire)
        {
            MajorEmpire majorEmpire = base.AIEntity.Empire as MajorEmpire;
            for (int i = 0; i < majorEmpire.ConvertedVillages.Count; i++)
            {
                Village village = majorEmpire.ConvertedVillages[i];
                if (this.worldAtlasHelper.IsRegionExplored(base.AIEntity.Empire, village.Region, 0.95f))
                {
                    GlobalObjectiveMessage globalObjectiveMessage = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == village.Region.Index);
                    if (globalObjectiveMessage == null)
                    {
                        globalObjectiveMessage = base.GenerateObjective(village.Region.Index);
                        this.patrolObjectives.Add(globalObjectiveMessage);
                    }
                    globalObjectiveMessage.TimeOut        = 1;
                    globalObjectiveMessage.GlobalPriority = base.GlobalPriority;
                    HeuristicValue heuristicValue = new HeuristicValue(0f);
                    heuristicValue.Add(layer.GetVillageUnitPriority(village, village.StandardUnits.Count), "Village unit priority", new object[0]);
                    globalObjectiveMessage.LocalPriority = heuristicValue;
                }
            }
            for (int j = 0; j < majorEmpire.TamedKaijus.Count; j++)
            {
                Kaiju kaiju = majorEmpire.TamedKaijus[j];
                if (kaiju.OnGarrisonMode())
                {
                    GlobalObjectiveMessage globalObjectiveMessage2 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == kaiju.Region.Index);
                    if (globalObjectiveMessage2 == null)
                    {
                        globalObjectiveMessage2 = base.GenerateObjective(kaiju.Region.Index);
                        this.patrolObjectives.Add(globalObjectiveMessage2);
                    }
                    globalObjectiveMessage2.TimeOut        = 1;
                    globalObjectiveMessage2.GlobalPriority = base.GlobalPriority;
                    HeuristicValue heuristicValue2 = new HeuristicValue(0.6f);
                    AIRegionData   regionData      = this.worldAtlasHelper.GetRegionData(base.AIEntity.Empire.Index, kaiju.Region.Index);
                    if (regionData != null)
                    {
                        float operand = Mathf.Min(1f, 0.1f * (float)regionData.BorderWithNeutral + 0.2f * (float)regionData.BorderWithEnnemy);
                        heuristicValue2.Boost(operand, "Border with enemy!", new object[0]);
                    }
                    globalObjectiveMessage2.LocalPriority = heuristicValue2;
                }
            }
        }
        for (int k = 0; k < this.departmentOfTheInterior.Cities.Count; k++)
        {
            City city = this.departmentOfTheInterior.Cities[k];
            if (this.worldAtlasHelper.IsRegionExplored(base.AIEntity.Empire, city.Region, 0.8f))
            {
                GlobalObjectiveMessage globalObjectiveMessage3 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == city.Region.Index);
                if (globalObjectiveMessage3 == null)
                {
                    globalObjectiveMessage3 = base.GenerateObjective(city.Region.Index);
                    this.patrolObjectives.Add(globalObjectiveMessage3);
                }
                globalObjectiveMessage3.TimeOut        = 1;
                globalObjectiveMessage3.GlobalPriority = base.GlobalPriority;
                HeuristicValue heuristicValue3 = new HeuristicValue(0f);
                heuristicValue3.Add(AILayer_Military.GetCityDefenseLocalPriority(city, this.unitRatioBoost, 0), "City defense local priority", new object[0]);
                globalObjectiveMessage3.LocalPriority = heuristicValue3;
            }
        }
        if (base.AIEntity.Empire is MajorEmpire)
        {
            using (List <int> .Enumerator enumerator = this.questSolverLayer.QuestRegions.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    int regionIndex = enumerator.Current;
                    GlobalObjectiveMessage globalObjectiveMessage4 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex);
                    if (globalObjectiveMessage4 == null)
                    {
                        globalObjectiveMessage4 = base.GenerateObjective(regionIndex);
                        this.patrolObjectives.Add(globalObjectiveMessage4);
                    }
                    if (globalObjectiveMessage4 != null)
                    {
                        globalObjectiveMessage4.GlobalPriority.Value = 0.85f;
                        globalObjectiveMessage4.LocalPriority.Value  = 0.85f;
                    }
                }
            }
        }
        if (this.departmentOfForeignAffairs.IsInWarWithSomeone())
        {
            base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.WarPatrol.ToString(), ref this.warPatrolObjectives);
            base.ValidateMessages(ref this.warPatrolObjectives);
            if (base.AIEntity.Empire is MajorEmpire)
            {
                MajorEmpire majorEmpire2 = base.AIEntity.Empire as MajorEmpire;
                for (int l = 0; l < majorEmpire2.ConvertedVillages.Count; l++)
                {
                    Village village = majorEmpire2.ConvertedVillages[l];
                    GlobalObjectiveMessage globalObjectiveMessage5 = this.warPatrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == village.Region.Index);
                    if (globalObjectiveMessage5 == null)
                    {
                        globalObjectiveMessage5 = base.GenerateObjective(village.Region.Index);
                        globalObjectiveMessage5.ObjectiveType = AICommanderMissionDefinition.AICommanderCategory.WarPatrol.ToString();
                        this.warPatrolObjectives.Add(globalObjectiveMessage5);
                    }
                    globalObjectiveMessage5.TimeOut        = 1;
                    globalObjectiveMessage5.GlobalPriority = base.GlobalPriority;
                    HeuristicValue heuristicValue4 = new HeuristicValue(0f);
                    heuristicValue4.Add(layer.GetVillageUnitPriority(village, village.StandardUnits.Count), "Village unit priority", new object[0]);
                    globalObjectiveMessage5.LocalPriority = heuristicValue4;
                }
                for (int m = 0; m < majorEmpire2.TamedKaijus.Count; m++)
                {
                    Kaiju kaiju = majorEmpire2.TamedKaijus[m];
                    if (kaiju.OnGarrisonMode())
                    {
                        GlobalObjectiveMessage globalObjectiveMessage6 = this.warPatrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == kaiju.Region.Index);
                        if (globalObjectiveMessage6 == null)
                        {
                            globalObjectiveMessage6 = base.GenerateObjective(kaiju.Region.Index);
                            this.warPatrolObjectives.Add(globalObjectiveMessage6);
                        }
                        globalObjectiveMessage6.TimeOut        = 1;
                        globalObjectiveMessage6.GlobalPriority = base.GlobalPriority;
                        HeuristicValue heuristicValue5 = new HeuristicValue(0.8f);
                        AIRegionData   regionData2     = this.worldAtlasHelper.GetRegionData(base.AIEntity.Empire.Index, kaiju.Region.Index);
                        if (regionData2 != null)
                        {
                            float operand2 = Mathf.Min(1f, 0.2f * (float)regionData2.BorderWithNeutral + 0.3f * (float)regionData2.BorderWithEnnemy);
                            heuristicValue5.Boost(operand2, "Border with enemy!", new object[0]);
                        }
                        globalObjectiveMessage6.LocalPriority = heuristicValue5;
                    }
                }
            }
            for (int n = 0; n < this.departmentOfTheInterior.Cities.Count; n++)
            {
                City city = this.departmentOfTheInterior.Cities[n];
                GlobalObjectiveMessage globalObjectiveMessage7 = this.warPatrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == city.Region.Index);
                if (globalObjectiveMessage7 == null)
                {
                    globalObjectiveMessage7 = base.GenerateObjective(city.Region.Index);
                    globalObjectiveMessage7.ObjectiveType = AICommanderMissionDefinition.AICommanderCategory.WarPatrol.ToString();
                    this.warPatrolObjectives.Add(globalObjectiveMessage7);
                }
                globalObjectiveMessage7.TimeOut        = 1;
                globalObjectiveMessage7.GlobalPriority = base.GlobalPriority;
                HeuristicValue heuristicValue6 = new HeuristicValue(0f);
                heuristicValue6.Add(AILayer_Military.GetCityDefenseLocalPriority(city, this.unitRatioBoost, 0), "City defense local priority", new object[0]);
                if (this.worldAtlasHelper.GetRegionData(city.Empire.Index, city.Region.Index).BorderWithEnnemy > 0)
                {
                    heuristicValue6.Boost(0.2f, "Border with enemy!", new object[0]);
                }
                globalObjectiveMessage7.LocalPriority = heuristicValue6;
            }
            bool flag = false;
            for (int num = 0; num < this.warPatrolObjectives.Count; num++)
            {
                GlobalObjectiveMessage warPatrolObjective = this.warPatrolObjectives[num];
                if (base.AIEntity.GetCommanderProcessingTheNeededGlobalObjective(warPatrolObjective.ID) == null)
                {
                    GlobalObjectiveMessage globalObjectiveMessage8 = this.patrolObjectives.Find((GlobalObjectiveMessage match) => match.RegionIndex == warPatrolObjective.RegionIndex);
                    if (globalObjectiveMessage8 != null)
                    {
                        AICommander commanderProcessingTheNeededGlobalObjective = base.AIEntity.GetCommanderProcessingTheNeededGlobalObjective(globalObjectiveMessage8.ID);
                        if (commanderProcessingTheNeededGlobalObjective != null)
                        {
                            commanderProcessingTheNeededGlobalObjective.Release();
                            flag = true;
                        }
                    }
                }
            }
            if (flag)
            {
                base.AIEntity.KillAllCommanders("AICommander_Exploration");
            }
        }
    }
コード例 #8
0
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Defense.ToString(), ref this.globalObjectiveMessages);
        base.ValidateMessages(ref this.globalObjectiveMessages);
        AILayer_War layer = base.AIEntity.GetLayer <AILayer_War>();

        base.GlobalPriority.Reset();
        AILayer_Strategy layer2 = base.AIEntity.GetLayer <AILayer_Strategy>();

        base.GlobalPriority.Add(layer2.StrategicNetwork.GetAgentValue("InternalMilitary"), "Strategic Network 'InternalMilitary'", new object[0]);
        AILayer_ArmyManagement layer3 = base.AIEntity.GetLayer <AILayer_ArmyManagement>();
        float worldColonizationRatio  = this.worldAtlasHelper.GetWorldColonizationRatio(base.AIEntity.Empire);
        bool  flag     = layer.WantWarWithSomoeone() || layer.NumberOfWar > 0;
        City  mainCity = this.departmentOfTheInterior.MainCity;
        bool  flag2    = false;

        if (this.departmentOfTheInterior.NonInfectedCities.Count < 4)
        {
            List <IGarrison> list = new List <IGarrison>();
            list.AddRange(this.departmentOfDefense.Armies.ToList <Army>().FindAll((Army match) => !match.IsSeafaring && !match.IsSettler && match.UnitsCount > 3).Cast <IGarrison>());
            if (list.Count > 1)
            {
                flag2 = true;
            }
        }
        for (int i = 0; i < this.departmentOfTheInterior.Cities.Count; i++)
        {
            City city = this.departmentOfTheInterior.Cities[i];
            if (this.IsObjectiveValid(AICommanderMissionDefinition.AICommanderCategory.Defense.ToString(), city.Region.Index, true))
            {
                GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == city.Region.Index);
                if (globalObjectiveMessage == null)
                {
                    globalObjectiveMessage = base.GenerateObjective(city.Region.Index);
                    globalObjectiveMessage.LocalPriority = new HeuristicValue(0f);
                    this.globalObjectiveMessages.Add(globalObjectiveMessage);
                }
                globalObjectiveMessage.TimeOut = 1;
                globalObjectiveMessage.LocalPriority.Reset();
                if (flag2 && city == mainCity)
                {
                    bool flag3 = !AILayer_Military.AreaIsSave(city.WorldPosition, 15, this.departmentOfForeignAffairs, false, false);
                    if (!flag3)
                    {
                        foreach (Region region in this.worldPositionningService.GetNeighbourRegions(city.Region, false, false))
                        {
                            if (region.IsLand && region.Owner is MajorEmpire)
                            {
                                DiplomaticRelation diplomaticRelation = this.departmentOfForeignAffairs.GetDiplomaticRelation(region.Owner);
                                if (diplomaticRelation.State.Name == DiplomaticRelationState.Names.War || diplomaticRelation.State.Name == DiplomaticRelationState.Names.ColdWar || diplomaticRelation.State.Name == DiplomaticRelationState.Names.Truce)
                                {
                                    flag3 = true;
                                    break;
                                }
                            }
                        }
                    }
                    if (flag3)
                    {
                        globalObjectiveMessage.LocalPriority  = new HeuristicValue(1f);
                        globalObjectiveMessage.GlobalPriority = new HeuristicValue(1f);
                    }
                }
                else
                {
                    globalObjectiveMessage.GlobalPriority = base.GlobalPriority;
                    AICommanderWithObjective aicommanderWithObjective = layer3.FindCommander(globalObjectiveMessage);
                    if (aicommanderWithObjective != null && aicommanderWithObjective is AICommander_Defense)
                    {
                        AICommander_Defense aicommander_Defense = aicommanderWithObjective as AICommander_Defense;
                        globalObjectiveMessage.LocalPriority.Add(AILayer_Military.GetCityDefenseLocalPriority(city, this.unitRatioBoost, aicommander_Defense.ComputeCurrentUnitInDefense()), "CityDefenseLocalPriority", new object[0]);
                    }
                    else
                    {
                        globalObjectiveMessage.LocalPriority.Add(AILayer_Military.GetCityDefenseLocalPriority(city, this.unitRatioBoost, -1), "CityDefenseLocalPriority", new object[0]);
                    }
                    HeuristicValue heuristicValue = new HeuristicValue(0f);
                    heuristicValue.Add(worldColonizationRatio, "colonization ratio", new object[0]);
                    heuristicValue.Multiply(0.2f, "(constant)", new object[0]);
                    globalObjectiveMessage.LocalPriority.Boost(heuristicValue, "Colonization boost", new object[0]);
                    if (flag)
                    {
                        globalObjectiveMessage.LocalPriority.Boost(0.3f, "Want war", new object[0]);
                    }
                    AIData_City aidata_City;
                    if (this.aiDataRepositoryAIHelper.TryGetAIData <AIData_City>(city.GUID, out aidata_City) && aidata_City.IsAtWarBorder)
                    {
                        globalObjectiveMessage.LocalPriority.Boost(0.3f, "War border", new object[0]);
                    }
                    if ((float)this.endTurnService.Turn < this.unitInGarrisonTurnLimit)
                    {
                        globalObjectiveMessage.LocalPriority.Boost(-0.3f, "turn under 'unitInGarrisonTurnLimit' ({0})", new object[]
                        {
                            this.unitInGarrisonTurnLimit
                        });
                    }
                }
            }
        }
        MajorEmpire majorEmpire = base.AIEntity.Empire as MajorEmpire;

        if (majorEmpire == null || majorEmpire.ConvertedVillages.Count == 0)
        {
            return;
        }
        if (mainCity == null)
        {
            return;
        }
        float num = AILayer_Military.GetCityDefenseLocalPriority(mainCity, this.unitRatioBoost, AICommanderMission_Garrison.SimulatedUnitsCount);

        num *= this.villageDefenseRatioDeboost;
        num *= base.GlobalPriority;
        for (int k = 0; k < this.VillageDOFPriority.Count; k++)
        {
            this.VillageDOFPriority[k].Reset();
        }
        float num2 = 0f;

        for (int l = 0; l < majorEmpire.ConvertedVillages.Count; l++)
        {
            Village village = majorEmpire.ConvertedVillages[l];
            AILayer_Military.VillageDefensePriority villageDefensePriority = this.VillageDOFPriority.Find((AILayer_Military.VillageDefensePriority match) => match.Village.GUID == village.GUID);
            if (villageDefensePriority == null)
            {
                villageDefensePriority = new AILayer_Military.VillageDefensePriority();
                villageDefensePriority.Reset();
                villageDefensePriority.Village = village;
                this.VillageDOFPriority.Add(villageDefensePriority);
            }
            villageDefensePriority.ToDelete          = false;
            villageDefensePriority.FirstUnitPriority = num;
            float num3 = (float)this.worldPositionningService.GetDistance(village.WorldPosition, mainCity.WorldPosition);
            villageDefensePriority.DistanceToMainCity = num3;
            if (num3 > num2)
            {
                num2 = num3;
            }
        }
        for (int m = this.VillageDOFPriority.Count - 1; m >= 0; m--)
        {
            AILayer_Military.VillageDefensePriority villageDefensePriority2 = this.VillageDOFPriority[m];
            if (villageDefensePriority2.ToDelete)
            {
                this.VillageDOFPriority.Remove(villageDefensePriority2);
            }
            else
            {
                float num4 = villageDefensePriority2.DistanceToMainCity / num2;
                if (majorEmpire.ConvertedVillages.Count > 1)
                {
                    villageDefensePriority2.FirstUnitPriority = AILayer.Boost(villageDefensePriority2.FirstUnitPriority, num4 * -0.1f);
                }
            }
        }
    }