Terraria ModLoader  0.11.5
A framework for Terraria mods
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 int BuffType< T > ()
 Get the id (type) of a ModBuff by class. Assumes one instance per class. More...
 
static int DustType< T > ()
 Get the id (type) of a ModDust by class. Assumes one instance per class. More...
 
static bool FileExists (string name)
 Returns whether or not a file with the specified name exists. More...
 
static EquipTexture GetEquipTexture (EquipType type, int slot)
 Gets the equipment texture for the specified equipment type and ID. More...
 
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. More...
 
static T GetInstance< T > ()
 
static int GetModBackgroundSlot (string texture)
 Returns the slot/ID of the background texture with the given name. More...
 
static int GetModBossHeadSlot (string texture)
 Gets the index of the boss head texture corresponding to the given texture path. More...
 
static ModBuff GetModBuff (int type)
 Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null. More...
 
static ModDust GetModDust (int type)
 Gets the ModDust instance with the given type. Returns null if no ModDust with the given type exists. More...
 
static int GetModHeadSlot (string texture)
 Gets the index of the head texture corresponding to the given texture path. More...
 
static ModItem GetModItem (int type)
 Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the given type. More...
 
static ModMountData GetModMountData (int type)
 Gets the ModMountData instance corresponding to the given type. Returns null if no ModMountData has the given type. More...
 
static ModNPC GetModNPC (int type)
 Gets the ModNPC instance corresponding to the specified type. More...
 
static ModProjectile GetModProjectile (int type)
 Gets the ModProjectile instance corresponding to the specified type. More...
 
static ModSurfaceBgStyle GetModSurfaceBgStyle (int style)
 Returns the ModSurfaceBgStyle object with the given ID. More...
 
static ModTile GetModTile (int type)
 Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null. More...
 
static ModUgBgStyle GetModUgBgStyle (int style)
 Returns the ModUgBgStyle object with the given ID. More...
 
static ModWall GetModWall (int type)
 Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null. More...
 
static ModWaterfallStyle GetModWaterfallStyle (int style)
 Returns the ModWaterfallStyle with the given ID. More...
 
static ModWaterStyle GetModWaterStyle (int style)
 Returns the ModWaterStyle with the given ID. More...
 
static Music GetMusic (string name)
 Gets the music with the specified name. The name is in the same format as for texture names. Throws an ArgumentException if the music does not exist. Note: SoundMP3 is in the Terraria.ModLoader namespace. More...
 
static SoundEffect GetSound (string name)
 Gets the sound with the specified name. The name is in the same format as for texture names. Throws an ArgumentException if the sound does not exist. Note: SoundEffect is in the Microsoft.Xna.Framework.Audio namespace. More...
 
static Texture2D GetTexture (string name)
 Gets the texture with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNameWithoutExtension". Throws an ArgumentException if the texture does not exist. If a vanilla texture is desired, the format "Terraria/FileNameWithoutExtension" will reference an image from the "terraria/Content/Images" folder. Note: Texture2D is in the Microsoft.Xna.Framework.Graphics namespace. More...
 
static int ItemType< T > ()
 Get the id (type) of a ModItem by class. Assumes one instance per class. More...
 
static int MountType< T > ()
 Get the id (type) of a ModMountData by class. Assumes one instance per class. More...
 
static bool MusicExists (string name)
 Returns whether or not a sound with the specified name exists. More...
 
static int NPCType< T > ()
 Get the id (type) of a ModNPC by class. Assumes one instance per class. More...
 
static Stream OpenRead (string assetName, bool newFileStream=false)
 
static byte PrefixType< T > ()
 Get the id (type) of a ModPrefix by class. Assumes one instance per class. More...
 
static int ProjectileType< T > ()
 Get the id (type) of a ModProjectile by class. Assumes one instance per class. More...
 
static void RefreshModLanguage (GameCulture culture)
 
static bool SoundExists (string name)
 Returns whether or not a sound with the specified name exists. More...
 
static void SplitName (string name, out string domain, out string subName)
 
static bool TextureExists (string name)
 Returns whether or not a texture with the specified name exists. More...
 
static int TileEntityType< T > ()
 Get the id (type) of a ModTileEntity by class. Assumes one instance per class. More...
 
static int TileType< T > ()
 Get the id (type) of a ModTile by class. Assumes one instance per class. More...
 
static int WallType< T > ()
 Get the id (type) of a ModWall by class. Assumes one instance per class. More...
 

Static Private Member Functions

static void CacheVanillaState ()
 
static void DisposeMusic ()
 
static void LoadModContent (CancellationToken token, Action< Mod > loadAction)
 
static void ResizeArrays (bool unloading=false)
 
static LocalizedText SetLocalizedText (Dictionary< string, LocalizedText > dict, LocalizedText value)
 
static void SetupRecipes (CancellationToken token)
 

Static Private Attributes

static readonly string ImagePath = "Content" + Path.DirectorySeparatorChar + "Images"
 

Detailed Description

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

Definition at line 25 of file ModContent.cs.

Member Function Documentation

static int Terraria.ModLoader.ModContent.BuffType< T > ( )
static

Get the id (type) of a ModBuff by class. Assumes one instance per class.

Type Constraints
T :ModBuff 
T :GetInstance<T>() 
T :Type 
static void Terraria.ModLoader.ModContent.CacheVanillaState ( )
staticprivate

Definition at line 386 of file ModContent.cs.

386  {
387  EffectsTracker.CacheVanillaState();
388  }
static void Terraria.ModLoader.ModContent.DisposeMusic ( )
staticprivate

Definition at line 573 of file ModContent.cs.

References Terraria.ModLoader.ModItem.item, and Terraria.ModLoader.ModNPC.npc.

573  {
574  foreach (var music in Main.music.OfType<MusicStreaming>())
575  music.Dispose();
576  }
static int Terraria.ModLoader.ModContent.DustType< T > ( )
static

Get the id (type) of a ModDust by class. Assumes one instance per class.

Type Constraints
T :ModDust 
T :GetInstance<T>() 
T :Type 
static bool Terraria.ModLoader.ModContent.FileExists ( string  name)
static

Returns whether or not a file with the specified name exists.

Definition at line 56 of file ModContent.cs.

References Terraria.ModLoader.Mod.FileExists(), and Terraria.ModLoader.ModLoader.GetMod().

56  {
57  if (!name.Contains('/'))
58  return false;
59 
60  string modName, subName;
61  SplitName(name, out modName, out subName);
62 
63  Mod mod = ModLoader.GetMod(modName);
64  return mod != null && mod.FileExists(subName);
65  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

static EquipTexture Terraria.ModLoader.ModContent.GetEquipTexture ( EquipType  type,
int  slot 
)
static

Gets the equipment texture for the specified equipment type and ID.

Parameters
type
slot
Returns
static byte [] Terraria.ModLoader.ModContent.GetFileBytes ( string  name)
static

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.

Exceptions
MissingResourceExceptionMissing mod: " + name

Definition at line 42 of file ModContent.cs.

References Terraria.ModLoader.Mod.GetFileBytes(), and Terraria.ModLoader.ModLoader.GetMod().

42  {
43  string modName, subName;
44  SplitName(name, out modName, out subName);
45 
46  Mod mod = ModLoader.GetMod(modName);
47  if (mod == null)
48  throw new MissingResourceException("Missing mod: " + name);
49 
50  return mod.GetFileBytes(subName);
51  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

static T Terraria.ModLoader.ModContent.GetInstance< T > ( )
static
Type Constraints
T :class 
T :ContentInstance<T> 
T :Instance 
static int Terraria.ModLoader.ModContent.GetModBackgroundSlot ( string  texture)
static

Returns the slot/ID of the background texture with the given name.

static int Terraria.ModLoader.ModContent.GetModBossHeadSlot ( string  texture)
static

Gets the index of the boss head texture corresponding to the given texture path.

Parameters
texture
Returns
static ModBuff Terraria.ModLoader.ModContent.GetModBuff ( int  type)
static

Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.

static ModDust Terraria.ModLoader.ModContent.GetModDust ( int  type)
static

Gets the ModDust instance with the given type. Returns null if no ModDust with the given type exists.

static int Terraria.ModLoader.ModContent.GetModHeadSlot ( string  texture)
static

Gets the index of the head texture corresponding to the given texture path.

Parameters
textureRelative texture path
Returns
The index of the texture in the heads array, -1 if not found.
static ModItem Terraria.ModLoader.ModContent.GetModItem ( int  type)
static

Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the given type.

static ModMountData Terraria.ModLoader.ModContent.GetModMountData ( int  type)
static

Gets the ModMountData instance corresponding to the given type. Returns null if no ModMountData has the given type.

Parameters
typeThe type of the mount.
Returns
Null if not found, otherwise the ModMountData associated with the mount.
static ModNPC Terraria.ModLoader.ModContent.GetModNPC ( int  type)
static

Gets the ModNPC instance corresponding to the specified type.

Parameters
typeThe type of the npc
Returns
The ModNPC instance in the npcs array, null if not found.
static ModProjectile Terraria.ModLoader.ModContent.GetModProjectile ( int  type)
static

Gets the ModProjectile instance corresponding to the specified type.

Parameters
typeThe type of the projectile
Returns
The ModProjectile instance in the projectiles array, null if not found.
static ModSurfaceBgStyle Terraria.ModLoader.ModContent.GetModSurfaceBgStyle ( int  style)
static

Returns the ModSurfaceBgStyle object with the given ID.

static ModTile Terraria.ModLoader.ModContent.GetModTile ( int  type)
static

Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null.

Parameters
typeThe type of the ModTile
Returns
The ModTile instance in the tiles array, null if not found.
static ModUgBgStyle Terraria.ModLoader.ModContent.GetModUgBgStyle ( int  style)
static

Returns the ModUgBgStyle object with the given ID.

static ModWall Terraria.ModLoader.ModContent.GetModWall ( int  type)
static

Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.

static ModWaterfallStyle Terraria.ModLoader.ModContent.GetModWaterfallStyle ( int  style)
static

Returns the ModWaterfallStyle with the given ID.

static ModWaterStyle Terraria.ModLoader.ModContent.GetModWaterStyle ( int  style)
static

Returns the ModWaterStyle with the given ID.

static Music Terraria.ModLoader.ModContent.GetMusic ( string  name)
static

Gets the music with the specified name. The name is in the same format as for texture names. Throws an ArgumentException if the music does not exist. Note: SoundMP3 is in the Terraria.ModLoader namespace.

Exceptions
MissingResourceExceptionMissing mod: " + name

Definition at line 173 of file ModContent.cs.

References Terraria.ModLoader.ModLoader.GetMod(), and Terraria.ModLoader.Mod.GetMusic().

Referenced by Terraria.ModLoader.SoundLoader.GetSoundSlot().

173  {
174  if (Main.dedServ) { return null; }
175  string modName, subName;
176  SplitName(name, out modName, out subName);
177  Mod mod = ModLoader.GetMod(modName);
178  if (mod == null) { throw new MissingResourceException("Missing mod: " + name); }
179  return mod.GetMusic(subName);
180  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static SoundEffect Terraria.ModLoader.ModContent.GetSound ( string  name)
static

Gets the sound with the specified name. The name is in the same format as for texture names. Throws an ArgumentException if the sound does not exist. Note: SoundEffect is in the Microsoft.Xna.Framework.Audio namespace.

Exceptions
MissingResourceExceptionMissing mod: " + name

Definition at line 141 of file ModContent.cs.

References Terraria.ModLoader.ModLoader.GetMod(), and Terraria.ModLoader.Mod.GetSound().

Referenced by Terraria.ModLoader.Mod.AddSound(), and Terraria.ModLoader.SoundLoader.GetSoundSlot().

141  {
142  if (Main.dedServ)
143  return null;
144 
145  string modName, subName;
146  SplitName(name, out modName, out subName);
147 
148  Mod mod = ModLoader.GetMod(modName);
149  if (mod == null)
150  throw new MissingResourceException("Missing mod: " + name);
151 
152  return mod.GetSound(subName);
153  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static Texture2D Terraria.ModLoader.ModContent.GetTexture ( string  name)
static

Gets the texture with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNameWithoutExtension". Throws an ArgumentException if the texture does not exist. If a vanilla texture is desired, the format "Terraria/FileNameWithoutExtension" will reference an image from the "terraria/Content/Images" folder. Note: Texture2D is in the Microsoft.Xna.Framework.Graphics namespace.

Exceptions
MissingResourceExceptionMissing mod: " + name

Definition at line 71 of file ModContent.cs.

References Terraria.ModLoader.ModLoader.GetMod().

Referenced by Terraria.ModLoader.Mod.AddBackgroundTexture(), Terraria.ModLoader.Mod.AddBossHeadTexture(), Terraria.ModLoader.Mod.AddDust(), Terraria.ModLoader.Mod.AddEquipTexture(), Terraria.ModLoader.Mod.AddMount(), Terraria.ModLoader.Mod.AddNPCHeadTexture(), Terraria.ModLoader.ModProjectile.AutoStaticDefaults(), Terraria.ModLoader.ModItem.AutoStaticDefaults(), Terraria.ModLoader.ModNPC.AutoStaticDefaults(), Terraria.ModLoader.EquipLoader.GetEquipTexture(), Terraria.ModLoader.ModGore.GetGoreSlot(), and Terraria.ModLoader.Mod.LoadMusic().

71  {
72  if (Main.dedServ)
73  return null;
74 
75  string modName, subName;
76  SplitName(name, out modName, out subName);
77  if (modName == "Terraria")
78  return Main.instance.Content.Load<Texture2D>("Images" + Path.DirectorySeparatorChar + subName);
79 
80  Mod mod = ModLoader.GetMod(modName);
81  if (mod == null)
82  throw new MissingResourceException("Missing mod: " + name);
83 
84  return mod.GetTexture(subName);
85  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int Terraria.ModLoader.ModContent.ItemType< T > ( )
static

Get the id (type) of a ModItem by class. Assumes one instance per class.

Type Constraints
T :ModItem 
T :GetInstance<T>() 
T :item.type 
static void Terraria.ModLoader.ModContent.LoadModContent ( CancellationToken  token,
Action< Mod loadAction 
)
staticprivate

Definition at line 391 of file ModContent.cs.

References Terraria.ModLoader.ModLoader.Mods.

391  {
392  MemoryTracking.Checkpoint();
393  int num = 0;
394  foreach (var mod in ModLoader.Mods) {
395  token.ThrowIfCancellationRequested();
396  Interface.loadMods.SetCurrentMod(num++, $"{mod.Name} v{mod.Version}");
397  try {
398  LoadingMod = mod;
399  loadAction(mod);
400  }
401  catch (Exception e) {
402  e.Data["mod"] = mod.Name;
403  throw;
404  }
405  finally {
406  LoadingMod = null;
407  MemoryTracking.Update(mod.Name);
408  }
409  }
410  }
static int Terraria.ModLoader.ModContent.MountType< T > ( )
static

Get the id (type) of a ModMountData by class. Assumes one instance per class.

Type Constraints
T :ModMountData 
T :GetInstance<T>() 
T :Type 
static bool Terraria.ModLoader.ModContent.MusicExists ( string  name)
static

Returns whether or not a sound with the specified name exists.

Definition at line 185 of file ModContent.cs.

References Terraria.ModLoader.BackgroundTextureLoader.GetBackgroundSlot(), Terraria.ModLoader.NPCHeadLoader.GetBossHeadSlot(), Terraria.ModLoader.BuffLoader.GetBuff(), Terraria.ModLoader.ModDust.GetDust(), Terraria.ModLoader.EquipLoader.GetEquipTexture(), Terraria.ModLoader.NPCHeadLoader.GetHeadSlot(), Terraria.ModLoader.ItemLoader.GetItem(), Terraria.ModLoader.ModLoader.GetMod(), Terraria.ModLoader.MountLoader.GetMount(), Terraria.ModLoader.NPCLoader.GetNPC(), Terraria.ModLoader.ProjectileLoader.GetProjectile(), Terraria.ModLoader.SurfaceBgStyleLoader.GetSurfaceBgStyle(), Terraria.ModLoader.TileLoader.GetTile(), Terraria.ModLoader.UgBgStyleLoader.GetUgBgStyle(), Terraria.ModLoader.WallLoader.GetWall(), Terraria.ModLoader.WaterfallStyleLoader.GetWaterfallStyle(), Terraria.ModLoader.WaterStyleLoader.GetWaterStyle(), Terraria.ModLoader.ModItem.item, Terraria.ModLoader.Mod.MusicExists(), Terraria.ModLoader.ModNPC.npc, Terraria.ModLoader.ModProjectile.projectile, Terraria.ModLoader.ModBuff.Type, Terraria.ModLoader.ModMountData.Type, Terraria.ModLoader.ModWall.Type, Terraria.ModLoader.ModTile.Type, Terraria.ModLoader.ModTileEntity.Type, Terraria.ModLoader.ModDust.Type, and Terraria.ModLoader.ModPrefix.Type.

185  {
186  if (!name.Contains('/')) { return false; }
187  string modName, subName;
188  SplitName(name, out modName, out subName);
189  Mod mod = ModLoader.GetMod(modName);
190  return mod != null && mod.MusicExists(subName);
191  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

static int Terraria.ModLoader.ModContent.NPCType< T > ( )
static

Get the id (type) of a ModNPC by class. Assumes one instance per class.

Type Constraints
T :ModNPC 
T :GetInstance<T>() 
T :npc.type 
static Stream Terraria.ModLoader.ModContent.OpenRead ( string  assetName,
bool  newFileStream = false 
)
static

Definition at line 611 of file ModContent.cs.

References Terraria.ModLoader.Mod.GetFileStream(), and Terraria.ModLoader.ModLoader.GetMod().

Referenced by Terraria.ModLoader.Audio.MusicStreaming.EnsureLoaded().

611  {
612  if (!assetName.StartsWith("tmod:"))
613  return File.OpenRead(assetName);
614 
615  SplitName(assetName.Substring(5).Replace('\\', '/'), out var modName, out var entryPath);
616  return ModLoader.GetMod(modName).GetFileStream(entryPath, newFileStream);
617  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static byte Terraria.ModLoader.ModContent.PrefixType< T > ( )
static

Get the id (type) of a ModPrefix by class. Assumes one instance per class.

Type Constraints
T :ModPrefix 
T :GetInstance<T>() 
T :Type 
static int Terraria.ModLoader.ModContent.ProjectileType< T > ( )
static

Get the id (type) of a ModProjectile by class. Assumes one instance per class.

Type Constraints
T :ModProjectile 
T :GetInstance<T>() 
T :projectile.type 
static void Terraria.ModLoader.ModContent.RefreshModLanguage ( GameCulture  culture)
static

Definition at line 519 of file ModContent.cs.

References Terraria.ModLoader.ModBuff.Description, Terraria.ModLoader.ModBuff.DisplayName, Terraria.ModLoader.ModNPC.DisplayName, Terraria.ModLoader.ModItem.DisplayName, Terraria.ModLoader.ModProjectile.DisplayName, Terraria.ModLoader.ModPrefix.DisplayName, Terraria.ModLoader.ModTranslation.GetTranslation(), Terraria.ModLoader.ModItem.item, Terraria.ModLoader.ModTranslation.Key, Terraria.ModLoader.ModLoader.Mods, Terraria.ModLoader.ModNPC.npc, Terraria.ModLoader.ModProjectile.projectile, Terraria.ModLoader.ModItem.Tooltip, Terraria.ModLoader.ModBuff.Type, and Terraria.ModLoader.ModPrefix.Type.

519  {
520  Dictionary<string, LocalizedText> dict = LanguageManager.Instance._localizedTexts;
521  foreach (ModItem item in ItemLoader.items) {
522  LocalizedText text = new LocalizedText(item.DisplayName.Key, item.DisplayName.GetTranslation(culture));
523  Lang._itemNameCache[item.item.type] = SetLocalizedText(dict, text);
524  text = new LocalizedText(item.Tooltip.Key, item.Tooltip.GetTranslation(culture));
525  if (text.Value != null) {
526  text = SetLocalizedText(dict, text);
527  Lang._itemTooltipCache[item.item.type] = ItemTooltip.FromLanguageKey(text.Key);
528  }
529  }
530  foreach (ModPrefix prefix in ModPrefix.prefixes) {
531  LocalizedText text = new LocalizedText(prefix.DisplayName.Key, prefix.DisplayName.GetTranslation(culture));
532  Lang.prefix[prefix.Type] = SetLocalizedText(dict, text);
533  }
534  foreach (var keyValuePair in MapLoader.tileEntries) {
535  foreach (MapEntry entry in keyValuePair.Value) {
536  if (entry.translation != null) {
537  LocalizedText text = new LocalizedText(entry.translation.Key, entry.translation.GetTranslation(culture));
538  SetLocalizedText(dict, text);
539  }
540  }
541  }
542  foreach (var keyValuePair in MapLoader.wallEntries) {
543  foreach (MapEntry entry in keyValuePair.Value) {
544  if (entry.translation != null) {
545  LocalizedText text = new LocalizedText(entry.translation.Key, entry.translation.GetTranslation(culture));
546  SetLocalizedText(dict, text);
547  }
548  }
549  }
550  foreach (ModProjectile proj in ProjectileLoader.projectiles) {
551  LocalizedText text = new LocalizedText(proj.DisplayName.Key, proj.DisplayName.GetTranslation(culture));
552  Lang._projectileNameCache[proj.projectile.type] = SetLocalizedText(dict, text);
553  }
554  foreach (ModNPC npc in NPCLoader.npcs) {
555  LocalizedText text = new LocalizedText(npc.DisplayName.Key, npc.DisplayName.GetTranslation(culture));
556  Lang._npcNameCache[npc.npc.type] = SetLocalizedText(dict, text);
557  }
558  foreach (ModBuff buff in BuffLoader.buffs) {
559  LocalizedText text = new LocalizedText(buff.DisplayName.Key, buff.DisplayName.GetTranslation(culture));
560  Lang._buffNameCache[buff.Type] = SetLocalizedText(dict, text);
561  text = new LocalizedText(buff.Description.Key, buff.Description.GetTranslation(culture));
562  Lang._buffDescriptionCache[buff.Type] = SetLocalizedText(dict, text);
563  }
564  foreach (Mod mod in ModLoader.Mods) {
565  foreach (ModTranslation translation in mod.translations.Values) {
566  LocalizedText text = new LocalizedText(translation.Key, translation.GetTranslation(culture));
567  SetLocalizedText(dict, text);
568  }
569  }
570  LanguageManager.Instance.ProcessCopyCommandsInTexts();
571  }
static LocalizedText SetLocalizedText(Dictionary< string, LocalizedText > dict, LocalizedText value)
Definition: ModContent.cs:338

+ Here is the call graph for this function:

static void Terraria.ModLoader.ModContent.ResizeArrays ( bool  unloading = false)
staticprivate

Definition at line 491 of file ModContent.cs.

491  {
492  ItemLoader.ResizeArrays(unloading);
493  EquipLoader.ResizeAndFillArrays();
494  ModPrefix.ResizeArrays();
495  Main.InitializeItemAnimations();
496  ModDust.ResizeArrays();
497  TileLoader.ResizeArrays(unloading);
498  WallLoader.ResizeArrays(unloading);
499  ProjectileLoader.ResizeArrays();
500  NPCLoader.ResizeArrays(unloading);
501  NPCHeadLoader.ResizeAndFillArrays();
502  ModGore.ResizeAndFillArrays();
503  SoundLoader.ResizeAndFillArrays();
504  MountLoader.ResizeArrays();
505  BuffLoader.ResizeArrays();
506  PlayerHooks.RebuildHooks();
507  BackgroundTextureLoader.ResizeAndFillArrays();
508  UgBgStyleLoader.ResizeAndFillArrays();
509  SurfaceBgStyleLoader.ResizeAndFillArrays();
510  GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
511  WaterStyleLoader.ResizeArrays();
512  WaterfallStyleLoader.ResizeArrays();
513  WorldHooks.ResizeArrays();
514  foreach (LocalizedText text in LanguageManager.Instance._localizedTexts.Values) {
515  text.Override = null;
516  }
517  }
static LocalizedText Terraria.ModLoader.ModContent.SetLocalizedText ( Dictionary< string, LocalizedText >  dict,
LocalizedText  value 
)
staticprivate

Definition at line 338 of file ModContent.cs.

References Terraria.ModLoader.ModLoader.Mods.

338  {
339  if (dict.ContainsKey(value.Key)) {
340  dict[value.Key].SetValue(value.Value);
341  }
342  else {
343  dict[value.Key] = value;
344  }
345  return dict[value.Key];
346  }
static void Terraria.ModLoader.ModContent.SetupRecipes ( CancellationToken  token)
staticprivate

Definition at line 412 of file ModContent.cs.

References Terraria.ModLoader.Console, and Terraria.ModLoader.ModLoader.Mods.

412  {
413  Interface.loadMods.SetLoadStage("tModLoader.MSAddingRecipes");
414  for (int k = 0; k < Recipe.maxRecipes; k++) {
415  token.ThrowIfCancellationRequested();
416  Main.recipe[k] = new Recipe();
417  }
418 
419  Recipe.numRecipes = 0;
420  RecipeGroupHelper.ResetRecipeGroups();
421  Recipe.SetupRecipes();
422  }
static bool Terraria.ModLoader.ModContent.SoundExists ( string  name)
static

Returns whether or not a sound with the specified name exists.

Definition at line 158 of file ModContent.cs.

References Terraria.ModLoader.ModLoader.GetMod(), and Terraria.ModLoader.Mod.SoundExists().

158  {
159  if (!name.Contains('/'))
160  return false;
161 
162  string modName, subName;
163  SplitName(name, out modName, out subName);
164 
165  Mod mod = ModLoader.GetMod(modName);
166  return mod != null && mod.SoundExists(subName);
167  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29

+ Here is the call graph for this function:

static void Terraria.ModLoader.ModContent.SplitName ( string  name,
out string  domain,
out string  subName 
)
static

Definition at line 29 of file ModContent.cs.

29  {
30  int slash = name.IndexOf('/');
31  if (slash < 0)
32  throw new MissingResourceException("Missing mod qualifier: " + name);
33 
34  domain = name.Substring(0, slash);
35  subName = name.Substring(slash + 1);
36  }
static bool Terraria.ModLoader.ModContent.TextureExists ( string  name)
static

Returns whether or not a texture with the specified name exists.

Definition at line 91 of file ModContent.cs.

References Terraria.ModLoader.ModLoader.GetMod(), and Terraria.ModLoader.Mod.TextureExists().

Referenced by Terraria.ModLoader.Mod.AddEquipTexture(), Terraria.ModLoader.Mod.AddMount(), and Terraria.ModLoader.ModItem.AutoStaticDefaults().

91  {
92  if (!name.Contains('/'))
93  return false;
94 
95  string modName, subName;
96  SplitName(name, out modName, out subName);
97 
98  if (modName == "Terraria")
99  return File.Exists(ImagePath + Path.DirectorySeparatorChar + subName + ".xnb");
100 
101  Mod mod = ModLoader.GetMod(modName);
102  return mod != null && mod.TextureExists(subName);
103  }
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:29
static readonly string ImagePath
Definition: ModContent.cs:87

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int Terraria.ModLoader.ModContent.TileEntityType< T > ( )
static

Get the id (type) of a ModTileEntity by class. Assumes one instance per class.

Type Constraints
T :ModTileEntity 
T :GetInstance<T>() 
T :Type 
static int Terraria.ModLoader.ModContent.TileType< T > ( )
static

Get the id (type) of a ModTile by class. Assumes one instance per class.

Type Constraints
T :ModTile 
T :GetInstance<T>() 
T :Type 
static int Terraria.ModLoader.ModContent.WallType< T > ( )
static

Get the id (type) of a ModWall by class. Assumes one instance per class.

Type Constraints
T :ModWall 
T :GetInstance<T>() 
T :Type 

Member Data Documentation

readonly string Terraria.ModLoader.ModContent.ImagePath = "Content" + Path.DirectorySeparatorChar + "Images"
staticprivate

Definition at line 87 of file ModContent.cs.