internal static void ReadNetWorldOrder(BinaryReader r) { short n = r.ReadInt16(); NetWorlds = new ModWorld[n]; for (short i = 0; i < n; i++) { NetWorlds[i] = ModContent.Find <ModWorld>(ModNet.GetMod(r.ReadInt16()).Name, r.ReadString()); } }
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(); }
internal static void Unload() { ContentInstance.Clear(); 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(); HotKeyLoader.Unload(); RecipeHooks.Unload(); CommandManager.Unload(); TagSerializer.Reload(); ModNet.Unload(); Config.ConfigManager.Unload(); CustomCurrencyManager.Initialize(); EffectsTracker.RemoveModEffects(); CleanupModReferences(); }
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); } }
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(); }
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(); }
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(); }
//TODO: Unhardcode ALL of this. internal static void Unload() { ContentInstance.Clear(); ModTypeLookup.Clear(); ItemLoader.Unload(); EquipLoader.Unload(); PrefixLoader.Unload(); DustLoader.Unload(); TileLoader.Unload(); TileEntity.manager.Reset(); WallLoader.Unload(); ProjectileLoader.Unload(); NPCLoader.Unload(); NPCHeadLoader.Unload(); BossBarLoader.Unload(); PlayerHooks.Unload(); BuffLoader.Unload(); MountLoader.Unload(); RarityLoader.Unload(); DamageClassLoader.Unload(); InfoDisplayLoader.Unload(); GoreLoader.Unload(); SoundLoader.Unload(); DisposeMusic(); BackgroundTextureLoader.Unload(); UgBgStyleLoader.Unload(); SurfaceBgStyleLoader.Unload(); GlobalBgStyleLoader.Unload(); WaterStyleLoader.Unload(); WaterfallStyleLoader.Unload(); PlayerDrawLayerLoader.Unload(); SystemHooks.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(); RecipeLoader.Unload(); CommandLoader.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(); }