TModLoader v1.4.4.9
TModLoader source code documentation
Loading...
Searching...
No Matches
Terraria.ModLoader.ModContent Class Reference

Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loader classes. More...

+ Collaboration diagram for Terraria.ModLoader.ModContent:

Static Public Member Functions

static T GetInstance< T > ()
 Returns the template instance of the provided content type (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played).
 
static IEnumerable< T > GetContent< T > ()
 Returns all registered content instances that derive from the provided type and that are added by all currently loaded mods.
This only includes the 'template' instance for each piece of content, not all the clones/new instances which get added to Items/Players/NPCs etc. as the game is played.
 
static T Find< T > (string fullname)
 Attempts to find the template instance with the specified full name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended.
 
static T Find< T > (string modName, string name)
 Attempts to find the template instance with the specified name and mod name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended.
 
static bool TryFind< T > (string fullname, out T value)
 Safely attempts to find the template instance with the specified full name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended.
 
static bool TryFind< T > (string modName, string name, out T value)
 Safely attempts to find the template instance with the specified name and mod name (not the clone/new instance which gets added to Items/Players/NPCs etc. as the game is played). Caching the result is recommended.
 
static void SplitName (string name, out string domain, out string subName)
 
static byte[] GetFileBytes (string name)
 Gets the byte representation of the file with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNameWithExtension". Throws an ArgumentException if the file does not exist.
 
static bool FileExists (string name)
 Returns whether or not a file with the specified name exists.
 
static Asset< T > Request< T > (string name, AssetRequestMode mode=AssetRequestMode.AsyncLoad)
 Gets the asset with the specified name. Throws an Exception if the asset does not exist.
 
static bool HasAsset (string name)
 Returns whether or not a asset with the specified name exists. Includes the mod name prefix like Request.
 
static bool RequestIfExists< T > (string name, out Asset< T > asset, AssetRequestMode mode=AssetRequestMode.AsyncLoad)
 
static ModNPC GetModNPC (int type)
 
static int GetModBossHeadSlot (string texture)
 
static int GetModHeadSlot (string texture)
 
static ModItem GetModItem (int type)
 
static ModDust GetModDust (int type)
 
static ModProjectile GetModProjectile (int type)
 
static ModBuff GetModBuff (int type)
 
static EquipTexture GetEquipTexture (EquipType type, int slot)
 
static ModMount GetModMount (int type)
 
static ModTile GetModTile (int type)
 
static ModWall GetModWall (int type)
 
static ModWaterStyle GetModWaterStyle (int style)
 Returns the ModWaterStyle with the given ID.
 
static ModWaterfallStyle GetModWaterfallStyle (int style)
 Returns the ModWaterfallStyle with the given ID.
 
static int GetModBackgroundSlot (string texture)
 
static ModSurfaceBackgroundStyle GetModSurfaceBackgroundStyle (int style)
 Returns the ModSurfaceBackgroundStyle object with the given ID.
 
static ModUndergroundBackgroundStyle GetModUndergroundBackgroundStyle (int style)
 Returns the ModUndergroundBackgroundStyle object with the given ID.
 
static int GoreType< T > ()
 Get the id (type) of a ModGore by class. Assumes one instance per class.
 
static int ItemType< T > ()
 Get the id (type) of a ModItem by class. Assumes one instance per class.
 
static int PrefixType< T > ()
 Get the id (type) of a ModPrefix by class. Assumes one instance per class.
 
static int RarityType< T > ()
 Get the id (type) of a ModRarity by class. Assumes one instance per class.
 
static int DustType< T > ()
 Get the id (type) of a ModDust by class. Assumes one instance per class.
 
static int TileType< T > ()
 Get the id (type) of a ModTile by class. Assumes one instance per class.
 
static TeleportPylonType PylonType< T > ()
 Get the id (type) of a ModPylon by class. Assumes one instance per class. If nothing is found, returns 0, or the "Forest Pylon" type.
 
static int TileEntityType< T > ()
 Get the id (type) of a ModTileEntity by class. Assumes one instance per class.
 
static int WallType< T > ()
 Get the id (type) of a ModWall by class. Assumes one instance per class.
 
static int ProjectileType< T > ()
 Get the id (type) of a ModProjectile by class. Assumes one instance per class.
 
static int NPCType< T > ()
 Get the id (type) of a ModNPC by class. Assumes one instance per class.
 
static int BuffType< T > ()
 Get the id (type) of a ModBuff by class. Assumes one instance per class.
 
static int MountType< T > ()
 Get the id (type) of a ModMount by class. Assumes one instance per class.
 
static int EmoteBubbleType< T > ()
 Get the id (type) of a ModEmoteBubble by class. Assumes one instance per class.
 
static Stream OpenRead (string assetName, bool newFileStream=false)
 

Static Package Functions

static void Load (CancellationToken token)
 
static void UnloadModContent ()
 
static void Unload ()
 
static void CleanupModReferences ()
 Several arrays and other fields hold references to various classes from mods, we need to clean them up to give properly coded mods a chance to be completely free of references so that they can be collected by the garbage collection. For most things eventually they will be replaced during gameplay, but we want the old instance completely gone quickly.
 
static void TransferCompletedAssets ()
 

Static Private Member Functions

static void CacheVanillaState ()
 
static void LoadModContent (CancellationToken token, Action< Mod > loadAction)
 
static void SetupBestiary ()
 
static void SetupRecipes (CancellationToken token)
 
static void ResizeArrays (bool unloading=false)
 

Static Private Attributes

static readonly char[] nameSplitters = new char[3] { '/', ' ', ':' }
 

Detailed Description

Manages content added by mods. Liasons between mod content and Terraria's arrays and oversees the Loader classes.

Definition at line 37 of file ModContent.cs.


The documentation for this class was generated from the following file: