public override IEnumerator Initialize(AIEntity aiEntity)
    {
        yield return(base.Initialize(aiEntity));

        this.gameService = Services.GetService <IGameService>();
        Diagnostics.Assert(this.gameService != null);
        this.gameEntityRepositoryService = this.gameService.Game.Services.GetService <IGameEntityRepositoryService>();
        Diagnostics.Assert(this.gameEntityRepositoryService != null);
        this.worldPositionningService = this.gameService.Game.Services.GetService <IWorldPositionningService>();
        Diagnostics.Assert(this.worldPositionningService != null);
        base.AIEntity.RegisterPass(AIEntity.Passes.RefreshObjectives.ToString(), "AILayer_KaijuManagement_RefreshObjectives", new AIEntity.AIAction(this.RefreshObjectives), this, new StaticString[0]);
        base.AIEntity.RegisterPass(AIEntity.Passes.CreateLocalNeeds.ToString(), "AILayer_KaijuManagement_CreateLocalNeedsPass", new AIEntity.AIAction(this.CreateLocalNeeds), this, new StaticString[]
        {
            "AILayer_Diplomacy_CreateLocalNeedsPass"
        });
        base.AIEntity.RegisterPass(AIEntity.Passes.EvaluateNeeds.ToString(), "AILayer_KaijuManagement_EvaluateNeedsPass", new AIEntity.AIAction(this.EvaluateNeeds), this, new StaticString[0]);
        base.AIEntity.RegisterPass(AIEntity.Passes.ExecuteNeeds.ToString(), "AILayer_KaijuManagement_ExecuteNeedsPass", new AIEntity.AIAction(this.ExecuteNeeds), this, new StaticString[0]);
        this.validatedRelocationMessages = new List <KaijuRelocationMessage>();
        this.DiplomacyLayer          = base.AIEntity.GetLayer <AILayer_Diplomacy>();
        this.aiDataRepositoryHelper  = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>();
        this.departmentOfDefense     = this.MajorEmpire.GetAgency <DepartmentOfDefense>();
        this.departmentOfScience     = this.MajorEmpire.GetAgency <DepartmentOfScience>();
        this.departmentOfTheInterior = this.MajorEmpire.GetAgency <DepartmentOfTheInterior>();
        IDatabase <GarrisonAction> database       = Databases.GetDatabase <GarrisonAction>(false);
        GarrisonAction             garrisonAction = null;

        if (database == null || !database.TryGetValue("GarrisonActionMigrateKaiju", out garrisonAction))
        {
            Diagnostics.LogError("AILayer_KaijuManagement didnt find GarrisonActionMigrateKaiju");
        }
        else
        {
            this.garrisonAction_MigrateKaiju = (garrisonAction as GarrisonAction_MigrateKaiju);
        }
        GarrisonAction garrisonAction2 = null;

        if (database == null || !database.TryGetValue(GarrisonAction_RiseKaiju.ReadOnlyName, out garrisonAction2))
        {
            Diagnostics.LogError("AILayer_KaijuManagement didnt find " + GarrisonAction_RiseKaiju.ReadOnlyName.ToString());
        }
        else
        {
            this.garrisonAction_RiseKaiju = (garrisonAction2 as GarrisonAction_RiseKaiju);
        }
        this.MajorEmpire.TamedKaijusCollectionChanged += this.AILayer_KaijuManagement_TamedKaijusCollectionChanged;
        yield break;
    }
    public override void Initialize(AICommander commander)
    {
        base.Initialize(commander);
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        this.game = (service.Game as global::Game);
        this.worldPositioningService = service.Game.Services.GetService <IWorldPositionningService>();
        this.pathfindingService      = service.Game.Services.GetService <IPathfindingService>();
        this.departmentOfDefense     = base.Commander.Empire.GetAgency <DepartmentOfDefense>();
        this.departmentOfTheInterior = base.Commander.Empire.GetAgency <DepartmentOfTheInterior>();
        this.aiDataRepositoryHelper  = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>();
        base.AIDataArmyGUID          = commander.ForceArmyGUID;
        AIData_Army aidata_Army;

        if (this.aiDataRepositoryHelper.TryGetAIData <AIData_Army>(base.AIDataArmyGUID, out aidata_Army) && aidata_Army.Army is KaijuArmy)
        {
            this.Kaiju = (aidata_Army.Army as KaijuArmy).Kaiju;
        }
        if (base.Commander.Empire != null && base.Commander.Empire is MajorEmpire)
        {
            GameServer           gameServer = (Services.GetService <ISessionService>().Session as global::Session).GameServer as GameServer;
            AIPlayer_MajorEmpire aiplayer_MajorEmpire;
            if (gameServer.AIScheduler != null && gameServer.AIScheduler.TryGetMajorEmpireAIPlayer(base.Commander.Empire as MajorEmpire, out aiplayer_MajorEmpire))
            {
                AIEntity entity = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>();
                if (entity != null)
                {
                    this.aILayer_KaijuManagement = entity.GetLayer <AILayer_KaijuManagement>();
                    this.aILayer_War             = entity.GetLayer <AILayer_War>();
                }
            }
        }
        IDatabase <GarrisonAction> database       = Databases.GetDatabase <GarrisonAction>(false);
        GarrisonAction             garrisonAction = null;

        if (database == null || !database.TryGetValue("GarrisonActionMigrateKaiju", out garrisonAction))
        {
            Diagnostics.LogError("AICommanderMission_KaijuSupport didnt find GarrisonActionMigrateKaiju");
            return;
        }
        this.garrisonAction_MigrateKaiju = (garrisonAction as GarrisonAction_MigrateKaiju);
    }