Exemple #1
0
        internal static void Load()
        {
            Interface.loadMods.SetLoadStage("tModLoader.MSIntializing", ModLoader.Mods.Length);
            LoadModContent(mod => {
                mod.loading = true;
                mod.File?.Read(TmodFile.LoadedState.Streaming, mod.LoadResourceFromStream);
                mod.Autoload();
                mod.Load();
                mod.loading = false;
            });

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

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

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

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

            RefreshModLanguage(Language.ActiveCulture);
            MapLoader.SetupModMap();
            ItemSorting.SetupWhiteLists();
            PlayerInput.ReInitialize();
            SetupRecipes();
        }
Exemple #2
0
        internal static void Unload()
        {
            ContentInstance.Clear();
            ModTypeLookup.Clear();
            ItemLoader.Unload();
            EquipLoader.Unload();
            ModPrefix.Unload();
            ModDust.Unload();
            TileLoader.Unload();
            ModTileEntity.UnloadAll();
            WallLoader.Unload();
            ProjectileLoader.Unload();
            NPCLoader.Unload();
            NPCHeadLoader.Unload();
            PlayerHooks.Unload();
            BuffLoader.Unload();
            MountLoader.Unload();
            RarityLoader.Unload();
            DamageClassLoader.Unload();
            ModGore.Unload();
            SoundLoader.Unload();
            DisposeMusic();
            BackgroundTextureLoader.Unload();
            UgBgStyleLoader.Unload();
            SurfaceBgStyleLoader.Unload();
            GlobalBgStyleLoader.Unload();
            WaterStyleLoader.Unload();
            WaterfallStyleLoader.Unload();
            WorldHooks.Unload();
            ResizeArrays(true);
            for (int k = 0; k < Recipe.maxRecipes; k++)
            {
                Main.recipe[k] = new Recipe();
            }
            Recipe.numRecipes = 0;
            RecipeGroupHelper.ResetRecipeGroups();
            Recipe.SetupRecipes();
            MapLoader.UnloadModMap();
            ItemSorting.SetupWhiteLists();
            HotKeyLoader.Unload();
            RecipeHooks.Unload();
            CommandManager.Unload();
            TagSerializer.Reload();
            ModNet.Unload();
            Config.ConfigManager.Unload();
            CustomCurrencyManager.Initialize();
            EffectsTracker.RemoveModEffects();

            // ItemID.Search = IdDictionary.Create<ItemID, short>();
            // NPCID.Search = IdDictionary.Create<NPCID, short>();
            // ProjectileID.Search = IdDictionary.Create<ProjectileID, short>();
            // TileID.Search = IdDictionary.Create<TileID, ushort>();
            // WallID.Search = IdDictionary.Create<WallID, ushort>();
            // BuffID.Search = IdDictionary.Create<BuffID, int>();

            ContentSamples.Initialize();

            CleanupModReferences();
        }
Exemple #3
0
        internal static void Unload()
        {
            while (loadOrder.Count > 0)
            {
                GetMod(loadOrder.Pop()).UnloadContent();
            }

            loadOrder.Clear();
            loadedMods = new Mod[0];

            ItemLoader.Unload();
            EquipLoader.Unload();
            ModPrefix.Unload();
            ModDust.Unload();
            TileLoader.Unload();
            ModTileEntity.Unload();
            WallLoader.Unload();
            ProjectileLoader.Unload();
            NPCLoader.Unload();
            NPCHeadLoader.Unload();
            PlayerHooks.Unload();
            BuffLoader.Unload();
            MountLoader.Unload();
            ModGore.Unload();
            SoundLoader.Unload();
            DisposeMusic();
            BackgroundTextureLoader.Unload();
            UgBgStyleLoader.Unload();
            SurfaceBgStyleLoader.Unload();
            GlobalBgStyleLoader.Unload();
            WaterStyleLoader.Unload();
            WaterfallStyleLoader.Unload();
            mods.Clear();
            WorldHooks.Unload();
            ResizeArrays(true);
            for (int k = 0; k < Recipe.maxRecipes; k++)
            {
                Main.recipe[k] = new Recipe();
            }
            Recipe.numRecipes = 0;
            RecipeGroupHelper.ResetRecipeGroups();
            Recipe.SetupRecipes();
            MapLoader.UnloadModMap();
            ItemSorting.SetupWhiteLists();
            modHotKeys.Clear();
            RecipeHooks.Unload();
            CommandManager.Unload();
            TagSerializer.Reload();
            ModNet.Unload();
            GameContent.UI.CustomCurrencyManager.Initialize();
            CleanupModReferences();

            if (!Main.dedServ && Main.netMode != 1)             //disable vanilla client compatiblity restrictions when reloading on a client
            {
                ModNet.AllowVanillaClients = false;
            }
        }
Exemple #4
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();
        }
Exemple #5
0
        internal static void Unload()
        {
            ItemLoader.Unload();
            EquipLoader.Unload();
            ModPrefix.Unload();
            ModDust.Unload();
            TileLoader.Unload();
            ModTileEntity.Unload();
            WallLoader.Unload();
            ProjectileLoader.Unload();
            NPCLoader.Unload();
            NPCHeadLoader.Unload();
            PlayerHooks.Unload();
            BuffLoader.Unload();
            MountLoader.Unload();
            ModGore.Unload();
            SoundLoader.Unload();
            DisposeMusic();
            BackgroundTextureLoader.Unload();
            UgBgStyleLoader.Unload();
            SurfaceBgStyleLoader.Unload();
            GlobalBgStyleLoader.Unload();
            WaterStyleLoader.Unload();
            WaterfallStyleLoader.Unload();
            WorldHooks.Unload();
            ResizeArrays(true);
            for (int k = 0; k < Recipe.maxRecipes; k++)
            {
                Main.recipe[k] = new Recipe();
            }
            Recipe.numRecipes = 0;
            RecipeGroupHelper.ResetRecipeGroups();
            Recipe.SetupRecipes();
            MapLoader.UnloadModMap();
            ItemSorting.SetupWhiteLists();
            modHotKeys.Clear();
            RecipeHooks.Unload();
            CommandManager.Unload();
            TagSerializer.Reload();
            ModNet.Unload();
            Config.ConfigManager.Unload();
            CustomCurrencyManager.Initialize();
            EffectsTracker.RemoveModEffects();

            CleanupModReferences();
        }
Exemple #6
0
        internal static bool Load()
        {
            try
            {
                Interface.loadMods.SetLoadStage("tModLoader.MSIntializing", ModLoader.Mods.Length);
                LoadModContent(mod => {
                    mod.loading = true;
                    mod.File?.Read(TmodFile.LoadedState.Streaming, mod.LoadResourceFromStream);
                    mod.Autoload();
                    mod.Load();
                    mod.loading = false;
                });

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

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

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

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

                RefreshModLanguage(Language.ActiveCulture);
                MapLoader.SetupModMap();
                ItemSorting.SetupWhiteLists();
                PlayerInput.ReInitialize();
                SetupRecipes();
                return(true);
            }
            catch (LoadingException e)
            {
                ModLoader.DisableMod(e.mod.Name);
                ErrorLogger.LogLoadingError(e.mod.Name, e.mod.Version, e.InnerException, e is AddRecipesException);
                Main.menuMode = Interface.errorMessageID;
                return(false);
            }
        }
Exemple #7
0
        internal static void Unload()
        {
            while (loadOrder.Count > 0)
            {
                GetMod(loadOrder.Pop()).UnloadContent();
            }

            loadOrder.Clear();
            loadedMods = new Mod[0];

            ItemLoader.Unload();
            EquipLoader.Unload();
            ModDust.Unload();
            TileLoader.Unload();
            WallLoader.Unload();
            ProjectileLoader.Unload();
            NPCLoader.Unload();
            NPCHeadLoader.Unload();
            PlayerHooks.Unload();
            BuffLoader.Unload();
            MountLoader.Unload();
            ModGore.Unload();
            SoundLoader.Unload();
            BackgroundTextureLoader.Unload();
            UgBgStyleLoader.Unload();
            SurfaceBgStyleLoader.Unload();
            GlobalBgStyleLoader.Unload();
            WaterStyleLoader.Unload();
            WaterfallStyleLoader.Unload();
            mods.Clear();
            ResizeArrays(true);
            MapLoader.UnloadModMap();
            ItemSorting.SetupWhiteLists();
            modHotKeys.Clear();
            WorldHooks.Unload();
            RecipeHooks.Unload();

            if (!Main.dedServ && Main.netMode != 1)             //disable vanilla client compatiblity restrictions when reloading on a client
            {
                ModNet.AllowVanillaClients = false;
            }
        }
Exemple #8
0
        internal static void Load()
        {
            CacheVanillaState();

            Interface.loadMods.SetLoadStage("tModLoader.MSIntializing", ModLoader.Mods.Length);
            MemoryTracking.Start();
            LoadModContent(mod => {
                mod.AutoloadConfig();
                mod.loading = true;
                mod.LoadResources();
                mod.Autoload();
                mod.Load();
                mod.loading = false;
                MemoryTracking.Load(mod);
            });

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

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

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

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

            RefreshModLanguage(Language.ActiveCulture);
            MapLoader.SetupModMap();
            ItemSorting.SetupWhiteLists();
            PlayerInput.ReInitialize();
            SetupRecipes();
        }
Exemple #9
0
        internal static void do_Load(object threadContext)
        {
            if (!LoadMods())
            {
                Main.menuMode = Interface.errorMessageID;
                return;
            }
            if (Main.dedServ)
            {
                Console.WriteLine(Language.GetTextValue("tModLoader.AddingModContent"));
            }
            int num = 0;

            foreach (Mod mod in mods.Values)
            {
                Interface.loadMods.SetProgressInit(mod.Name, num, mods.Count);
                try
                {
                    mod.loading = true;
                    mod.File?.Read(TmodFile.LoadedState.Streaming, mod.LoadResourceFromStream);
                    mod.Autoload();
                    Interface.loadMods.SetSubProgressInit("");
                    mod.Load();
                    mod.loading = false;
                }
                catch (Exception e)
                {
                    DisableMod(mod.Name);
                    ErrorLogger.LogLoadingError(mod.Name, mod.tModLoaderVersion, e);
                    Main.menuMode = Interface.errorMessageID;
                    return;
                }
                num++;
            }
            Interface.loadMods.SetProgressSetup(0f);
            ResizeArrays();
            RecipeGroupHelper.FixRecipeGroupLookups();
            num = 0;
            foreach (Mod mod in mods.Values)
            {
                Interface.loadMods.SetProgressLoad(mod.Name, num, mods.Count);
                try
                {
                    mod.SetupContent();
                    mod.PostSetupContent();
                    mod.File?.UnloadAssets();
                }
                catch (Exception e)
                {
                    DisableMod(mod.Name);
                    ErrorLogger.LogLoadingError(mod.Name, mod.tModLoaderVersion, e);
                    Main.menuMode = Interface.errorMessageID;
                    return;
                }
                num++;
            }
            RefreshModLanguage(Language.ActiveCulture);

            if (Main.dedServ)
            {
                ModNet.AssignNetIDs();
                //Main.player[0] = new Player();
            }
            Main.player[255] = new Player(false);             // setup inventory is unnecessary

            MapLoader.SetupModMap();
            ItemSorting.SetupWhiteLists();

            Interface.loadMods.SetProgressRecipes();
            for (int k = 0; k < Recipe.maxRecipes; k++)
            {
                Main.recipe[k] = new Recipe();
            }
            Recipe.numRecipes = 0;
            RecipeGroupHelper.ResetRecipeGroups();
            try
            {
                Recipe.SetupRecipes();
            }
            catch (AddRecipesException e)
            {
                ErrorLogger.LogLoadingError(e.modName, version, e.InnerException, true);
                Main.menuMode = Interface.errorMessageID;
                return;
            }

            if (PostLoad != null)
            {
                PostLoad();
                PostLoad = null;
            }
            else
            {
                Main.menuMode = 0;
            }
            GameInput.PlayerInput.ReInitialize();
        }
Exemple #10
0
        internal static void do_Load(object threadContext)
        {
            if (!LoadMods())
            {
                Main.menuMode = Interface.errorMessageID;
                return;
            }
            if (Main.dedServ)
            {
                Console.WriteLine("Adding mod content...");
            }
            int num = 0;

            foreach (Mod mod in mods.Values)
            {
                Interface.loadMods.SetProgressInit(mod.Name, num, mods.Count);
                try
                {
                    mod.Autoload();
                    mod.Load();
                }
                catch (Exception e)
                {
                    DisableMod(mod.File);
                    ErrorLogger.LogLoadingError(mod.Name, mod.tModLoaderVersion, e);
                    Main.menuMode = Interface.errorMessageID;
                    return;
                }
                num++;
            }
            Interface.loadMods.SetProgressSetup(0f);
            ResizeArrays();
            num = 0;
            foreach (Mod mod in mods.Values)
            {
                Interface.loadMods.SetProgressLoad(mod.Name, num, mods.Count);
                try
                {
                    mod.SetupContent();
                    mod.PostSetupContent();
                }
                catch (Exception e)
                {
                    DisableMod(mod.File);
                    ErrorLogger.LogLoadingError(mod.Name, mod.tModLoaderVersion, e);
                    Main.menuMode = Interface.errorMessageID;
                    return;
                }
                num++;
            }

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

            MapLoader.SetupModMap();
            ItemSorting.SetupWhiteLists();

            Interface.loadMods.SetProgressRecipes();
            for (int k = 0; k < Recipe.maxRecipes; k++)
            {
                Main.recipe[k] = new Recipe();
            }
            Recipe.numRecipes = 0;
            RecipeGroupHelper.ResetRecipeGroups();
            try
            {
                Recipe.SetupRecipes();
            }
            catch (AddRecipesException e)
            {
                ErrorLogger.LogLoadingError(e.modName, version, e.InnerException, true);
                Main.menuMode = Interface.errorMessageID;
                return;
            }
            if (PostLoad != null)
            {
                PostLoad();
                PostLoad = null;
            }
            else
            {
                Main.menuMode = 0;
            }
            GameInput.PlayerInput.ReInitialize();
        }