コード例 #1
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();
            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();
        }
コード例 #2
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;
            }
        }
コード例 #3
0
ファイル: Mod.cs プロジェクト: DrakoGlyph/tModLoader
 public void AddMusicBox(int musicSlot, int itemType, int tileType, int tileFrameY = 0)
 {
     if (Main.dedServ)
     {
         return;
     }
     if (musicSlot < Main.maxMusic)
     {
         throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla music ID " + musicSlot);
     }
     if (musicSlot >= SoundLoader.SoundCount(SoundType.Music))
     {
         throw new ArgumentOutOfRangeException("Music ID " + musicSlot + " does not exist");
     }
     if (itemType < ItemID.Count)
     {
         throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla item ID " + itemType);
     }
     if (ItemLoader.GetItem(itemType) == null)
     {
         throw new ArgumentOutOfRangeException("Item ID " + itemType + " does not exist");
     }
     if (tileType < TileID.Count)
     {
         throw new ArgumentOutOfRangeException("Cannot assign music box to vanilla tile ID " + tileType);
     }
     if (TileLoader.GetTile(tileType) == null)
     {
         throw new ArgumentOutOfRangeException("Tile ID " + tileType + " does not exist");
     }
     if (SoundLoader.musicToItem.ContainsKey(musicSlot))
     {
         throw new ArgumentException("Music ID " + musicSlot + " has already been assigned a music box");
     }
     if (SoundLoader.itemToMusic.ContainsKey(itemType))
     {
         throw new ArgumentException("Item ID " + itemType + " has already been assigned a music");
     }
     if (!SoundLoader.tileToMusic.ContainsKey(tileType))
     {
         SoundLoader.tileToMusic[tileType] = new Dictionary <int, int>();
     }
     if (SoundLoader.tileToMusic[tileType].ContainsKey(tileFrameY))
     {
         string message = "Y-frame " + tileFrameY + " of tile type " + tileType + " has already been assigned a music";
         throw new ArgumentException(message);
     }
     if (tileFrameY % 36 != 0)
     {
         throw new ArgumentException("Y-frame must be divisible by 36");
     }
     SoundLoader.musicToItem[musicSlot]            = itemType;
     SoundLoader.itemToMusic[itemType]             = musicSlot;
     SoundLoader.tileToMusic[tileType][tileFrameY] = musicSlot;
 }
コード例 #4
0
ファイル: Mod.cs プロジェクト: Unowndeveloper/tModLoader
        public void AddSound(SoundType type, string soundPath, ModSound modSound = null)
        {
            int id = SoundLoader.ReserveSoundID(type);

            SoundLoader.sounds[type][soundPath] = id;
            if (modSound != null)
            {
                SoundLoader.modSounds[type][id] = modSound;
                modSound.sound = ModLoader.GetSound(soundPath);
            }
        }
コード例 #5
0
ファイル: ModLoader.cs プロジェクト: saeym/tModLoader
 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();
     NPCHeadLoader.ResizeAndFillArrays();
     ModGore.ResizeAndFillArrays();
     SoundLoader.ResizeAndFillArrays();
     MountLoader.ResizeArrays();
     BuffLoader.ResizeArrays();
 }
コード例 #6
0
ファイル: ModContent.cs プロジェクト: PhilBill44/tModLoader
        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();
        }
コード例 #7
0
        /// <summary>
        /// Adds the given sound file to the game as the given type of sound and with the given custom sound playing. If no ModSound instance is provided, the custom sound will play in a similar manner as the default vanilla ones.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="soundPath">The sound path.</param>
        /// <param name="modSound">The mod sound.</param>
        public void AddSound(SoundType type, string soundPath, ModSound modSound = null)
        {
            if (!loading)
            {
                throw new Exception("AddSound can only be called from Mod.Load or Mod.Autoload");
            }

            int id = SoundLoader.ReserveSoundID(type);

            SoundLoader.sounds[type][soundPath] = id;

            if (modSound != null)
            {
                SoundLoader.modSounds[type][id] = modSound;

                modSound.Sound = ModContent.GetSound(soundPath);
            }
        }
コード例 #8
0
ファイル: ModLoader.cs プロジェクト: nilfisk/tModLoader
        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;
            }
        }
コード例 #9
0
ファイル: ModLoader.cs プロジェクト: nilfisk/tModLoader
 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();
     NPCHeadLoader.ResizeAndFillArrays();
     ModGore.ResizeAndFillArrays();
     SoundLoader.ResizeAndFillArrays();
     MountLoader.ResizeArrays();
     BuffLoader.ResizeArrays();
     BackgroundTextureLoader.ResizeAndFillArrays();
     UgBgStyleLoader.ResizeAndFillArrays();
     SurfaceBgStyleLoader.ResizeAndFillArrays();
     GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
     WaterStyleLoader.ResizeArrays();
     WaterfallStyleLoader.ResizeArrays();
 }
コード例 #10
0
ファイル: ModContent.cs プロジェクト: vSLG/tModLoader
        //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;
            }
        }
コード例 #11
0
 /// <summary>
 /// Shorthand for calling SoundLoader.GetLegacySoundSlot(type, this.Name + '/' + name).
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public LegacySoundStyle GetLegacySoundSlot(SoundType type, string name) => SoundLoader.GetLegacySoundSlot(type, Name + '/' + name);
コード例 #12
0
 /// <summary>
 /// Shorthand for calling SoundLoader.GetSoundSlot(type, this.Name + '/' + name).
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public int GetSoundSlot(SoundType type, string name) => SoundLoader.GetSoundSlot(type, Name + '/' + name);
コード例 #13
0
ファイル: Mod.cs プロジェクト: Unowndeveloper/tModLoader
 public int GetSoundSlot(SoundType type, string name)
 {
     return(SoundLoader.GetSoundSlot(type, FileName(name)));
 }