Exemplo n.º 1
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.º 2
0
        //in Terraria.Map.MapHelper.GetMapTileXnaColor after result is initialized call
        //  TileLoader.MapColor(tile, ref result);
        internal static void MapColor(MapTile mapTile, ref Color color)
        {
            Tile tile = Main.tile[mapTile.x, mapTile.y];

            if (tile.active())
            {
                ModTile modTile = GetTile(tile.type);
                if (modTile != null)
                {
                    Color?modColor = modTile.MapColor(mapTile.x, mapTile.y);
                    if (modColor.HasValue)
                    {
                        color = modColor.Value;
                    }
                }
            }
            else
            {
                ModWall modWall = WallLoader.GetWall(tile.wall);
                if (modWall != null)
                {
                    Color?modColor = modWall.MapColor(mapTile.x, mapTile.y);
                    if (modColor.HasValue)
                    {
                        color = modColor.Value;
                    }
                }
            }
        }
Exemplo n.º 3
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.º 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
        protected override sealed void Register()
        {
            Type = (ushort)WallLoader.ReserveWallID();

            ModTypeLookup <ModWall> .Register(this);

            WallLoader.walls.Add(this);
        }
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 AddWall(string name, ModWall wall, string texture)
        {
            int id = WallLoader.ReserveWallID();

            wall.Name            = name;
            wall.Type            = (ushort)id;
            walls[name]          = wall;
            WallLoader.walls[id] = wall;
            wall.texture         = texture;
            wall.mod             = this;
        }
Exemplo n.º 8
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.º 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();
        }
Exemplo n.º 10
0
        //make Terraria.Map.MapHelper.colorLookup internal
        //add internal modPosition field to Terraria.Map.MapHelper
        //near end of Terraria.Map.MapHelper.Initialize set modPosition to num11 + 1
        //in Terraria.Map.MapHelper.SaveMap add mod-type-check to darkness check
        internal static void SetupModMap()
        {
            if (Main.dedServ)
            {
                return;
            }
            Array.Resize(ref MapHelper.tileLookup, TileLoader.TileCount());
            Array.Resize(ref MapHelper.wallLookup, WallLoader.WallCount());
            IList <Color>  colors = new List <Color>();
            IList <string> names  = new List <string>();

            foreach (ushort type in tileEntries.Keys)
            {
                MapHelper.tileLookup[type] = (ushort)(MapHelper.modPosition + colors.Count);
                foreach (MapEntry entry in tileEntries[type])
                {
                    ushort mapType = (ushort)(MapHelper.modPosition + colors.Count);
                    entryToTile[mapType] = type;
                    nameFuncs[mapType]   = entry.getName;
                    colors.Add(entry.color);
                    names.Add(entry.name);
                }
            }
            foreach (ushort type in wallEntries.Keys)
            {
                MapHelper.wallLookup[type] = (ushort)(MapHelper.modPosition + colors.Count);
                foreach (MapEntry entry in wallEntries[type])
                {
                    ushort mapType = (ushort)(MapHelper.modPosition + colors.Count);
                    entryToWall[mapType] = type;
                    nameFuncs[mapType]   = entry.getName;
                    colors.Add(entry.color);
                    names.Add(entry.name);
                }
            }
            Array.Resize(ref MapHelper.colorLookup, MapHelper.modPosition + colors.Count);
            Lang.mapLegend.Resize(MapHelper.modPosition + names.Count);
            for (int k = 0; k < colors.Count; k++)
            {
                MapHelper.colorLookup[MapHelper.modPosition + k] = colors[k];
                Lang.mapLegend[MapHelper.modPosition + k]        = names[k];
            }
            initialized = true;
        }
Exemplo n.º 11
0
 //in Terraria.Main.DrawMap replace text = Lang.mapLegend[type]; with
 //  text = Lang.mapLegend[Main.Map[num91, num92]];
 public string this[MapTile mapTile]
 {
     get
     {
         Tile tile = Main.tile[mapTile.x, mapTile.y];
         if (tile.active())
         {
             if (tile.type >= TileID.Count)
             {
                 return(TileLoader.GetTile(tile.type).MapName(tile.frameX, tile.frameY));
             }
         }
         else if (tile.wall >= WallID.Count)
         {
             return(WallLoader.GetWall(tile.wall).mapName);
         }
         return(legend[mapTile.Type]);
     }
 }
Exemplo n.º 12
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.º 13
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.º 14
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.º 15
0
 //at end of Terraria.Map.MapHelper.CreateMapTile before returning call
 //  MapLoader.ModMapOption(ref num16, i, j);
 internal static void ModMapOption(ref ushort mapType, int i, int j)
 {
     if (entryToTile.ContainsKey(mapType))
     {
         ModTile tile   = TileLoader.GetTile(entryToTile[mapType]);
         ushort  option = tile.GetMapOption(i, j);
         if (option < 0 || option >= modTileOptions(tile.Type))
         {
             throw new ArgumentOutOfRangeException("Bad map option for tile " + tile.Name + " from mod " + tile.mod.Name);
         }
         mapType += option;
     }
     else if (entryToWall.ContainsKey(mapType))
     {
         ModWall wall   = WallLoader.GetWall(entryToWall[mapType]);
         ushort  option = wall.GetMapOption(i, j);
         if (option < 0 || option >= modWallOptions(wall.Type))
         {
             throw new ArgumentOutOfRangeException("Bad map option for wall " + wall.Name + " from mod " + wall.mod.Name);
         }
         mapType += option;
     }
 }
Exemplo n.º 16
0
        //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;
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
 /// </summary>
 public static ModWall GetModWall(int type) => WallLoader.GetWall(type);