private static void ReadNetIDs(BinaryReader reader) { Mod[] mods = ModLoader.Mods; var list = new List <Mod>(); int n = reader.ReadInt32(); for (short i = 0; i < n; i++) { string name = reader.ReadString(); Mod mod = mods.SingleOrDefault(m => m.Name == name); list.Add(mod); if (mod != null) //nosync mod that doesn't exist on the client { mod.netID = i; } } netMods = list.ToArray(); SetupDiagnostics(); ItemLoader.ReadNetGlobalOrder(reader); SystemHooks.ReadNetSystemOrder(reader); int serverMaxBuffs = reader.ReadInt32(); if (serverMaxBuffs != Player.MaxBuffs) { Netplay.Disconnect = true; Main.statusText = $"The server expects Player.MaxBuffs of {serverMaxBuffs}\nbut this client reports {Player.MaxBuffs}.\nSome mod is behaving poorly."; } }
internal static bool HijackGetData(ref byte messageType, ref BinaryReader reader, int playerNumber) { if (netMods == null) { return(false); } return(SystemHooks.HijackGetData(ref messageType, ref reader, playerNumber)); }
public static void ChooseWaterStyle(ref int style) { foreach (ModWaterStyle waterStyle in waterStyles) { if (waterStyle.ChooseWaterStyle()) { style = waterStyle.Type; } } SystemHooks.ChooseWaterStyle(ref style); }
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 SendNetIDs(int toClient) { var p = new ModPacket(MessageID.ModPacket); p.Write(netMods.Length); foreach (Mod mod in netMods) { p.Write(mod.Name); } ItemLoader.WriteNetGlobalOrder(p); SystemHooks.WriteNetSystemOrder(p); p.Write(Player.MaxBuffs); p.Send(toClient); }
//TODO: Unhardcode ALL of this. private static void ResizeArrays(bool unloading = false) { DamageClassLoader.ResizeArrays(); ItemLoader.ResizeArrays(unloading); EquipLoader.ResizeAndFillArrays(); PrefixLoader.ResizeArrays(); DustLoader.ResizeArrays(); TileLoader.ResizeArrays(unloading); WallLoader.ResizeArrays(unloading); TileIO.ResizeArrays(); ProjectileLoader.ResizeArrays(); NPCLoader.ResizeArrays(unloading); NPCHeadLoader.ResizeAndFillArrays(); MountLoader.ResizeArrays(); BuffLoader.ResizeArrays(); PlayerHooks.RebuildHooks(); PlayerDrawLayerLoader.ResizeArrays(); SystemHooks.ResizeArrays(); if (!Main.dedServ) { SoundLoader.ResizeAndFillArrays(); BackgroundTextureLoader.ResizeAndFillArrays(); UgBgStyleLoader.ResizeAndFillArrays(); SurfaceBgStyleLoader.ResizeAndFillArrays(); GlobalBgStyleLoader.ResizeAndFillArrays(unloading); GoreLoader.ResizeAndFillArrays(); WaterStyleLoader.ResizeArrays(); WaterfallStyleLoader.ResizeArrays(); } foreach (LocalizedText text in LanguageManager.Instance._localizedTexts.Values) { text.Override = null; } }
//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(); }
protected override void Register() { SystemHooks.Add(this); ModTypeLookup <ModSystem> .Register(this); }
internal static bool HijackSendData(int whoAmI, int msgType, int remoteClient, int ignoreClient, NetworkText text, int number, float number2, float number3, float number4, int number5, int number6, int number7) => SystemHooks.HijackSendData(whoAmI, msgType, remoteClient, ignoreClient, text, number, number2, number3, number4, number5, number6, number7);