Ejemplo n.º 1
0
        void cMapSave(ConsoleSystem.Arg arg)
        {
            if (arg.Connection != null && arg.Connection.authLevel < 2)
            {
                return;
            }
            if (SaveRestore.IsSaving)
            {
                SendReply(arg, lang.GetMessage("alreadysaving", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
                return;
            }
            SaveBackupCreate();
            string saveName;

            saveName = saveFolder + SaveRestore.SaveFileName;
            foreach (BaseEntity current in BaseEntity.saveList)
            {
                current.InvalidateNetworkCache();
            }
            Diag.Stopwatch stopwatch = Diag.Stopwatch.StartNew();
            UnityEngine.Debug.Log("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds");
            try {
                BaseEntity.saveList.RemoveWhere(p => !p);
                BaseEntity.saveList.RemoveWhere(p => p == null);
                IEnumerator enumerator = SaveRestore.Save(saveName, true);
                while (enumerator.MoveNext())
                {
                }
                Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { saveName, "custom" }));
                arg.ReplyWith(lang.GetMessage("customsavecomplete", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
            }
            catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
            CallOnServerSave();
        }
Ejemplo n.º 2
0
 public void Initialize(bool loadSave = true, string saveFile = "", bool allowOutOfDateSaves = false, bool skipInitialSpawn = false)
 {
     this.persistance = new UserPersistance(ConVar.Server.rootFolder);
     this.SpawnMapEntities();
     if (SingletonComponent <SpawnHandler> .Instance)
     {
         using (TimeWarning timeWarning = TimeWarning.New("SpawnHandler.UpdateDistributions", 0.1f))
         {
             SingletonComponent <SpawnHandler> .Instance.UpdateDistributions();
         }
     }
     if (loadSave)
     {
         skipInitialSpawn = SaveRestore.Load(saveFile, allowOutOfDateSaves);
     }
     if (SingletonComponent <SpawnHandler> .Instance)
     {
         if (!skipInitialSpawn)
         {
             using (timeWarning = TimeWarning.New("SpawnHandler.InitialSpawn", (long)200))
             {
                 SingletonComponent <SpawnHandler> .Instance.InitialSpawn();
             }
         }
         using (timeWarning = TimeWarning.New("SpawnHandler.StartSpawnTick", (long)200))
         {
             SingletonComponent <SpawnHandler> .Instance.StartSpawnTick();
         }
     }
     this.CreateImportantEntities();
     this.auth = base.GetComponent <ConnectionAuth>();
 }
Ejemplo n.º 3
0
        void OnNewSave(string strFilename)
        {
            if (Initialized || loadReload || !enableLoadOverride)
            {
                return;
            }
            List <string> filename = Interface.Oxide.DataFileSystem.ReadObject <List <string> >(this.Title);

            if (filename != null && filename.Count == 2 && !filename[0].Contains(SaveRestore.SaveFileName))
            {
                Puts(lang.GetMessage("loadoverridecancel", this));
                return;
            }
            if (filename != null && filename.Count == 2)
            {
                if (filename[1] == "custom")
                {
                    loadReload = true;
                    if (SaveRestore.Load(filename[0], allowOutOfDateSaves))
                    {
                        Puts(lang.GetMessage("loadoverride", this));
                    }
                }
            }
        }
Ejemplo n.º 4
0
 object OnSaveLoad(Dictionary <BaseEntity, ProtoBuf.Entity> dictionary)
 {
     if (Initialized || loadReload)
     {
         return(null);
     }
     if (!enableLoadOverride)
     {
         return(null);
     }
     if (!loadReload)
     {
         List <string> filename = Interface.Oxide.DataFileSystem.ReadObject <List <string> >(this.Title);
         if (filename != null && filename.Count == 2)
         {
             if (filename[1] == "custom")
             {
                 loadReload = true;
                 if (SaveRestore.Load(filename[0], allowOutOfDateSaves))
                 {
                     dictionary.Clear();
                     Puts(lang.GetMessage("loadoverride", this));
                     return(true);
                 }
             }
         }
     }
     return(null);
 }
Ejemplo n.º 5
0
        void cMapSave(ConsoleSystem.Arg arg)
        {
            if (arg.connection != null && arg.connection.authLevel < 2)
            {
                return;
            }
            if (SaveRestore.IsSaving)
            {
                SendReply(arg, lang.GetMessage("alreadysaving", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
            SaveBackupCreate();
            string saveName;

            saveName = saveFolder + SaveRestore.SaveFileName;
            try {
                foreach (BaseEntity current in BaseEntity.saveList)
                {
                    current.InvalidateNetworkCache();
                }
                IEnumerator enumerator = SaveRestore.Save(saveName, true);
                while (enumerator.MoveNext())
                {
                }
                Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { saveName, "custom" }));
                arg.ReplyWith(lang.GetMessage("customsavecomplete", this, arg.connection != null ? arg.connection.userid.ToString() : null));
            }
            catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
        }
Ejemplo n.º 6
0
 public void Initialize(
     bool loadSave            = true,
     string saveFile          = "",
     bool allowOutOfDateSaves = false,
     bool skipInitialSpawn    = false)
 {
     if (!ConVar.Server.official)
     {
         ExceptionReporter.set_Disabled(true);
     }
     this.persistance = new UserPersistance(ConVar.Server.rootFolder);
     this.SpawnMapEntities();
     if (Object.op_Implicit((Object)SingletonComponent <SpawnHandler> .Instance))
     {
         using (TimeWarning.New("SpawnHandler.UpdateDistributions", 0.1f))
             ((SpawnHandler)SingletonComponent <SpawnHandler> .Instance).UpdateDistributions();
     }
     if (loadSave)
     {
         skipInitialSpawn = SaveRestore.Load(saveFile, allowOutOfDateSaves);
     }
     if (Object.op_Implicit((Object)SingletonComponent <SpawnHandler> .Instance))
     {
         if (!skipInitialSpawn)
         {
             using (TimeWarning.New("SpawnHandler.InitialSpawn", 200L))
                 ((SpawnHandler)SingletonComponent <SpawnHandler> .Instance).InitialSpawn();
         }
         using (TimeWarning.New("SpawnHandler.StartSpawnTick", 200L))
             ((SpawnHandler)SingletonComponent <SpawnHandler> .Instance).StartSpawnTick();
     }
     this.CreateImportantEntities();
     this.auth = (ConnectionAuth)((Component)this).GetComponent <ConnectionAuth>();
 }
Ejemplo n.º 7
0
        void cLoadFile(ConsoleSystem.Arg arg)
        {
            if (arg.connection != null && arg.connection.authLevel < 2)
            {
                return;
            }
            if (arg.Args == null || arg.Args.Length < 1)
            {
                SendReply(arg, lang.GetMessage("definefilename", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
            int folderNumber = -1;

            if (arg.Args[0].Length <= 4 && arg.Args[0] != "last" && !int.TryParse(arg.Args[0], out folderNumber))
            {
                SendReply(arg, lang.GetMessage("lastfilename", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
            string file = "";

            if (arg.Args[0] == "last")
            {
                List <string> filename = Interface.Oxide.DataFileSystem.ReadObject <List <string> >(this.Title);
                if (filename != null)
                {
                    file = filename.First();
                }
            }
            else if (int.TryParse(arg.Args[0], out folderNumber))
            {
                file = $"{ConVar.Server.rootFolder}/saves/{folderNumber}/{SaveRestore.SaveFileName}";
            }
            if (file == "")
            {
                file = saveFolder + arg.Args[0];
            }

            foreach (var player in BasePlayer.activePlayerList.ToList())
            {
                player.Kick(lang.GetMessage("kickreason", this));
            }

            if (SaveRestore.Load(file, allowOutOfDateSaves))
            {
                if (saveAfterLoadFile)
                {
                    foreach (BaseEntity current in BaseEntity.saveList)
                    {
                        current.InvalidateNetworkCache();
                    }
                    SaveRestore.Save(true);
                }
            }
            else
            {
                SendReply(arg, lang.GetMessage("filenotfound", this, arg.connection != null ? arg.connection.userid.ToString() : null));
                return;
            }
        }
Ejemplo n.º 8
0
 void OnServerInitialized()
 {
     saveRestore           = SingletonComponent <SaveRestore> .Instance;
     saveRestore.timedSave = false;
     saveFolder            = $"{ConVar.Server.rootFolder}/saves/{0}/";
     timer.Every(saveInterval, SaveLoop);
     Initialized = true;
     Puts(lang.GetMessage("loadedinfo", this), saveInterval, saveCustomAfter);
 }
Ejemplo n.º 9
0
        IEnumerator SaveLoop()
        {
            if (!Initialized)
            {
                yield return(null);
            }
            WaitForFixedUpdate waitU = new WaitForFixedUpdate();

            BaseEntity.saveList.RemoveWhere(p => !p);
            BaseEntity.saveList.RemoveWhere(p => p == null);
            Diag.Stopwatch stopwatch = Diag.Stopwatch.StartNew();
            foreach (BaseEntity current in BaseEntity.saveList)
            {
                current.InvalidateNetworkCache();
            }
            Debug.Log("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds");
            if (Rounds < saveCustomAfter && saveCustomAfter > 0)
            {
                IEnumerator original = SaveRestore.Save(ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, true);
                while (original.MoveNext())
                {
                }
                Debug.Log("Saving complete");
                if (!callOnServerSave)
                {
                    Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, "default" }));
                }
                Rounds++;
                CallOnServerSave();
            }
            else
            {
                string file = saveFolder + SaveRestore.SaveFileName;
                DirectoryEx.Backup(SaveFolders());
                yield return(waitU);

                ConVar.Server.GetServerFolder("saves/0/");
                yield return(waitU);

                try {
                    IEnumerator custom = SaveRestore.Save(file, true);
                    while (custom.MoveNext())
                    {
                    }
                    Debug.Log("Custom Saving complete");
                    if (!callOnServerSave)
                    {
                        Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { file, "custom" }));
                    }
                }
                catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
                CallOnServerSave();
                Rounds = 0;
            }
            yield return(null);
        }
Ejemplo n.º 10
0
        public static void save(Arg arg)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (BaseEntity save in BaseEntity.saveList)
            {
                save.InvalidateNetworkCache();
            }
            UnityEngine.Debug.Log("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds");
            SaveRestore.Save(true);
        }
Ejemplo n.º 11
0
        public static void save(ConsoleSystem.Arg arg)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (BaseNetworkable save in BaseEntity.saveList)
            {
                save.InvalidateNetworkCache();
            }
            Debug.Log((object)("Invalidate Network Cache took " + stopwatch.Elapsed.TotalSeconds.ToString("0.00") + " seconds"));
            SaveRestore.Save(true);
        }
Ejemplo n.º 12
0
 void SaveLoop()
 {
     if (!Initialized)
     {
         return;
     }
     if (Rounds < saveCustomAfter && saveCustomAfter > 0)
     {
         foreach (BaseEntity current in BaseEntity.saveList)
         {
             current.InvalidateNetworkCache();
         }
         if (callOnServerSave)
         {
             timer.Once(delayCallOnServerSave, () => Interface.CallHook("OnServerSave", null));
         }
         IEnumerator original = SaveRestore.Save(ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, true);
         while (original.MoveNext())
         {
         }
         if (!callOnServerSave)
         {
             Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, "default" }));
         }
         Rounds++;
     }
     else
     {
         string file = saveFolder + SaveRestore.SaveFileName;
         if (callOnServerSave)
         {
             timer.Once(delayCallOnServerSave, () => Interface.CallHook("OnServerSave", file));
         }
         try {
             SaveBackupCreate();
             foreach (BaseEntity current in BaseEntity.saveList)
             {
                 current.InvalidateNetworkCache();
             }
             IEnumerator custom = SaveRestore.Save(file, true);
             while (custom.MoveNext())
             {
             }
             if (!callOnServerSave)
             {
                 Interface.Oxide.DataFileSystem.WriteObject(this.Title, new List <object>(new object[] { file, "custom" }));
             }
         }
         catch { PrintWarning(lang.GetMessage("dirnotfound", this)); }
         Rounds = 0;
     }
 }
Ejemplo n.º 13
0
 void cmdConsoleSave(ConsoleSystem.Arg arg)
 {
     if (arg.connection != null)
     {
         if (arg.connection.authLevel < saveAuth)
         {
             SendReply(arg, noAccess);
             return;
         }
     }
     SaveRestore.Save();
     SendReply(arg, saved);
 }
Ejemplo n.º 14
0
        public static void save(ConsoleSystem.Arg arg)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            foreach (BaseEntity baseEntity in BaseEntity.saveList)
            {
                baseEntity.InvalidateNetworkCache();
            }
            double totalSeconds = stopwatch.Elapsed.TotalSeconds;

            UnityEngine.Debug.Log(string.Concat("Invalidate Network Cache took ", totalSeconds.ToString("0.00"), " seconds"));
            SaveRestore.Save(true);
        }
Ejemplo n.º 15
0
 void cLoadMap(ConsoleSystem.Arg arg)
 {
     if (arg.connection != null && arg.connection.authLevel < 2)
     {
         return;
     }
     if (arg.Args == null || arg.Args.Length != 1 || arg.Args[0] != "force")
     {
         SendReply(arg, lang.GetMessage("needconfirm", this, arg.connection != null ? arg.connection.userid.ToString() : null));
         return;
     }
     foreach (var player in BasePlayer.activePlayerList.ToList())
     {
         player.Kick(lang.GetMessage("kickreason", this, player.UserIDString));
     }
     SaveRestore.Load(ConVar.Server.rootFolder + "/" + SaveRestore.SaveFileName, allowOutOfDateSaves);
 }
Ejemplo n.º 16
0
 void cmdChatSave(BasePlayer player, string command, string[] args)
 {
     if (!hasPermission(player))
     {
         SendReply(player, noAccess); return;
     }
     SaveRestore.Save();
     SendReply(player, saved);
     if (args.Length > 0)
     {
         float value;
         if (float.TryParse(args[0], out value))
         {
             ConsoleSystem.Run.Server.Normal("server.saveinterval " + args[0], new object[] { });
             SendReply(player, "set: server.saveinterval " + args[0]);
         }
     }
 }
Ejemplo n.º 17
0
 void cLoadNamed(ConsoleSystem.Arg arg)
 {
     if (arg.Connection != null && arg.Connection.authLevel < 2)
     {
         return;
     }
     if (arg.Args == null || arg.Args.Length < 1)
     {
         SendReply(arg, lang.GetMessage("definefilename", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
         return;
     }
     foreach (var player in BasePlayer.activePlayerList.ToList())
     {
         player.Kick(lang.GetMessage("kickreason", this));
     }
     foreach (BaseEntity current in BaseEntity.saveList.ToList())
     {
         if (current != null)
         {
             current.Kill();
         }
     }
     BaseEntity.saveList.Clear();
     ItemManager.DoRemoves();
     if (SaveRestore.Load(ConVar.Server.rootFolder + "/" + arg.Args[0], true))
     {
         if (saveAfterLoadFile)
         {
             foreach (BaseEntity current in BaseEntity.saveList)
             {
                 current.InvalidateNetworkCache();
             }
             SaveRestore.Save(true);
         }
     }
     else
     {
         SendReply(arg, lang.GetMessage("filenotfound", this, arg.Connection != null ? arg.Connection.userid.ToString() : null));
         return;
     }
 }
Ejemplo n.º 18
0
    public static IEnumerator StartServer(
        bool doLoad,
        string saveFileOverride,
        bool allowOutOfDateSaves)
    {
        float timeScale = Time.get_timeScale();

        if (Time.pausewhileloading)
        {
            Time.set_timeScale(0.0f);
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if (Object.op_Implicit((Object)SingletonComponent <WorldSetup> .Instance))
        {
            yield return((object)((MonoBehaviour)SingletonComponent <WorldSetup> .Instance).StartCoroutine(((WorldSetup)SingletonComponent <WorldSetup> .Instance).InitCoroutine()));
        }
        if (Object.op_Implicit((Object)SingletonComponent <DynamicNavMesh> .Instance) && ((Behaviour)SingletonComponent <DynamicNavMesh> .Instance).get_enabled() && !AiManager.nav_disable)
        {
            yield return((object)((MonoBehaviour)SingletonComponent <DynamicNavMesh> .Instance).StartCoroutine(((DynamicNavMesh)SingletonComponent <DynamicNavMesh> .Instance).UpdateNavMeshAndWait()));
        }
        if (Object.op_Implicit((Object)SingletonComponent <AiManager> .Instance) && ((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled())
        {
            ((AiManager)SingletonComponent <AiManager> .Instance).Initialize();
            if (!AiManager.nav_disable && AI.npc_enable && Object.op_Inequality((Object)TerrainMeta.Path, (Object)null))
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (monument.HasNavmesh)
                    {
                        yield return((object)monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                    }
                }
            }
        }
        GameObject prefab = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab", true);

        Object.DontDestroyOnLoad((Object)prefab);
        ServerMgr serverMgr = (ServerMgr)prefab.GetComponent <ServerMgr>();

        serverMgr.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves, false);
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        serverMgr.OpenConnection();
        if (Time.pausewhileloading)
        {
            Time.set_timeScale(timeScale);
        }
        Bootstrap.WriteToLog("Server startup complete");
    }
Ejemplo n.º 19
0
    public static IEnumerator StartServer(bool doLoad, string saveFileOverride, bool allowOutOfDateSaves)
    {
        float timeScale = UnityEngine.Time.timeScale;

        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = 0f;
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if ((bool)SingletonComponent <WorldSetup> .Instance)
        {
            yield return(SingletonComponent <WorldSetup> .Instance.StartCoroutine(SingletonComponent <WorldSetup> .Instance.InitCoroutine()));
        }
        if ((bool)SingletonComponent <DynamicNavMesh> .Instance && SingletonComponent <DynamicNavMesh> .Instance.enabled && !AiManager.nav_disable)
        {
            yield return(SingletonComponent <DynamicNavMesh> .Instance.StartCoroutine(SingletonComponent <DynamicNavMesh> .Instance.UpdateNavMeshAndWait()));
        }
        if ((bool)SingletonComponent <AiManager> .Instance && SingletonComponent <AiManager> .Instance.enabled)
        {
            SingletonComponent <AiManager> .Instance.Initialize();

            if (!AiManager.nav_disable && AI.npc_enable && TerrainMeta.Path != null)
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (monument.HasNavmesh)
                    {
                        yield return(monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                    }
                }
                if ((bool)TerrainMeta.Path && (bool)TerrainMeta.Path.DungeonRoot)
                {
                    DungeonNavmesh dungeonNavmesh = TerrainMeta.Path.DungeonRoot.AddComponent <DungeonNavmesh>();
                    dungeonNavmesh.NavMeshCollectGeometry = NavMeshCollectGeometry.PhysicsColliders;
                    dungeonNavmesh.LayerMask = 65537;
                    yield return(dungeonNavmesh.StartCoroutine(dungeonNavmesh.UpdateNavMeshAndWait()));
                }
                else
                {
                    Debug.LogError("Failed to find DungeonRoot, NOT generating Dungeon navmesh");
                }
            }
        }
        GameObject gameObject = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab");

        Object.DontDestroyOnLoad(gameObject);
        ServerMgr serverMgr = gameObject.GetComponent <ServerMgr>();

        serverMgr.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves);
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        BaseGameMode.CreateGameMode();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        serverMgr.OpenConnection();
        CompanionServer.Server.Initialize();
        using (BenchmarkTimer.New("Boombox.LoadStations"))
        {
            BoomBox.LoadStations();
        }
        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = timeScale;
        }
        WriteToLog("Server startup complete");
    }
Ejemplo n.º 20
0
    public static IEnumerator StartServer(bool doLoad, string saveFileOverride, bool allowOutOfDateSaves)
    {
        float single = UnityEngine.Time.timeScale;

        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = 0f;
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if (SingletonComponent <WorldSetup> .Instance)
        {
            yield return(SingletonComponent <WorldSetup> .Instance.StartCoroutine(SingletonComponent <WorldSetup> .Instance.InitCoroutine()));
        }
        if (SingletonComponent <DynamicNavMesh> .Instance && SingletonComponent <DynamicNavMesh> .Instance.enabled && !AiManager.nav_disable)
        {
            yield return(SingletonComponent <DynamicNavMesh> .Instance.StartCoroutine(SingletonComponent <DynamicNavMesh> .Instance.UpdateNavMeshAndWait()));
        }
        if (SingletonComponent <AiManager> .Instance && SingletonComponent <AiManager> .Instance.enabled)
        {
            SingletonComponent <AiManager> .Instance.Initialize();

            if (!AiManager.nav_disable && AI.npc_enable && TerrainMeta.Path != null)
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (!monument.HasNavmesh)
                    {
                        continue;
                    }
                    yield return(monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                }
            }
        }
        GameObject gameObject = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab", true);

        UnityEngine.Object.DontDestroyOnLoad(gameObject);
        ServerMgr component = gameObject.GetComponent <ServerMgr>();

        component.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves, false);
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        component.OpenConnection();
        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = single;
        }
        Bootstrap.WriteToLog("Server startup complete");
    }