Example #1
0
 internal static void Unload()
 {
     while (loadOrder.Count > 0)
     {
         GetMod(loadOrder.Pop()).UnloadContent();
     }
     loadedMods.Clear();
     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();
     textures.Clear();
     sounds.Clear();
     mods.Clear();
     ResizeArrays(true);
     MapLoader.UnloadModMap();
     modHotKeys.Clear();
     WorldHooks.Unload();
 }
Example #2
0
        private static void ReadNetIDs(BinaryReader reader)
        {
            var mods = ModLoader.Mods;
            var list = new List <Mod>();
            var n    = reader.ReadInt32();

            for (short i = 0; i < n; i++)
            {
                var name = reader.ReadString();
                var 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);
            WorldHooks.ReadNetWorldOrder(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.";
            }
        }
Example #3
0
 private static void ResizeArrays(bool unloading = false)
 {
     ItemLoader.ResizeArrays(unloading);
     EquipLoader.ResizeAndFillArrays();
     ModPrefix.ResizeArrays();
     Main.InitializeItemAnimations();
     ModDust.ResizeArrays();
     TileLoader.ResizeArrays(unloading);
     WallLoader.ResizeArrays(unloading);
     ProjectileLoader.ResizeArrays();
     NPCLoader.ResizeArrays(unloading);
     NPCHeadLoader.ResizeAndFillArrays();
     ModGore.ResizeAndFillArrays();
     SoundLoader.ResizeAndFillArrays();
     MountLoader.ResizeArrays();
     BuffLoader.ResizeArrays();
     PlayerHooks.RebuildHooks();
     BackgroundTextureLoader.ResizeAndFillArrays();
     UgBgStyleLoader.ResizeAndFillArrays();
     SurfaceBgStyleLoader.ResizeAndFillArrays();
     GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
     WaterStyleLoader.ResizeArrays();
     WaterfallStyleLoader.ResizeArrays();
     WorldHooks.ResizeArrays();
     foreach (LocalizedText text in LanguageManager.Instance._localizedTexts.Values)
     {
         text.Override = null;
     }
 }
Example #4
0
 public void AddModWorld(string name, ModWorld modWorld)
 {
     modWorld.Name = name;
     worlds[name]  = modWorld;
     modWorld.mod  = this;
     WorldHooks.Add(modWorld);
 }
Example #5
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();
        }
Example #6
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;
            }
        }
Example #7
0
 public static void ChooseWaterStyle(ref int style)
 {
     foreach (ModWaterStyle waterStyle in waterStyles)
     {
         if (waterStyle.ChooseWaterStyle())
         {
             style = waterStyle.Type;
         }
     }
     WorldHooks.ChooseWaterStyle(ref style);
 }
Example #8
0
        internal static void SendNetIDs(int toClient)
        {
            var p = new ModPacket(MessageID.ModPacket);

            p.Write(netMods.Length);
            foreach (var mod in netMods)
            {
                p.Write(mod.Name);
            }

            ItemLoader.WriteNetGlobalOrder(p);
            WorldHooks.WriteNetWorldOrder(p);

            p.Send(toClient);
        }
Example #9
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();
        }
Example #10
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;
            }
        }
Example #11
0
        private static void ReadNetIDs(BinaryReader reader)
        {
            var mods = ModLoader.Mods;
            var list = new List <Mod>();
            var n    = reader.ReadInt32();

            for (short i = 0; i < n; i++)
            {
                var name = reader.ReadString();
                var 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();

            ItemLoader.ReadNetGlobalOrder(reader);
            WorldHooks.ReadNetWorldOrder(reader);
        }
Example #12
0
 private static void ResizeArrays(bool unloading = false)
 {
     ItemLoader.ResizeArrays();
     EquipLoader.ResizeAndFillArrays();
     Main.InitializeItemAnimations();
     ModDust.ResizeArrays();
     TileLoader.ResizeArrays(unloading);
     WallLoader.ResizeArrays(unloading);
     ProjectileLoader.ResizeArrays();
     NPCLoader.ResizeArrays(unloading);
     NPCHeadLoader.ResizeAndFillArrays();
     ModGore.ResizeAndFillArrays();
     SoundLoader.ResizeAndFillArrays();
     MountLoader.ResizeArrays();
     BuffLoader.ResizeArrays();
     BackgroundTextureLoader.ResizeAndFillArrays();
     UgBgStyleLoader.ResizeAndFillArrays();
     SurfaceBgStyleLoader.ResizeAndFillArrays();
     GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
     WaterStyleLoader.ResizeArrays();
     WaterfallStyleLoader.ResizeArrays();
     WorldHooks.ResizeArrays();
 }
Example #13
0
        protected sealed override void Register()
        {
            ModTypeLookup <ModWorld> .Register(this);

            WorldHooks.Add(this);
        }