Пример #1
0
    public IEnumerable <IAIParameter <InterpreterContext> > GetAIParameters(PillarDefinition pillarDefinition)
    {
        if (pillarDefinition == null)
        {
            throw new ArgumentNullException("pillarDefinition");
        }
        IEnumerable <WorldEffectDefinition> enumerator = this.pillarService.GetActiveWorldEffectDefinitions(pillarDefinition.Name, base.AIEntity.Empire);

        if (enumerator != null)
        {
            foreach (WorldEffectDefinition worldEffectDefinition in enumerator)
            {
                IAIParameter <InterpreterContext>[] worldEffectAiParameters;
                if (!this.pillarEffectsAiParameters.TryGetValue(worldEffectDefinition.Name, out worldEffectAiParameters))
                {
                    IDatabase <AIParameterDatatableElement> aiParameterDatabase = Databases.GetDatabase <AIParameterDatatableElement>(false);
                    Diagnostics.Assert(aiParameterDatabase != null);
                    AIParameterDatatableElement aiParameterDatatableElement;
                    if (aiParameterDatabase.TryGetValue(worldEffectDefinition.Name, out aiParameterDatatableElement))
                    {
                        if (aiParameterDatatableElement.AIParameters != null)
                        {
                            worldEffectAiParameters = new IAIParameter <InterpreterContext> [aiParameterDatatableElement.AIParameters.Length];
                            for (int index = 0; index < aiParameterDatatableElement.AIParameters.Length; index++)
                            {
                                AIParameterDatatableElement.AIParameter parameterDefinition = aiParameterDatatableElement.AIParameters[index];
                                Diagnostics.Assert(parameterDefinition != null);
                                worldEffectAiParameters[index] = parameterDefinition.Instantiate();
                            }
                        }
                    }
                    else
                    {
                        AILayer.LogError("No AIParameters for WorldEffectDefinition {0}", new object[]
                        {
                            worldEffectDefinition.Name
                        });
                    }
                }
                if (worldEffectAiParameters != null)
                {
                    for (int index2 = 0; index2 < worldEffectAiParameters.Length; index2++)
                    {
                        yield return(worldEffectAiParameters[index2]);
                    }
                }
            }
        }
        yield break;
    }
Пример #2
0
    public override IEnumerator Initialize(AIEntity aiEntity)
    {
        this.aiEntityCity  = (aiEntity as AIEntity_City);
        this.amasCityLayer = this.aiEntityCity.GetLayer <AILayer_AmasCity>();
        yield return(base.Initialize(aiEntity));

        base.AIEntity.RegisterPass(AIEntity.Passes.CreateLocalNeeds.ToString(), "LayerPopulation_CreateLocalNeedsPass", new AIEntity.AIAction(this.CreateLocalNeeds), this, new StaticString[]
        {
            "LayerAmasCity_CreateLocalNeedsPass",
            "LayerExtension_CreateLocalNeedsPass"
        });
        base.AIEntity.RegisterPass(AIEntity.Passes.EvaluateNeeds.ToString(), "LayerPopulation_EvaluateNeedsPass", new AIEntity.AIAction(this.EvaluateNeeds), this, new StaticString[]
        {
            "LayerExtension_EvaluateNeedsPass"
        });
        base.AIEntity.RegisterPass(AIEntity.Passes.ExecuteNeeds.ToString(), "LayerPopulation_ExecuteNeedsPass", new AIEntity.AIAction(this.ExecuteNeeds), this, new StaticString[]
        {
            "LayerExtension_ExecuteNeedsPass"
        });
        this.interpreterContext = new InterpreterContext(this.aiEntityCity.City);
        for (int index = 0; index < AILayer_Population.PopulationResource.Length; index++)
        {
            this.interpreterContext.Register(AILayer_Population.PopulationResource[index], 1);
        }
        this.preferedPopulationMessageID = base.AIEntity.AIPlayer.Blackboard.AddMessage(new PreferedPopulationMessage(this.aiEntityCity.City.GUID));
        if (!(this.aiEntityCity.AIPlayer is AIPlayer_MajorEmpire))
        {
            AILayer.LogError("The agent context object is not an ai player.");
        }
        DepartmentOfIndustry industry = this.Empire.GetAgency <DepartmentOfIndustry>();

        DepartmentOfIndustry.ConstructibleElement[] constructibleElements = ((IConstructibleElementDatabase)industry).GetAvailableConstructibleElements(new StaticString[]
        {
            DistrictImprovementDefinition.ReadOnlyCategory
        });
        Diagnostics.Assert(constructibleElements != null);
        this.districtImprovement = Array.Find <DepartmentOfIndustry.ConstructibleElement>(constructibleElements, delegate(DepartmentOfIndustry.ConstructibleElement element)
        {
            AIPlayer_MajorEmpire aiPlayer;
            return(element.Name == aiPlayer.AIData_Faction.DistrictImprovement);
        });
        Diagnostics.Assert(this.districtImprovement != null);
        IPersonalityAIHelper personalityAIHelper = AIScheduler.Services.GetService <IPersonalityAIHelper>();

        this.populationThresholdForSacrifice = personalityAIHelper.GetRegistryValue <float>(this.Empire, "AI/MajorEmpire/AIEntity_City/AILayer_Population/PopulationThresholdForSacrifice", this.populationThresholdForSacrifice);
        this.approvalThresholdForSacrifice   = personalityAIHelper.GetRegistryValue <float>(this.Empire, "AI/MajorEmpire/AIEntity_City/AILayer_Population/ApprovalThresholdForSacrifice", this.approvalThresholdForSacrifice);
        yield break;
    }
Пример #3
0
    protected override void CreateLocalNeeds(StaticString context, StaticString pass)
    {
        base.CreateLocalNeeds(context, pass);
        Account account = this.aiLayerAccountManager.TryGetAccount(AILayer_AccountManager.EmpirePlanAccountName);

        if (account == null)
        {
            AILayer.LogError("Can't retrieve the empire plan account.");
            return;
        }
        Diagnostics.Assert(this.empirePlanClasses != null);
        Diagnostics.Assert(this.wantedEmpirePlan != null);
        for (int i = 0; i < this.empirePlanClasses.Length; i++)
        {
            this.wantedEmpirePlan.SubmitPlan(this.departmentOfPlanification.GetEmpirePlanDefinition(this.empirePlanClasses[i], 0));
        }
        Diagnostics.Assert(this.availableEmpirePlans != null);
        this.availableEmpirePlans.Clear();
        for (int j = 0; j < this.empirePlanClasses.Length; j++)
        {
            int empirePlanAvailableLevel = this.departmentOfPlanification.GetEmpirePlanAvailableLevel(this.empirePlanClasses[j]);
            for (int k = 1; k <= empirePlanAvailableLevel; k++)
            {
                this.availableEmpirePlans.Add(this.departmentOfPlanification.GetEmpirePlanDefinition(this.empirePlanClasses[j], k));
            }
        }
        Diagnostics.Assert(this.decisionMaker != null);
        base.AIEntity.Context.InitializeDecisionMaker <ConstructibleElement>(AILayer_Strategy.EmpirePlanParameterModifier, this.decisionMaker);
        this.decisionMaker.ClearAIParametersOverrides();
        this.FillDecisionMakerVariables();
        Diagnostics.Assert(this.decisionResults != null);
        this.decisionResults.Clear();
        if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools)
        {
            DecisionMakerEvaluationData <ConstructibleElement, InterpreterContext> decisionMakerEvaluationData;
            this.decisionMaker.EvaluateDecisions(this.availableEmpirePlans, ref this.decisionResults, out decisionMakerEvaluationData);
            IGameService service = Services.GetService <IGameService>();
            decisionMakerEvaluationData.Turn = (service.Game as global::Game).Turn;
            this.DecisionMakerEvaluationDataHistoric.Add(decisionMakerEvaluationData);
        }
        else
        {
            this.decisionMaker.EvaluateDecisions(this.availableEmpirePlans, ref this.decisionResults);
        }
        IPersonalityAIHelper service2 = AIScheduler.Services.GetService <IPersonalityAIHelper>();
        float registryValue           = service2.GetRegistryValue <float>(base.AIEntity.Empire, "AI/MajorEmpire/AIEntity_Empire/AILayer_EmpirePlan/MaximumPopulationPercentToReachObjective", 0f);

        Diagnostics.Assert(this.wantedEmpirePlan != null);
        float num  = 0f;
        float num2 = float.MaxValue;
        float num3 = float.MinValue;

        for (int l = 0; l < this.decisionResults.Count; l++)
        {
            DecisionResult decisionResult = this.decisionResults[l];
            if (decisionResult.Score < 0.05f)
            {
                break;
            }
            EmpirePlanDefinition empirePlanDefinition = decisionResult.Element as EmpirePlanDefinition;
            num2 = Mathf.Min(num2, decisionResult.Score);
            num3 = Mathf.Max(num3, decisionResult.Score);
            EmpirePlanDefinition currentEmpirePlanDefinition = this.wantedEmpirePlan.GetCurrentEmpirePlanDefinition(empirePlanDefinition.EmpirePlanClass);
            if (currentEmpirePlanDefinition == null || empirePlanDefinition.EmpirePlanLevel > currentEmpirePlanDefinition.EmpirePlanLevel)
            {
                float num4 = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, empirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint);
                if (currentEmpirePlanDefinition != null)
                {
                    float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(base.AIEntity.Empire.SimulationObject, currentEmpirePlanDefinition, DepartmentOfTheTreasury.Resources.EmpirePoint);
                    num4 -= productionCostWithBonus;
                }
                float empirePointProductionStress = this.GetEmpirePointProductionStress(num + num4, account, this.departmentOfPlanification.EmpirePlanChoiceRemainingTurn);
                if (empirePointProductionStress <= registryValue)
                {
                    num += num4;
                    this.wantedEmpirePlan.SubmitPlan(empirePlanDefinition);
                }
            }
        }
        Diagnostics.Assert(this.empirePlanClasses != null);
        Diagnostics.Assert(this.wantedEmpirePlan != null);
        for (int m = 0; m < this.empirePlanClasses.Length; m++)
        {
            EmpirePlanDefinition empirePlan = this.wantedEmpirePlan.GetCurrentEmpirePlanDefinition(this.empirePlanClasses[m]);
            float localOpportunity          = 0f;
            if (empirePlan.EmpirePlanLevel > 0)
            {
                float score = this.decisionResults.Find((DecisionResult match) => match.Element == empirePlan).Score;
                localOpportunity = ((num3 - num2 <= float.Epsilon) ? 0f : ((score - num2) / (num3 - num2)));
            }
            EvaluableMessage_EmpirePlan evaluableMessage_EmpirePlan = base.AIEntity.AIPlayer.Blackboard.FindFirst <EvaluableMessage_EmpirePlan>(BlackboardLayerID.Empire, (EvaluableMessage_EmpirePlan match) => match.State == BlackboardMessage.StateValue.Message_InProgress && match.EmpirePlanClass == empirePlan.EmpirePlanClass);
            if (evaluableMessage_EmpirePlan != null)
            {
                evaluableMessage_EmpirePlan.EmpirePlanLevel = empirePlan.EmpirePlanLevel;
                evaluableMessage_EmpirePlan.SetInterest(1f, localOpportunity);
            }
            else
            {
                evaluableMessage_EmpirePlan = new EvaluableMessage_EmpirePlan(empirePlan.EmpirePlanClass, empirePlan.EmpirePlanLevel, this.departmentOfPlanification.EmpirePlanChoiceRemainingTurn, AILayer_AccountManager.EmpirePlanAccountName);
                evaluableMessage_EmpirePlan.SetInterest(1f, localOpportunity);
                base.AIEntity.AIPlayer.Blackboard.AddMessage(evaluableMessage_EmpirePlan);
            }
        }
    }
    protected override void CreateLocalNeeds(StaticString context, StaticString pass)
    {
        AILayer_Military layer = base.AIEntity.GetLayer <AILayer_Military>();

        base.CreateLocalNeeds(context, pass);
        this.VerifyAndUpdateRecruitementLocks();
        Diagnostics.Assert(base.AIEntity != null && base.AIEntity.AIPlayer != null && base.AIEntity.AIPlayer.Blackboard != null);
        IEnumerable <RequestUnitListMessage> messages = base.AIEntity.AIPlayer.Blackboard.GetMessages <RequestUnitListMessage>(BlackboardLayerID.Empire);

        Diagnostics.Assert(messages != null);
        List <RequestUnitListMessage> list = new List <RequestUnitListMessage>(messages);

        Diagnostics.Assert(this.Empire != null);
        list.RemoveAll((RequestUnitListMessage match) => match.EmpireTarget != this.Empire.Index);
        this.ResetRequestArmyMessages();
        this.countByUnitModel.Clear();
        list.Sort((RequestUnitListMessage left, RequestUnitListMessage right) => - 1 * left.Priority.CompareTo(right.Priority));
        this.intelligenceAIHelper.FillAvailableUnitDesignList(this.Empire);
        Diagnostics.Assert(this.intelligenceAIHelper != null);
        for (int i = 0; i < list.Count; i++)
        {
            RequestUnitListMessage requestUnitListMessage = list[i];
            if (float.IsNaN(requestUnitListMessage.Priority) || float.IsInfinity(requestUnitListMessage.Priority))
            {
                AILayer.LogWarning("[SCORING] Skipping RequestUnitListMessage {0} with a priority of {1}", new object[]
                {
                    requestUnitListMessage.CommanderCategory,
                    requestUnitListMessage.Priority
                });
            }
            else if (AILayer_ArmyRecruitment.IsCommanderMissionNotInteresting(requestUnitListMessage.CommanderCategory))
            {
                requestUnitListMessage.State   = BlackboardMessage.StateValue.Message_Canceled;
                requestUnitListMessage.TimeOut = 0;
            }
            else
            {
                BlackboardMessage.StateValue state = requestUnitListMessage.State;
                if (state != BlackboardMessage.StateValue.Message_None)
                {
                    if (state == BlackboardMessage.StateValue.Message_Success || state == BlackboardMessage.StateValue.Message_Canceled)
                    {
                        goto IL_1F3;
                    }
                    if (state != BlackboardMessage.StateValue.Message_InProgress)
                    {
                        AILayer.LogError("[AILayer_ArmyRecruitment] Unknow state for RequestArmyMessage {0}", new object[]
                        {
                            requestUnitListMessage.State
                        });
                        goto IL_1F3;
                    }
                }
                if (requestUnitListMessage.ExecutionState == RequestUnitListMessage.RequestUnitListState.Pending)
                {
                    Intelligence.BestRecruitementCombination bestRecruitementCombination;
                    if (requestUnitListMessage is RequestGarrisonMessage)
                    {
                        bestRecruitementCombination = null;
                    }
                    else if (requestUnitListMessage is RequestGarrisonCampMessage)
                    {
                        bestRecruitementCombination = null;
                    }
                    else
                    {
                        bestRecruitementCombination = this.intelligenceAIHelper.FillArmyPattern(this.Empire.Index, requestUnitListMessage, layer);
                    }
                    if (bestRecruitementCombination != null)
                    {
                        this.RecruitArmiesUnits(requestUnitListMessage, bestRecruitementCombination);
                    }
                }
            }
            IL_1F3 :;
        }
        this.ResetRecruitementLocks();
        this.RegroupSmallFreeArmies();
        this.CleanupRequestUnitMessages();
    }
    private void RegroupSmallFreeArmies()
    {
        List <Army> list = new List <Army>();
        IAIDataRepositoryAIHelper service = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>();

        this.smallEntitiesToRegroup.Clear();
        this.tempEntitiesToRegroup.Clear();
        int num = (int)this.Empire.GetPropertyValue(SimulationProperties.ArmyUnitSlot);
        DepartmentOfDefense agency = this.Empire.GetAgency <DepartmentOfDefense>();

        for (int i = 0; i < agency.Armies.Count; i++)
        {
            Army        army   = agency.Armies[i];
            AIData_Army aidata = service.GetAIData <AIData_Army>(army.GUID);
            if (aidata != null && !aidata.IsSolitary && !aidata.Army.IsSeafaring && !aidata.Army.HasCatspaw && !(aidata.Army is KaijuArmy))
            {
                if (aidata.CommanderMission != null)
                {
                    if (aidata.CommanderMission.Commander == null)
                    {
                        AILayer.LogError("[AILayer_ArmyRecruitment] Commander Mission without a commander");
                        goto IL_131;
                    }
                    if (!AILayer_ArmyRecruitment.IsCommanderMissionNotInteresting(aidata.CommanderMission.Commander.Category))
                    {
                        goto IL_131;
                    }
                }
                else if (!aidata.IsTaggedFreeForExploration())
                {
                    goto IL_131;
                }
                if (army.StandardUnits.Count < num)
                {
                    if (!this.IsMercArmy(aidata.Army))
                    {
                        this.smallEntitiesToRegroup.Add(aidata);
                    }
                    else
                    {
                        list.Add(aidata.Army);
                    }
                }
            }
            IL_131 :;
        }
        if (this.Empire is MajorEmpire)
        {
            DepartmentOfTheInterior agency2 = this.Empire.GetAgency <DepartmentOfTheInterior>();
            if (agency2 != null)
            {
                for (int j = 0; j < agency2.Cities.Count; j++)
                {
                    City garrison = agency2.Cities[j];
                    this._Internal_RegroupSmallFreeArmies(garrison);
                }
            }
            List <Village> convertedVillages = ((MajorEmpire)this.Empire).ConvertedVillages;
            for (int k = 0; k < convertedVillages.Count; k++)
            {
                Village village = convertedVillages[k];
                if (village != null)
                {
                    this._Internal_RegroupSmallFreeArmies(village);
                }
            }
        }
        while (this.smallEntitiesToRegroup.Count > 1)
        {
            AIData_GameEntity aidata_GameEntity = this.smallEntitiesToRegroup[0];
            this.smallEntitiesToRegroup.RemoveAt(0);
            int num2;
            if (aidata_GameEntity is AIData_Army)
            {
                num2 = (aidata_GameEntity as AIData_Army).Army.StandardUnits.Count;
            }
            else
            {
                if (!(aidata_GameEntity is AIData_Unit))
                {
                    continue;
                }
                num2 = 1;
            }
            this.tempEntitiesToRegroup.Clear();
            this.tempEntitiesToRegroup.Add(aidata_GameEntity);
            int num3 = this.smallEntitiesToRegroup.Count - 1;
            while (num3 >= 0 && num2 < num)
            {
                AIData_GameEntity item = this.smallEntitiesToRegroup[num3];
                int num4;
                if (aidata_GameEntity is AIData_Army)
                {
                    num4 = (aidata_GameEntity as AIData_Army).Army.StandardUnits.Count;
                    goto IL_29E;
                }
                if (aidata_GameEntity is AIData_Unit)
                {
                    num4 = 1;
                    goto IL_29E;
                }
IL_296:
                num3--;
                continue;
IL_29E:
                if (num2 + num4 <= num)
                {
                    num2 += num4;
                    this.tempEntitiesToRegroup.Add(item);
                    this.smallEntitiesToRegroup.RemoveAt(num3);
                    goto IL_296;
                }
                goto IL_296;
            }
            if (this.tempEntitiesToRegroup.Count > 1)
            {
                this.unitsGUIDS.Clear();
                for (int l = 0; l < this.tempEntitiesToRegroup.Count; l++)
                {
                    AIData_GameEntity aidata_GameEntity2 = this.tempEntitiesToRegroup[l];
                    if (aidata_GameEntity2 is AIData_Army)
                    {
                        AIData_Army aidata_Army = aidata_GameEntity2 as AIData_Army;
                        if (aidata_Army.CommanderMission != null)
                        {
                            aidata_Army.CommanderMission.Interrupt();
                        }
                        for (int m = 0; m < aidata_Army.Army.StandardUnits.Count; m++)
                        {
                            AIData_Unit aidata_Unit;
                            if (service.TryGetAIData <AIData_Unit>(aidata_Army.Army.StandardUnits[m].GUID, out aidata_Unit))
                            {
                                aidata_Unit.ReservationExtraTag = AIData_Unit.AIDataReservationExtraTag.None;
                                this.unitsGUIDS.Add(aidata_Unit.Unit.GUID);
                            }
                        }
                    }
                    else if (aidata_GameEntity2 is AIData_Unit)
                    {
                        AIData_Unit aidata_Unit2 = aidata_GameEntity2 as AIData_Unit;
                        aidata_Unit2.ReservationExtraTag = AIData_Unit.AIDataReservationExtraTag.None;
                        this.unitsGUIDS.Add(aidata_Unit2.Unit.GUID);
                    }
                }
                if (this.unitsGUIDS.Count != 0)
                {
                    this.CreateNewCommanderRegroup(this.unitsGUIDS.ToArray(), null);
                }
            }
        }
        if (list.Count > 1)
        {
            int num5 = 0;
            List <GameEntityGUID> list2 = new List <GameEntityGUID>();
            for (int n = 0; n < list.Count; n++)
            {
                num5++;
                foreach (Unit unit in list[n].StandardUnits)
                {
                    AIData_Unit aidata_Unit3;
                    if (service.TryGetAIData <AIData_Unit>(unit.GUID, out aidata_Unit3))
                    {
                        aidata_Unit3.ReservationExtraTag = AIData_Unit.AIDataReservationExtraTag.None;
                        list2.Add(aidata_Unit3.Unit.GUID);
                        if (list2.Count >= num)
                        {
                            this.CreateNewCommanderRegroup(list2.ToArray(), null);
                            list2.Clear();
                            num5 = 0;
                            break;
                        }
                    }
                }
            }
            if (num5 > 1)
            {
                this.CreateNewCommanderRegroup(list2.ToArray(), null);
            }
        }
    }
    private void RecruitArmiesUnits(RequestUnitListMessage requestUnitListMessage, Intelligence.BestRecruitementCombination bestRecruits)
    {
        IAIDataRepositoryAIHelper service = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>();

        this.unitsGUIDS.Clear();
        for (int i = 0; i < bestRecruits.CombinationOfArmiesUnits.Count; i++)
        {
            AIData_GameEntity aidata_GameEntity = bestRecruits.CombinationOfArmiesUnits[i];
            if (aidata_GameEntity is AIData_Army)
            {
                AIData_Army aidata_Army = aidata_GameEntity as AIData_Army;
                if (aidata_Army.Army == null)
                {
                    AILayer.LogWarning(string.Format("[AILayer_ArmyRecruitment.UnitAssignation] Army was not found, was it destroyed?", new object[0]));
                }
                else
                {
                    if (aidata_Army.CommanderMission != null)
                    {
                        aidata_Army.CommanderMission.Interrupt();
                    }
                    for (int j = 0; j < aidata_Army.Army.StandardUnits.Count; j++)
                    {
                        Unit        unit = aidata_Army.Army.StandardUnits[j];
                        AIData_Unit aidata_Unit;
                        if (service.TryGetAIData <AIData_Unit>(unit.GUID, out aidata_Unit))
                        {
                            this.unitsGUIDS.Add(unit.GUID);
                            aidata_Unit.ClearLock();
                            aidata_Unit.TryLockUnit(base.InternalGUID, base.GetType().ToString(), AIData_Unit.AIDataReservationExtraTag.ArmyRecruitment, requestUnitListMessage.Priority);
                        }
                    }
                }
            }
            else if (aidata_GameEntity is AIData_Unit)
            {
                AIData_Unit aidata_Unit2 = aidata_GameEntity as AIData_Unit;
                Unit        unit2        = aidata_Unit2.Unit;
                if (unit2 == null || unit2.Garrison == null)
                {
                    AILayer.LogWarning(string.Format("[AILayer_ArmyRecruitment.UnitAssignation] Unit was not found, was it destroyed?", new object[0]));
                }
                else
                {
                    this.unitsGUIDS.Add(unit2.GUID);
                    if (aidata_Unit2.IsUnitLocked() && !aidata_Unit2.IsUnitLockedByMe(base.InternalGUID))
                    {
                        IGarrison garrison = unit2.Garrison;
                        if (garrison is Army)
                        {
                            Army        army   = garrison as Army;
                            AIData_Army aidata = service.GetAIData <AIData_Army>(army.GUID);
                            if (aidata == null)
                            {
                                AILayer.LogWarning(string.Format("[AILayer_ArmyRecruitment.UnitAssignation] Army was not found, was it destroyed?", new object[0]));
                            }
                            else if (aidata.CommanderMission != null)
                            {
                                aidata.CommanderMission.Interrupt();
                            }
                            else
                            {
                                AILayer.LogWarning(string.Format("[AILayer_ArmyRecruitment.UnitAssignation] Although unit is locked, Army commander mission was not found.", new object[0]));
                                aidata_Unit2.ClearLock();
                            }
                        }
                        else if (garrison is City)
                        {
                            aidata_Unit2.ClearLock();
                        }
                        else
                        {
                            aidata_Unit2.ClearLock();
                        }
                    }
                    aidata_Unit2.TryLockUnit(base.InternalGUID, base.GetType().ToString(), AIData_Unit.AIDataReservationExtraTag.ArmyRecruitment, requestUnitListMessage.Priority);
                }
            }
            else
            {
                AILayer.LogError("[AILayer_ArmyRecruitment.UnitAssignation] Unknown GameEntity Type {0}", new object[]
                {
                    aidata_GameEntity.GetType().ToString()
                });
            }
        }
        if (this.unitsGUIDS.Count != 0)
        {
            this.CreateNewCommanderRegroup(this.unitsGUIDS.ToArray(), requestUnitListMessage);
            requestUnitListMessage.ExecutionState = RequestUnitListMessage.RequestUnitListState.Regrouping;
        }
    }