Exemplo 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();
 }
Exemplo 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;
     }
 }
Exemplo 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);
                }
            }
        }
Exemplo 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();
        }
Exemplo n.º 5
0
        //Called by ModGore.Register
        internal static void RegisterModGore(ModGore modGore)
        {
            int id = GoreCount++;

            modGore.Type = id;

            gores[id] = modGore;
        }
Exemplo 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;
            }
        }
Exemplo 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;
            }
        }
Exemplo n.º 8
0
        public int GoreType(string name)
        {
            ModGore gore = GetGore(name);

            if (gore == null)
            {
                return(0);
            }
            return(gore.Type);
        }
Exemplo 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;
        }
Exemplo 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);
            }
        }
Exemplo 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();
 }
Exemplo 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);
            }
        }
Exemplo 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);
            }
        }
Exemplo 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);
            }
        }
Exemplo 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();
        }
Exemplo 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;
            }
        }
Exemplo 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);
 }
Exemplo 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();
 }
Exemplo 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;
 }
Exemplo 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);
Exemplo 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;
     }
 }
Exemplo n.º 22
0
 public int GetGoreSlot(string name)
 {
     return(ModGore.GetGoreSlot(FileName(name)));
 }