GetItem() public static méthode

public static GetItem ( int type ) : ModItem
type int
Résultat ModItem
Exemple #1
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 #2
0
 /// <summary>
 /// Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the given type.
 /// </summary>
 public static ModItem GetModItem(int type) => ItemLoader.GetItem(type);