예제 #1
0
 protected override bool IsObjectiveValid(StaticString objectiveType, int regionIndex, bool checkLocalPriority = false)
 {
     return(AILayer_Pacification.RegionContainsHostileArmies(base.AIEntity.Empire, regionIndex));
 }
예제 #2
0
    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--;
            }
        }
    }
 protected override bool IsMissionCompleted()
 {
     return(this.RegionTarget == null || (this.RegionTarget.City != null && this.RegionTarget.City.Empire != base.Commander.Empire) || !AILayer_Pacification.RegionContainsHostileArmies(base.Commander.Empire, this.RegionTarget.Index));
 }