Example #1
0
        internal static void UnloadModContent()
        {
            MenuLoader.Unload();             //do this early, so modded menus won't be active when unloaded
            int i = 0;

            foreach (var mod in ModLoader.Mods.Reverse())
            {
                try {
                    if (Main.dedServ)
                    {
                        Console.WriteLine($"Unloading {mod.DisplayName}...");
                    }
                    else
                    {
                        Interface.loadMods.SetCurrentMod(i++, mod.DisplayName);
                    }
                    mod.Close();
                    mod.UnloadContent();
                }
                catch (Exception e) {
                    e.Data["mod"] = mod.Name;
                    throw;
                }
                finally {
                    MonoModHooks.RemoveAll(mod);
                }
            }
        }
Example #2
0
        internal static void Load(CancellationToken token)
        {
            CacheVanillaState();

            Interface.loadMods.SetLoadStage("tModLoader.MSIntializing", ModLoader.Mods.Length);
            LoadModContent(token, mod => {
                ContentInstance.Register(mod);
                mod.loading = true;
                mod.AutoloadConfig();
                mod.PrepareAssets();
                mod.Autoload();
                mod.Load();
                SystemHooks.OnModLoad(mod);
                mod.loading = false;
            });

            Interface.loadMods.SetLoadStage("tModLoader.MSSettingUp");
            ResizeArrays();
            RecipeGroupHelper.FixRecipeGroupLookups();

            Interface.loadMods.SetLoadStage("tModLoader.MSLoading", ModLoader.Mods.Length);
            LoadModContent(token, mod => {
                mod.SetupContent();
                mod.PostSetupContent();
                SystemHooks.PostSetupContent(mod);
            });

            MemoryTracking.Finish();

            if (Main.dedServ)
            {
                ModNet.AssignNetIDs();
            }

            Main.player[255] = new Player(false);             // setup inventory is unnecessary

            RefreshModLanguage(Language.ActiveCulture);
            MapLoader.SetupModMap();
            RarityLoader.Initialize();

            ContentSamples.Initialize();
            PlayerInput.reinitialize = true;
            SetupBestiary(token);
            SetupRecipes(token);
            ContentSamples.RebuildItemCreativeSortingIDsAfterRecipesAreSetUp();
            ItemSorting.SetupWhiteLists();

            MenuLoader.GotoSavedModMenu();
            BossBarLoader.GotoSavedStyle();
        }
Example #3
0
 protected sealed override void Register()
 {
     MenuLoader.Add(this);
 }