Exemple #1
0
 //in Terraria.Main.DrawInventory replace
 //  Lang.mapLegend[MapHelper.TileToLookup(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62], 0)]
 //  with Lang.mapLegend.FromType(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62])
 //in Terraria.Main.DrawInfoAccs replace Lang.mapLegend[MapHelper.TileToLookup(Main.player[Main.myPlayer].bestOre, 0)]
 //  with Lang.mapLegend.FromType(Main.player[Main.myPlayer].bestOre)
 public string FromType(int type)
 {
     if (type >= TileID.Count)
     {
         return(TileLoader.GetTile(type).MapName(0, 0));
     }
     return(this[MapHelper.TileToLookup(type, 0)]);
 }
Exemple #2
0
 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;
 }
Exemple #3
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]);
     }
 }
Exemple #4
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;
     }
 }
Exemple #5
0
 /// <summary>
 /// Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null.
 /// </summary>
 /// <param name="type">The type of the ModTile</param>
 /// <returns>The ModTile instance in the tiles array, null if not found.</returns>
 public static ModTile GetModTile(int type) => TileLoader.GetTile(type);