private void CreateObjectiveFor(int regionIndex)
    {
        GlobalObjectiveMessage globalObjectiveMessage = base.GenerateObjective(regionIndex);

        this.globalObjectiveMessages.Add(globalObjectiveMessage);
        this.RefreshMessagePriority(globalObjectiveMessage);
    }
Example #2
0
    private void CreateObjectiveFor(int regionIndex, Kaiju kaiju)
    {
        GlobalObjectiveMessage globalObjectiveMessage = base.GenerateObjective(base.ObjectiveType, regionIndex, kaiju.GUID);

        this.globalObjectiveMessages.Add(globalObjectiveMessage);
        this.RefreshMessagePriority(globalObjectiveMessage);
    }
    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;
        }
    }
Example #4
0
    private GlobalObjectiveMessage CreateObjectiveFor(int regionIndex, IGameEntity pointOfInterest, StaticString questname)
    {
        GlobalObjectiveMessage globalObjectiveMessage = base.GenerateObjective(base.ObjectiveType, regionIndex, pointOfInterest.GUID);

        globalObjectiveMessage.ObjectiveState = questname;
        this.globalObjectiveMessages.Add(globalObjectiveMessage);
        return(globalObjectiveMessage);
    }
 protected override bool IsObjectiveValid(GlobalObjectiveMessage objective)
 {
     if (objective.ObjectiveType == base.ObjectiveType)
     {
         Region region = this.worldPositionningService.GetRegion(objective.RegionIndex);
         return(region.City != null && region.City.Empire.Index == base.AIEntity.Empire.Index && this.GetTerrainToTerraformInRegion(region) != 0 && objective.State != BlackboardMessage.StateValue.Message_Canceled);
     }
     return(false);
 }
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        this.FillUpRegions();
        this.opportunityPositions.Clear();
        foreach (Region region in this.regions)
        {
            WorldPosition worldPosition = this.SelectPositionToTerraform(region);
            if (worldPosition.IsValid)
            {
                if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools)
                {
                    Diagnostics.Log("ELCP {0} AILayer_Terraformation adding opportunity position in {1} at {2}", new object[]
                    {
                        base.AIEntity.Empire,
                        region.LocalizedName,
                        worldPosition
                    });
                }
                this.opportunityPositions.Add(region.Index, worldPosition);
            }
        }
        this.ComputeGlobalPriority();
        base.GatherObjectives(base.ObjectiveType, false, ref this.globalObjectiveMessages);
        base.ValidateMessages(ref this.globalObjectiveMessages);
        for (int i = 0; i < this.globalObjectiveMessages.Count; i++)
        {
            GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages[i];
            this.RefreshMessagePriority(globalObjectiveMessage);
            this.regions.Remove(this.worldPositionningService.GetRegion(globalObjectiveMessage.RegionIndex));
        }
        int num = (int)base.AIEntity.Empire.GetPropertyValue(SimulationProperties.LavapoolStock);

        for (int j = 0; j < this.globalObjectiveMessages.Count; j++)
        {
            num--;
        }
        if (num > 0 && this.regions.Count > 0)
        {
            for (int k = num; k > 0; k--)
            {
                if (this.globalObjectiveMessages.Count < 5)
                {
                    int nextTerraformationRegionIndex = this.GetNextTerraformationRegionIndex();
                    if (nextTerraformationRegionIndex != -1)
                    {
                        this.CreateObjectiveFor(nextTerraformationRegionIndex);
                    }
                }
            }
        }
    }
    private void ComputeObjectivePriority()
    {
        bool flag = false;

        if (this.departmentOfForeignAffairs.IsInWarWithSomeone())
        {
            flag = true;
        }
        else
        {
            foreach (City city in this.departmentOfTheInterior.Cities)
            {
                if (!this.worldAtlasAIHelper.IsRegionPacified(base.AIEntity.Empire, city.Region) || city.BesiegingEmpireIndex >= 0)
                {
                    flag = true;
                    break;
                }
            }
        }
        base.GlobalPriority.Reset();
        base.GlobalPriority.Add(0.1f, "(constant)", new object[0]);
        AILayer_Colonization layer = base.AIEntity.GetLayer <AILayer_Colonization>();

        for (int i = 0; i < this.globalObjectiveMessages.Count; i++)
        {
            GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages[i];
            HeuristicValue         heuristicValue         = new HeuristicValue(0f);
            heuristicValue.Add(layer.GetColonizationInterest(globalObjectiveMessage.RegionIndex), "Region colo interest", new object[0]);
            if (this.departmentOfCreepingNodes != null)
            {
                if (this.departmentOfCreepingNodes.Nodes.Any((CreepingNode CN) => CN.Region.Index == globalObjectiveMessage.RegionIndex))
                {
                    heuristicValue.Boost(1f, "bloom in region", new object[0]);
                }
                else if (this.departmentOfCreepingNodes.Nodes.Count > 0)
                {
                    heuristicValue.Max(0.5f, "bloom in region", new object[0]);
                }
            }
            heuristicValue.Multiply(0.1f, "(constant)", new object[0]);
            globalObjectiveMessage.LocalPriority  = heuristicValue;
            globalObjectiveMessage.GlobalPriority = base.GlobalPriority;
            if (i < 1 && !flag && base.AIEntity.Empire.GetAgency <DepartmentOfDefense>().Armies.Count > 2)
            {
                globalObjectiveMessage.LocalPriority.Boost(0.75f, "(constant)", new object[0]);
                globalObjectiveMessage.GlobalPriority.Boost(0.75f, "(constant)", new object[0]);
            }
            globalObjectiveMessage.TimeOut = 1;
        }
    }
Example #8
0
    private void RefreshMessagePriority(GlobalObjectiveMessage objectiveMessage)
    {
        HeuristicValue heuristicValue  = new HeuristicValue(1f);
        HeuristicValue heuristicValue2 = new HeuristicValue(1f);
        float          value;

        if (this.messagePriorityOverrides.TryGetValue(objectiveMessage.SubObjectifGUID, out value))
        {
            heuristicValue.Value  = value;
            heuristicValue2.Value = 0.7f;
        }
        objectiveMessage.GlobalPriority = heuristicValue2;
        objectiveMessage.LocalPriority  = heuristicValue;
        objectiveMessage.TimeOut        = 1;
    }
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        Diagnostics.Assert(Services.GetService <IGameService>() != null);
        base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Exploration.ToString(), ref this.globalObjectiveMessages);
        this.regionToExplore.Clear();
        if (!this.TrySelectRegionToExplore(base.AIEntity.Empire, ref this.regionToExplore) && this.departmentOfTheInterior.Cities.Count == 0)
        {
            int num = -9;
            for (int i = 0; i < this.departmentOfDefense.Armies.Count; i++)
            {
                if (this.departmentOfDefense.Armies[i].StandardUnits != null)
                {
                    if (this.departmentOfDefense.Armies[i].StandardUnits.ToList <Unit>().Exists((Unit U) => !U.IsSettler))
                    {
                        Region region = this.worldPositionningService.GetRegion(this.departmentOfDefense.Armies[i].WorldPosition);
                        num = ((num < 0) ? region.ContinentID : num);
                        this.regionToExplore.AddOnce(region);
                        for (int j = 0; j < region.Borders.Length; j++)
                        {
                            Region region2 = this.worldPositionningService.World.Regions[region.Borders[j].NeighbourRegionIndex];
                            if (region2.IsLand && region2.City == null && region2.ContinentID == num)
                            {
                                this.regionToExplore.AddOnce(region2);
                            }
                        }
                    }
                }
            }
        }
        base.ValidateMessages(ref this.globalObjectiveMessages);
        int index;
        int index2;

        for (index = 0; index < this.regionToExplore.Count; index = index2 + 1)
        {
            if (AILayer_Exploration.IsRegionValidForExploration(base.AIEntity.Empire, this.regionToExplore[index].Index) && this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == this.regionToExplore[index].Index) == null)
            {
                GlobalObjectiveMessage item = base.GenerateObjective(this.regionToExplore[index].Index);
                this.globalObjectiveMessages.Add(item);
            }
            index2 = index;
        }
        this.ComputeObjectivePriority();
    }
Example #10
0
 private void RefreshMessagePriority(GlobalObjectiveMessage objectiveMessage)
 {
     objectiveMessage.GlobalPriority = base.GlobalPriority;
     if (this.departmentOfTheInterior.Cities.Count == 0)
     {
         objectiveMessage.LocalPriority = new HeuristicValue(1f);
     }
     else
     {
         objectiveMessage.LocalPriority = new HeuristicValue(0.8f);
         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));
             objectiveMessage.LocalPriority.Boost(operand, "low city count boost", new object[0]);
         }
     }
     objectiveMessage.TimeOut = 1;
 }
Example #11
0
    protected override bool IsObjectiveValid(GlobalObjectiveMessage objective)
    {
        if (!(objective.ObjectiveType == base.ObjectiveType))
        {
            return(false);
        }
        ArmyAction             armyAction = null;
        IDatabase <ArmyAction> database   = Databases.GetDatabase <ArmyAction>(false);

        if (database == null || !database.TryGetValue("ArmyActionTameKaiju", out armyAction))
        {
            return(false);
        }
        if (!Amplitude.Unity.Runtime.Runtime.Registry.GetValue <bool>("Gameplay/Kaiju/KaijuAutoTameBeforeLoseEncounter", true) && !armyAction.CanAfford(base.AIEntity.Empire))
        {
            return(false);
        }
        Region region = this.worldPositionningService.GetRegion(objective.RegionIndex);
        Kaiju  kaiju  = region.Kaiju;

        return(kaiju != null && this.IsKaijuValidForObjective(kaiju) && !(kaiju.GUID != objective.SubObjectifGUID) && objective.State != BlackboardMessage.StateValue.Message_Canceled);
    }
Example #12
0
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        base.GatherObjectives(base.ObjectiveType, true, ref this.globalObjectiveMessages);
        base.ValidateMessages(ref this.globalObjectiveMessages);
        List <Kaiju> filterKaijuTargets = this.GetFilterKaijuTargets(this.huntTamedKaijus);

        this.ComputeGlobalPriority();
        for (int i = 0; i < filterKaijuTargets.Count; i++)
        {
            Kaiju kaiju = filterKaijuTargets[i];
            if (this.IsKaijuValidForObjective(kaiju))
            {
                Region region = this.worldPositionningService.GetRegion(kaiju.WorldPosition);
                GlobalObjectiveMessage globalObjectiveMessage = base.AIEntity.AIPlayer.Blackboard.FindFirst <GlobalObjectiveMessage>(BlackboardLayerID.Empire, (GlobalObjectiveMessage match) => match.State != BlackboardMessage.StateValue.Message_Canceled && match.RegionIndex == region.Index && match.SubObjectifGUID == kaiju.GUID && match.ObjectiveType == this.ObjectiveType);
                if (globalObjectiveMessage == null)
                {
                    globalObjectiveMessage = base.GenerateObjective(base.ObjectiveType, region.Index, kaiju.GUID);
                }
                this.RefreshMessagePriority(globalObjectiveMessage);
            }
        }
    }
 protected override void RefreshObjectives(StaticString context, StaticString pass)
 {
     this.SiegeBreakerArmyAssignations.Clear();
     base.RefreshObjectives(context, pass);
     base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.SiegeBreaker.ToString(), ref this.globalObjectiveMessages);
     base.ValidateMessages(ref this.globalObjectiveMessages);
     for (int i = 0; i < this.departmentOfTheInterior.Cities.Count; i++)
     {
         City city = this.departmentOfTheInterior.Cities[i];
         if (city.BesiegingEmpire != null && this.IsObjectiveValid(AICommanderMissionDefinition.AICommanderCategory.SiegeBreaker.ToString(), city.Region.Index, false) && this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == city.Region.Index) == null)
         {
             GlobalObjectiveMessage item = base.GenerateObjective(this.departmentOfTheInterior.Cities[i].Region.Index);
             this.globalObjectiveMessages.Add(item);
         }
     }
     for (int j = 0; j < this.departmentOfTheInterior.Cities.Count; j++)
     {
         if (this.globalObjectiveMessages.Count + 2 > base.AIEntity.Empire.GetAgency <DepartmentOfDefense>().Armies.Count)
         {
             break;
         }
         City city2 = this.departmentOfTheInterior.Cities[j];
         if (city2.BesiegingEmpire != null && this.IsObjectiveValid(AICommanderMissionDefinition.AICommanderCategory.SiegeBreaker.ToString(), city2.Region.Index, false))
         {
             int num  = Intelligence.GetArmiesInRegion(city2.Region.Index).Count((Army p) => p.Empire == city2.BesiegingEmpire);
             int num2 = this.globalObjectiveMessages.Count((GlobalObjectiveMessage p) => p.RegionIndex == city2.Region.Index);
             while (num2 <= num + 2 && this.globalObjectiveMessages.Count + 2 <= base.AIEntity.Empire.GetAgency <DepartmentOfDefense>().Armies.Count)
             {
                 GlobalObjectiveMessage item2 = base.GenerateObjective(this.departmentOfTheInterior.Cities[j].Region.Index);
                 this.globalObjectiveMessages.Add(item2);
                 num2++;
             }
         }
     }
     this.ComputeObjectivePriority();
     this.globalObjectiveMessages.Sort((GlobalObjectiveMessage left, GlobalObjectiveMessage right) => - 1 * left.LocalPriority.CompareTo(right.LocalPriority));
 }
 private void RefreshMessagePriority(GlobalObjectiveMessage objectiveMessage)
 {
     objectiveMessage.GlobalPriority = base.GlobalPriority;
     objectiveMessage.LocalPriority  = new HeuristicValue(0.6f);
     objectiveMessage.TimeOut        = 1;
 }
Example #15
0
 protected override bool IsObjectiveValid(GlobalObjectiveMessage objective)
 {
     AILayer_QuestBTController.QuestBTOrder questBTOrder;
     return(!(objective.ObjectiveType != base.ObjectiveType) && objective.SubObjectifGUID.IsValid && this.TryGetQuestBTOrder(objective.ObjectiveState, objective.SubObjectifGUID, out questBTOrder) && this.questManagementService.IsQuestRunningForEmpire(objective.ObjectiveState, base.AIEntity.Empire) && this.TargetIsReachable(objective.SubObjectifGUID));
 }
Example #16
0
    private void RefreshMessagePriority(GlobalObjectiveMessage objectiveMessage)
    {
        objectiveMessage.GlobalPriority = base.GlobalPriority;
        objectiveMessage.LocalPriority  = new HeuristicValue(0.35f);
        List <int> list = new List <int>();

        if (!DepartmentOfTheInterior.CanNeverDeclareWar(base.AIEntity.Empire) || this.departmentOfForeignAffairs.IsInWarWithSomeone())
        {
            foreach (AICommander aicommander in this.aILayer_ArmyManagement.AICommanders)
            {
                AICommander_WarWithObjective aicommander_WarWithObjective = aicommander as AICommander_WarWithObjective;
                if (aicommander_WarWithObjective != null)
                {
                    Region region = this.worldPositionningService.GetRegion(aicommander_WarWithObjective.RegionIndex);
                    if (region.Owner != null && region.Owner.Index != base.AIEntity.Empire.Index)
                    {
                        list.Add(region.Owner.Index);
                    }
                }
            }
        }
        if (list.Count == 0)
        {
            objectiveMessage.LocalPriority.Boost(0.4f, "NoWarBoost", new object[0]);
        }
        Region region2 = this.worldPositionningService.GetRegion(objectiveMessage.RegionIndex);

        if (region2.Kaiju != null && region2.Kaiju.IsTamed() && list.Contains(region2.Kaiju.OwnerEmpireIndex) && this.departmentOfForeignAffairs.IsAtWarWith(region2.Kaiju.MajorEmpire))
        {
            objectiveMessage.LocalPriority.Boost(0.2f, "At war boost", new object[0]);
        }
        if (region2 != null && region2.Kaiju != null && this.departmentOfTheInterior.Cities.Count > 0)
        {
            int num = int.MaxValue;
            foreach (City city in this.departmentOfTheInterior.Cities)
            {
                int distance = this.worldPositionningService.GetDistance(city.WorldPosition, region2.Kaiju.WorldPosition);
                if (distance < num)
                {
                    num = distance;
                }
            }
            if (this.departmentOfCreepingNodes != null)
            {
                foreach (CreepingNode creepingNode in this.departmentOfCreepingNodes.Nodes)
                {
                    if (creepingNode.Region.Index == region2.Index && !creepingNode.IsUnderConstruction && AILayer_Exploration.IsTravelAllowedInNode(base.AIEntity.Empire, creepingNode))
                    {
                        int distance2 = this.worldPositionningService.GetDistance(creepingNode.WorldPosition, region2.Kaiju.WorldPosition);
                        if (distance2 < num)
                        {
                            num = distance2;
                        }
                    }
                }
            }
            num = Mathf.Max(30 - num, 0);
            objectiveMessage.LocalPriority.Boost((float)num / 60f, "Close distance boost", new object[0]);
        }
        if (list.Count > 0 && !this.departmentOfForeignAffairs.IsInWarWithSomeone() && this.aiLayerStrategy.WantWarWithSomeone() && region2.Kaiju != null && region2.Kaiju.IsTamed() && (region2.Owner == null || region2.Owner.Index != base.AIEntity.Empire.Index) && !list.Contains(region2.Kaiju.OwnerEmpireIndex))
        {
            objectiveMessage.LocalPriority.Boost(-0.6f, "Not our target!", new object[0]);
        }
        objectiveMessage.TimeOut = 1;
    }
Example #17
0
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        base.GatherObjectives(base.ObjectiveType, true, ref this.globalObjectiveMessages);
        base.ValidateMessages(ref this.globalObjectiveMessages);
        this.messagePriorityOverrides.Clear();
        this.resourcesNeededForQuest.Clear();
        if (this.departmentOfTheInterior.Cities.Count == 0)
        {
            return;
        }
        List <StaticString> list = new List <StaticString>();

        using (List <AILayer_QuestBTController.QuestBTOrder> .Enumerator enumerator = this.QuestBTOrders.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                AILayer_QuestBTController.QuestBTOrder order = enumerator.Current;
                if (!list.Contains(order.questName))
                {
                    List <AILayer_QuestBTController.QuestBTOrder> list2 = this.QuestBTOrders.FindAll((AILayer_QuestBTController.QuestBTOrder q) => q.questName == order.questName);
                    if (list2.Count > 1)
                    {
                        list.Add(order.questName);
                        int num  = int.MaxValue;
                        int num2 = 0;
                        int num3 = -1;
                        for (int k = 0; k < list2.Count; k++)
                        {
                            IGameEntity gameEntity;
                            if (this.gameEntityRepositoryService.TryGetValue <IGameEntity>(list2[k].objectiveGUID, out gameEntity))
                            {
                                int distance = this.worldPositionningService.GetDistance(this.departmentOfTheInterior.Cities[0].WorldPosition, (gameEntity as IWorldPositionable).WorldPosition);
                                if (distance < num)
                                {
                                    num  = distance;
                                    num3 = k;
                                }
                                if (distance > num2)
                                {
                                    num2 = distance;
                                }
                            }
                        }
                        num2 -= num;
                        for (int j = 0; j < list2.Count; j++)
                        {
                            IGameEntity gameEntity2;
                            if (j != num3 && this.gameEntityRepositoryService.TryGetValue <IGameEntity>(list2[j].objectiveGUID, out gameEntity2))
                            {
                                int num4 = this.worldPositionningService.GetDistance(this.departmentOfTheInterior.Cities[0].WorldPosition, (gameEntity2 as IWorldPositionable).WorldPosition);
                                num4 -= num;
                                float num5 = 1f - (float)(num4 / num2);
                                num5 = Math.Max(num5, 0.3f);
                                this.messagePriorityOverrides.Add(list2[j].objectiveGUID, num5 / 1.25f);
                            }
                        }
                    }
                }
            }
        }
        int i;

        Predicate <GlobalObjectiveMessage> < > 9__1;
        int i2;

        for (i = this.QuestBTOrders.Count - 1; i >= 0; i = i2 - 1)
        {
            bool flag = this.QuestBTOrders[i].resourceNeeded == StaticString.Empty;
            if (!flag)
            {
                float num6;
                this.departmentOfTheTreasury.TryGetResourceStockValue(base.AIEntity.Empire.SimulationObject, this.QuestBTOrders[i].resourceNeeded, out num6, false);
                flag = (num6 >= (float)this.QuestBTOrders[i].resourceNeededAmount);
                if (this.resourcesNeededForQuest.ContainsKey(this.QuestBTOrders[i].resourceNeeded))
                {
                    Dictionary <StaticString, float> dictionary = this.resourcesNeededForQuest;
                    StaticString resourceNeeded = this.QuestBTOrders[i].resourceNeeded;
                    dictionary[resourceNeeded] += (float)this.QuestBTOrders[i].resourceNeededAmount;
                }
                else
                {
                    this.resourcesNeededForQuest.Add(this.QuestBTOrders[i].resourceNeeded, (float)this.QuestBTOrders[i].resourceNeededAmount);
                }
            }
            if (!this.questManagementService.IsQuestRunningForEmpire(this.QuestBTOrders[i].questName, base.AIEntity.Empire))
            {
                this.QuestBTOrders.RemoveAt(i);
            }
            else if (flag)
            {
                List <GlobalObjectiveMessage>      globalObjectiveMessages = this.globalObjectiveMessages;
                Predicate <GlobalObjectiveMessage> match;
                if ((match = < > 9__1) == null)
                {
                    match = (< > 9__1 = ((GlobalObjectiveMessage m) => m.ObjectiveState == this.QuestBTOrders[i].questName && m.SubObjectifGUID == this.QuestBTOrders[i].objectiveGUID));
                }
                GlobalObjectiveMessage globalObjectiveMessage = globalObjectiveMessages.Find(match);
                if (globalObjectiveMessage == null && this.TargetIsReachable(this.QuestBTOrders[i].objectiveGUID))
                {
                    IGameEntity gameEntity3;
                    this.gameEntityRepositoryService.TryGetValue <IGameEntity>(this.QuestBTOrders[i].objectiveGUID, out gameEntity3);
                    PointOfInterest pointOfInterest = gameEntity3 as PointOfInterest;
                    TerraformDevice terraformDevice = gameEntity3 as TerraformDevice;
                    if ((pointOfInterest != null && pointOfInterest.Type != "Village") || this.departmentOfScience.CanParley() || terraformDevice != null)
                    {
                        Region region = this.worldPositionningService.GetRegion((gameEntity3 as IWorldPositionable).WorldPosition);
                        globalObjectiveMessage = this.CreateObjectiveFor(region.Index, gameEntity3, this.QuestBTOrders[i].questName);
                    }
                }
                if (globalObjectiveMessage != null)
                {
                    this.RefreshMessagePriority(globalObjectiveMessage);
                }
            }
            i2 = i;
        }
    }
Example #18
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);
                }
            }
        }
    }
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        base.RefreshObjectives(context, pass);
        base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Pacification.ToString(), false, ref this.globalObjectiveMessages);
        base.ValidateMessages(ref this.globalObjectiveMessages);
        base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Colonization.ToString(), ref this.colonizationObjectives);
        this.colonizationObjectives.Sort((GlobalObjectiveMessage left, GlobalObjectiveMessage right) => - 1 * left.LocalPriority.CompareTo(right.LocalPriority));
        List <int> list = new List <int>();

        for (int l = 0; l < this.colonizationObjectives.Count; l++)
        {
            int regionIndex = this.colonizationObjectives[l].RegionIndex;
            list.Add(this.colonizationObjectives[l].RegionIndex);
            if (this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex) == null && AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, regionIndex))
            {
                GlobalObjectiveMessage item = base.GenerateObjective(regionIndex);
                this.globalObjectiveMessages.Add(item);
            }
        }
        for (int j = 0; j < this.departmentOfTheInterior.Cities.Count; j++)
        {
            int regionIndex = this.departmentOfTheInterior.Cities[j].Region.Index;
            list.AddOnce(this.departmentOfTheInterior.Cities[j].Region.Index);
            if (this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex) == null && AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, regionIndex))
            {
                GlobalObjectiveMessage item2 = base.GenerateObjective(regionIndex);
                this.globalObjectiveMessages.Add(item2);
            }
        }
        this.ComputeObjectivePriority();
        if (this.questManagementService.IsQuestRunningForEmpire("VictoryQuest-Chapter2", base.AIEntity.Empire))
        {
            QuestBehaviour questBehaviour = this.questRepositoryService.GetQuestBehaviour("VictoryQuest-Chapter2", base.AIEntity.Empire.Index);
            QuestBehaviourTreeNode_Action_SpawnArmy questBehaviourTreeNode_Action_SpawnArmy;
            if (questBehaviour != null && ELCPUtilities.TryGetFirstNodeOfType <QuestBehaviourTreeNode_Action_SpawnArmy>(questBehaviour.Root as BehaviourTreeNodeController, out questBehaviourTreeNode_Action_SpawnArmy))
            {
                Region region      = this.worldPositionningService.GetRegion(questBehaviourTreeNode_Action_SpawnArmy.SpawnLocations[0]);
                int    regionIndex = region.Index;
                GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages.Find((GlobalObjectiveMessage match) => match.RegionIndex == regionIndex);
                list.AddOnce(regionIndex);
                if (globalObjectiveMessage == null && AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, regionIndex) && (region.City == null || region.City.Empire == base.AIEntity.Empire))
                {
                    globalObjectiveMessage = base.GenerateObjective(regionIndex);
                    this.globalObjectiveMessages.Add(globalObjectiveMessage);
                }
                if (globalObjectiveMessage != null)
                {
                    globalObjectiveMessage.GlobalPriority.Value = 1f;
                    globalObjectiveMessage.LocalPriority.Value  = 1f;
                }
            }
        }
        float value = 0.9f;

        if (this.departmentOfForeignAffairs.IsInWarWithSomeone())
        {
            value = 0.7f;
        }
        int i;

        Predicate <GlobalObjectiveMessage> < > 9__4;
        int i2;

        for (i = 0; i < this.QuestBTPacifications.Count; i = i2 + 1)
        {
            if (!this.questManagementService.IsQuestRunningForEmpire(this.QuestBTPacifications[i].questName, base.AIEntity.Empire))
            {
                this.QuestBTPacifications.RemoveAt(i);
                i2 = i;
                i  = i2 - 1;
            }
            else if (!list.Contains(this.QuestBTPacifications[i].regionIndex))
            {
                Region region2 = this.worldPositionningService.GetRegion(this.QuestBTPacifications[i].regionIndex);
                if (region2.Owner == null || !(region2.Owner is MajorEmpire))
                {
                    list.AddOnce(this.QuestBTPacifications[i].regionIndex);
                    if (this.CanPathToObjective(region2))
                    {
                        List <GlobalObjectiveMessage>      globalObjectiveMessages = this.globalObjectiveMessages;
                        Predicate <GlobalObjectiveMessage> match2;
                        if ((match2 = < > 9__4) == null)
                        {
                            match2 = (< > 9__4 = ((GlobalObjectiveMessage match) => match.RegionIndex == this.QuestBTPacifications[i].regionIndex));
                        }
                        GlobalObjectiveMessage globalObjectiveMessage2 = globalObjectiveMessages.Find(match2);
                        if (globalObjectiveMessage2 != null)
                        {
                            globalObjectiveMessage2.GlobalPriority.Value = value;
                            globalObjectiveMessage2.LocalPriority.Value  = value;
                        }
                        else if (AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, this.QuestBTPacifications[i].regionIndex))
                        {
                            globalObjectiveMessage2 = base.GenerateObjective(this.QuestBTPacifications[i].regionIndex);
                            this.globalObjectiveMessages.Add(globalObjectiveMessage2);
                            globalObjectiveMessage2.GlobalPriority.Value = value;
                            globalObjectiveMessage2.LocalPriority.Value  = value;
                        }
                    }
                }
            }
            i2 = i;
        }
        for (int k = 0; k < this.globalObjectiveMessages.Count; k++)
        {
            if ((this.globalObjectiveMessages[k].State == BlackboardMessage.StateValue.Message_None || this.globalObjectiveMessages[k].State == BlackboardMessage.StateValue.Message_InProgress) && !list.Contains(this.globalObjectiveMessages[k].RegionIndex))
            {
                base.AIEntity.AIPlayer.Blackboard.CancelMessage(this.globalObjectiveMessages[k]);
                this.CancelObjective(this.globalObjectiveMessages[k]);
                this.globalObjectiveMessages.RemoveAt(k);
                k--;
            }
        }
    }
Example #20
0
    protected override void RefreshObjectives(StaticString context, StaticString pass)
    {
        this.PathingOrigin = this.GetPathingOrigin();
        DepartmentOfForeignAffairs agency = base.AIEntity.Empire.GetAgency <DepartmentOfForeignAffairs>();

        base.RefreshObjectives(context, pass);
        this.CurrentSettlerCount = this.GetSettlerCount();
        this.ComputeGlobalPriority();
        this.ComputeBestDefensiveArmypower();
        this.UpdateContinentData();
        int num = this.GetNumberOfAcceptedColonization();

        this.WantedNewCity = num;
        base.GatherObjectives(AICommanderMissionDefinition.AICommanderCategory.Colonization.ToString(), ref this.globalObjectiveMessages);
        base.ValidateMessages(ref this.globalObjectiveMessages);
        for (int i = 0; i < this.globalObjectiveMessages.Count; i++)
        {
            GlobalObjectiveMessage globalObjectiveMessage = this.globalObjectiveMessages[i];
            if (this.IsObjectiveValid(AICommanderMissionDefinition.AICommanderCategory.Colonization.ToString(), globalObjectiveMessage.RegionIndex, false))
            {
                if (agency.IsInWarWithSomeone())
                {
                    using (IEnumerator <Army> enumerator = Intelligence.GetArmiesInRegion(globalObjectiveMessage.RegionIndex).GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Army army = enumerator.Current;
                            if (army.Empire != base.AIEntity.Empire && army.Empire is MajorEmpire && agency.IsAtWarWith(army.Empire))
                            {
                                base.AIEntity.AIPlayer.Blackboard.CancelMessage(this.globalObjectiveMessages[i]);
                            }
                        }
                        goto IL_18E;
                    }
                }
                if (num > 0 || this.CurrentSettlerCount > i)
                {
                    num--;
                    this.RefreshMessagePriority(globalObjectiveMessage);
                }
                else
                {
                    base.AIEntity.AIPlayer.Blackboard.CancelMessage(this.globalObjectiveMessages[i]);
                }
            }
            IL_18E :;
        }
        if (this.departmentOfTheInterior.Cities.Count == 0 && this.globalObjectiveMessages.Count == 0)
        {
            Region region3 = this.ChooseLastHopeRegion();
            if (region3 == null)
            {
                return;
            }
            this.CreateObjectiveFor(region3);
            num--;
        }
        Region region2 = null;

        for (int j = 0; j < num; j++)
        {
            region2 = this.GetNextRegionToColonize();
            if (region2 != null)
            {
                this.CreateObjectiveFor(region2);
            }
        }
        if (this.ForceShipyardResearch)
        {
            this.TryForceShipyardResearch();
        }
        else if (region2 == null && num > 0)
        {
            if (this.worldPositionningService.World.Continents.Length > 1)
            {
                this.TryForceShipyardResearch();
            }
            else if (this.continentData.Any((AILayer_Colonization.ContinentData c) => c.LandRegionCount > 0 && c.OverallColonizationPercent <= 0.8f))
            {
                this.TryForceShipyardResearch();
            }
        }
        this.WantToColonizeOversea = false;
        for (int k = 0; k < this.globalObjectiveMessages.Count; k++)
        {
            GlobalObjectiveMessage globalObjectiveMessage2 = this.globalObjectiveMessages[k];
            Region region = this.worldPositionningService.GetRegion(globalObjectiveMessage2.RegionIndex);
            if (!Array.Find <AILayer_Colonization.ContinentData>(this.continentData, (AILayer_Colonization.ContinentData match) => match.ContinentId == region.ContinentID).EmpireWithRegion.Contains(base.AIEntity.Empire))
            {
                this.WantToColonizeOversea = true;
                return;
            }
        }
    }
Example #21
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");
            }
        }
    }