Esempio n. 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();
 }
Esempio n. 2
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;
     }
 }
Esempio n. 3
0
        private void AutoloadGores(IList <Type> modGores)
        {
            IList <string>             textures     = ModLoader.GetTextures(this);
            string                     goreDir      = Name + "/Gores/";
            IDictionary <string, Type> modGoreNames = new Dictionary <string, Type>();

            foreach (Type type in modGores)
            {
                string modGoreName = (type.Namespace + "." + type.Name).Replace('.', '/');
                modGoreNames[modGoreName] = type;
            }
            foreach (string texture in textures)
            {
                if (texture.IndexOf(goreDir) == 0)
                {
                    string  className = texture.Replace('/', '.');
                    ModGore modGore   = null;
                    if (modGoreNames.ContainsKey(className))
                    {
                        modGore = (ModGore)Activator.CreateInstance(modGoreNames[className]);
                    }
                    AddGore(texture, modGore);
                }
            }
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        //Called by ModGore.Register
        internal static void RegisterModGore(ModGore modGore)
        {
            int id = GoreCount++;

            modGore.Type = id;

            gores[id] = modGore;
        }
Esempio n. 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;
            }
        }
Esempio n. 7
0
        public void AddGore(string texture, ModGore modGore = null)
        {
            int id = ModGore.ReserveGoreID();

            ModGore.gores[texture] = id;
            if (modGore != null)
            {
                ModGore.modGores[id] = modGore;
            }
        }
Esempio n. 8
0
        public int GoreType(string name)
        {
            ModGore gore = GetGore(name);

            if (gore == null)
            {
                return(0);
            }
            return(gore.Type);
        }
Esempio n. 9
0
        public void AddGore(string name, ModGore gore, string texture)
        {
            int id = ModGore.ReserveGoreID();

            gore.Name         = name;
            gore.Type         = id;
            gores[name]       = gore;
            ModGore.gores[id] = gore;
            gore.texture      = texture;
            gore.mod          = this;
        }
Esempio n. 10
0
        private void AutoloadGore(Type type)
        {
            ModGore gore = (ModGore)Activator.CreateInstance(type);

            gore.mod = this;
            string name    = type.Name;
            string texture = (type.Namespace + "." + type.Name).Replace('.', '/');

            if (gore.Autoload(ref name, ref texture))
            {
                AddGore(name, gore, texture);
            }
        }
Esempio n. 11
0
 private static void ResizeArrays(bool unloading = false)
 {
     ItemLoader.ResizeArrays();
     EquipLoader.ResizeAndFillArrays();
     Main.InitializeItemAnimations();
     TileLoader.ResizeArrays(unloading);
     WallLoader.ResizeArrays(unloading);
     ProjectileLoader.ResizeArrays();
     NPCLoader.ResizeArrays();
     ModGore.ResizeArrays();
     NPCHeadLoader.ResizeAndFillArrays();
     ModSound.ResizeArrays();
 }
Esempio n. 12
0
        private void AutoloadGores(IList <Type> modGores)
        {
            var modGoreNames = modGores.ToDictionary(t => t.FullName);

            foreach (string texturePath in Assets.EnumeratePaths <Texture2D>().Where(t => t.StartsWith("Gores/")))
            {
                ModGore modGore = null;
                if (modGoreNames.TryGetValue($"{Name}.{texturePath.Replace('/', '.')}", out Type t))
                {
                    modGore = (ModGore)Activator.CreateInstance(t);
                }

                AddGore($"{Name}/{texturePath}", modGore);
            }
        }
Esempio n. 13
0
        private void AutoloadGores(IList <Type> modGores)
        {
            var modGoreNames = modGores.ToDictionary(t => t.Namespace + "." + t.Name);

            foreach (var texture in textures.Keys.Where(t => t.StartsWith("Gores/")))
            {
                ModGore modGore = null;
                Type    t;
                if (modGoreNames.TryGetValue(Name + "." + texture.Replace('/', '.'), out t))
                {
                    modGore = (ModGore)Activator.CreateInstance(t);
                }

                AddGore(Name + '/' + texture, modGore);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Adds the given texture to the game as a custom gore, with the given custom gore behavior. If no custom gore behavior is provided, the custom gore will have the default vanilla behavior.
        /// </summary>
        /// <param name="texture">The texture.</param>
        /// <param name="modGore">The mod gore.</param>
        public void AddGore(string texture, ModGore modGore = null)
        {
            if (!loading)
            {
                throw new Exception("AddGore can only be called from Mod.Load or Mod.Autoload");
            }

            int id = ModGore.ReserveGoreID();

            ModGore.gores[texture] = id;
            if (modGore != null)
            {
                ModGore.modGores[id] = modGore;
                ContentInstance.Register(modGore);
            }
        }
Esempio n. 15
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();
        }
Esempio n. 16
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;
            }
        }
Esempio n. 17
0
 internal static void Unload()
 {
     foreach (Mod mod in mods.Values)
     {
         mod.Unload();
     }
     loadedMods.Clear();
     ItemLoader.Unload();
     EquipLoader.Unload();
     TileLoader.Unload();
     WallLoader.Unload();
     ProjectileLoader.Unload();
     NPCLoader.Unload();
     ModGore.Unload();
     NPCHeadLoader.Unload();
     ModSound.Unload();
     textures.Clear();
     sounds.Clear();
     mods.Clear();
     ResizeArrays(true);
 }
Esempio n. 18
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();
     NPCHeadLoader.ResizeAndFillArrays();
     ModGore.ResizeAndFillArrays();
     SoundLoader.ResizeAndFillArrays();
     MountLoader.ResizeArrays();
     BuffLoader.ResizeArrays();
     BackgroundTextureLoader.ResizeAndFillArrays();
     UgBgStyleLoader.ResizeAndFillArrays();
     SurfaceBgStyleLoader.ResizeAndFillArrays();
     GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
     WaterStyleLoader.ResizeArrays();
     WaterfallStyleLoader.ResizeArrays();
 }
Esempio n. 19
0
 public void AddGore(string name, ModGore gore, string texture)
 {
     int id = ModGore.ReserveGoreID();
     gore.Name = name;
     gore.Type = id;
     gores[name] = gore;
     ModGore.gores[id] = gore;
     gore.texture = texture;
     gore.mod = this;
 }
Esempio n. 20
0
 /// <summary>
 /// Shorthand for calling ModGore.GetGoreSlot(this.Name + '/' + name).
 /// </summary>
 /// <param name="name">The name.</param>
 /// <returns></returns>
 public int GetGoreSlot(string name) => ModGore.GetGoreSlot(Name + '/' + name);
Esempio n. 21
0
 public void AddGore(string texture, ModGore modGore = null)
 {
     int id = ModGore.ReserveGoreID();
     ModGore.gores[texture] = id;
     if (modGore != null)
     {
         ModGore.modGores[id] = modGore;
     }
 }
Esempio n. 22
0
 public int GetGoreSlot(string name)
 {
     return(ModGore.GetGoreSlot(FileName(name)));
 }