private List <IWorldPositionable> Execute_GetVillages(AIBehaviorTree aiBehaviorTree, Army army, IGameService gameService, List <IWorldPositionable> unfilteredTargetList)
    {
        List <IWorldPositionable> list = new List <IWorldPositionable>();

        for (int i = 0; i < unfilteredTargetList.Count; i++)
        {
            PointOfInterest pointOfInterest = unfilteredTargetList[i] as PointOfInterest;
            if (pointOfInterest != null && !(pointOfInterest.Type != "Village") && pointOfInterest.Region != null && pointOfInterest.Region.MinorEmpire != null)
            {
                BarbarianCouncil agency = pointOfInterest.Region.MinorEmpire.GetAgency <BarbarianCouncil>();
                if (agency != null)
                {
                    Village villageAt = agency.GetVillageAt(pointOfInterest.WorldPosition);
                    if (villageAt != null && !villageAt.HasBeenPacified && this.TypeOfDiplomaticRelation != "VillageConvert" && pointOfInterest.PointOfInterestImprovement != null && !villageAt.HasBeenInfected)
                    {
                        list.Add(villageAt);
                    }
                    else if (this.TypeOfDiplomaticRelation == "VillageConvert" && army.Empire is MajorEmpire && army.Empire.SimulationObject.Tags.Contains(AILayer_Village.TagConversionTrait) && villageAt.HasBeenPacified && DepartmentOfTheInterior.IsArmyAbleToConvert(army, true) && !villageAt.HasBeenConverted && !villageAt.HasBeenInfected)
                    {
                        DepartmentOfForeignAffairs agency2 = aiBehaviorTree.AICommander.Empire.GetAgency <DepartmentOfForeignAffairs>();
                        City city = villageAt.Region.City;
                        if (city != null && city.Empire != aiBehaviorTree.AICommander.Empire)
                        {
                            DiplomaticRelation diplomaticRelation = agency2.GetDiplomaticRelation(city.Empire);
                            if (diplomaticRelation == null || diplomaticRelation.State.Name != DiplomaticRelationState.Names.War || (diplomaticRelation.State.Name == DiplomaticRelationState.Names.War && pointOfInterest.PointOfInterestImprovement == null))
                            {
                                goto IL_1FB;
                            }
                        }
                        float num;
                        army.Empire.GetAgency <DepartmentOfTheTreasury>().TryGetResourceStockValue(army.Empire.SimulationObject, DepartmentOfTheTreasury.Resources.EmpirePoint, out num, false);
                        if (AILayer_Village.GetVillageConversionCost(army.Empire as MajorEmpire, villageAt) * 2f < num)
                        {
                            list.Add(villageAt);
                        }
                    }
                }
            }
            IL_1FB :;
        }
        return(list);
    }
Esempio n. 2
0
    protected override bool TryComputeArmyMissionParameter()
    {
        bool result;

        if (this.RegionTarget == null)
        {
            base.Completion = AICommanderMission.AICommanderMissionCompletion.Fail;
            result          = false;
        }
        else
        {
            base.ArmyMissionParameters.Clear();
            if (base.AIDataArmyGUID == GameEntityGUID.Zero)
            {
                result = false;
            }
            else
            {
                this.Village = this.SelectVillage();
                if (this.Village == null)
                {
                    base.Completion = AICommanderMission.AICommanderMissionCompletion.Success;
                    result          = true;
                }
                else
                {
                    List <object> list = new List <object>();
                    list.Add(this.RegionTarget.Index);
                    list.Add(this.Village);
                    AIData_Army aidata = this.aiDataRepository.GetAIData <AIData_Army>(base.AIDataArmyGUID);
                    if (aidata != null)
                    {
                        Army army = aidata.Army;
                        if (army != null && !DepartmentOfTheInterior.IsArmyAbleToConvert(army, true) && base.TryCreateArmyMission("PacifyVillage", new List <object>
                        {
                            this.Village
                        }))
                        {
                            return(true);
                        }
                    }
                    if (this.Village.HasBeenConverted && this.Village.Converter != base.Commander.Empire as MajorEmpire)
                    {
                        result = base.TryCreateArmyMission("PacifyVillage", new List <object>
                        {
                            this.Village
                        });
                    }
                    else
                    {
                        if (this.Village.HasBeenPacified)
                        {
                            if (base.TryCreateArmyMission("ConvertVillage", list))
                            {
                                return(true);
                            }
                        }
                        else if (base.TryCreateArmyMission("PacifyAndConvertVillage", list))
                        {
                            return(true);
                        }
                        result = false;
                    }
                }
            }
        }
        return(result);
    }