Example #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();
            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 #2
0
        public void AddConfig(string name, ModConfig mc)
        {
            mc.Name = name;
            mc.Mod  = this;

            ConfigManager.Add(mc);
            ContentInstance.Register(mc);
        }
Example #3
0
        protected override sealed void Register()
        {
            Slot = UgBgStyleLoader.ReserveBackgroundSlot();

            ModTypeLookup <ModUgBgStyle> .Register(this);

            UgBgStyleLoader.ugBgStyles.Add(this);
            ContentInstance.Register(this);
        }
Example #4
0
 public void AddContent(ILoadable instance)
 {
     if (!loading)
     {
         throw new Exception(Language.GetTextValue("tModLoader.LoadErrorNotLoading"));
     }
     instance.Load(this);
     content.Add(instance);
     ContentInstance.Register(instance);
 }
Example #5
0
        internal static void RegisterDefaultClasses()
        {
            int i = 0;

            foreach (var damageClass in DamageClasses)
            {
                damageClass.Type = i++;
                ContentInstance.Register(damageClass);
                ModTypeLookup <DamageClass> .Register(damageClass);
            }
        }
Example #6
0
        internal static void RegisterDefaultDisplays()
        {
            int i = 0;

            foreach (var infoDisplay in InfoDisplays)
            {
                infoDisplay.Type = i++;
                ContentInstance.Register(infoDisplay);
                ModTypeLookup <InfoDisplay> .Register(infoDisplay);
            }
        }
Example #7
0
        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();
        }
Example #8
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);
            }
        }
Example #9
0
        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.LoadResources();
                mod.Autoload();
                mod.Load();
                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();
            });

            MemoryTracking.Finish();

            if (Main.dedServ)
            {
                ModNet.AssignNetIDs();
            }

            Main.player[255] = new Player(false);             // setup inventory is unnecessary

            RefreshModLanguage(Language.ActiveCulture);
            MapLoader.SetupModMap();
            ItemSorting.SetupWhiteLists();
            PlayerInput.reinitialize = true;
            SetupRecipes(token);
        }