Terraria ModLoader  0.11.7.8
A mod to make and play Terraria mods
ModContent.cs
Go to the documentation of this file.
1 using Microsoft.Xna.Framework.Audio;
2 using Microsoft.Xna.Framework.Graphics;
3 using System;
4 using System.Collections.Generic;
5 using System.IO;
6 using System.Linq;
7 using System.Threading;
8 using Terraria.DataStructures;
9 using Terraria.GameContent.UI;
10 using Terraria.GameInput;
11 using Terraria.Localization;
13 using Terraria.ModLoader.Core;
14 using Terraria.ModLoader.Engine;
16 using Terraria.ModLoader.IO;
17 using Terraria.ModLoader.UI;
18 using Terraria.UI;
19 
20 namespace Terraria.ModLoader
21 {
26  public static class ModContent
27  {
28  public static T GetInstance<T>() where T : class => ContentInstance<T>.Instance;
29 
30  public static void SplitName(string name, out string domain, out string subName) {
31  int slash = name.IndexOf('/');
32  if (slash < 0)
33  throw new MissingResourceException("Missing mod qualifier: " + name);
34 
35  domain = name.Substring(0, slash);
36  subName = name.Substring(slash + 1);
37  }
38 
43  public static byte[] GetFileBytes(string name) {
44  string modName, subName;
45  SplitName(name, out modName, out subName);
46 
47  Mod mod = ModLoader.GetMod(modName);
48  if (mod == null)
49  throw new MissingResourceException("Missing mod: " + name);
50 
51  return mod.GetFileBytes(subName);
52  }
53 
57  public static bool FileExists(string name) {
58  if (!name.Contains('/'))
59  return false;
60 
61  string modName, subName;
62  SplitName(name, out modName, out subName);
63 
64  Mod mod = ModLoader.GetMod(modName);
65  return mod != null && mod.FileExists(subName);
66  }
67 
72  public static Texture2D GetTexture(string name) {
73  if (Main.dedServ)
74  return null;
75 
76  string modName, subName;
77  SplitName(name, out modName, out subName);
78  if (modName == "Terraria")
79  return Main.instance.Content.Load<Texture2D>("Images" + Path.DirectorySeparatorChar + subName);
80 
81  Mod mod = ModLoader.GetMod(modName);
82  if (mod == null)
83  throw new MissingResourceException("Missing mod: " + name);
84 
85  return mod.GetTexture(subName);
86  }
87 
91  public static bool TextureExists(string name) {
92  if (Main.dedServ || string.IsNullOrWhiteSpace(name) || !name.Contains('/'))
93  return false;
94 
95  SplitName(name, out string modName, out string subName);
96 
97  if (modName == "Terraria")
98  return (Main.instance.Content as TMLContentManager).ImageExists(subName);
99 
100  Mod mod = ModLoader.GetMod(modName);
101 
102  return mod != null && mod.TextureExists(subName);
103  }
104 
111  internal static bool TryGetTexture(string name, out Texture2D texture) {
112  if (Main.dedServ || string.IsNullOrWhiteSpace(name) || !name.Contains('/')) {
113  texture = null;
114 
115  return false;
116  }
117 
118  SplitName(name, out string modName, out string subName);
119 
120  if (modName == "Terraria") {
121  if ((Main.instance.Content as TMLContentManager).ImageExists(subName)) {
122  texture = Main.instance.Content.Load<Texture2D>("Images" + Path.DirectorySeparatorChar + subName);
123 
124  return true;
125  }
126 
127  texture = null;
128 
129  return false;
130  }
131 
132  Mod mod = ModLoader.GetMod(modName);
133 
134  if (mod == null) {
135  texture = null;
136 
137  return false;
138  }
139 
140  return mod.textures.TryGetValue(subName, out texture);
141  }
142 
147  public static SoundEffect GetSound(string name) {
148  if (Main.dedServ)
149  return null;
150 
151  string modName, subName;
152  SplitName(name, out modName, out subName);
153 
154  Mod mod = ModLoader.GetMod(modName);
155  if (mod == null)
156  throw new MissingResourceException("Missing mod: " + name);
157 
158  return mod.GetSound(subName);
159  }
160 
164  public static bool SoundExists(string name) {
165  if (!name.Contains('/'))
166  return false;
167 
168  string modName, subName;
169  SplitName(name, out modName, out subName);
170 
171  Mod mod = ModLoader.GetMod(modName);
172  return mod != null && mod.SoundExists(subName);
173  }
174 
179  public static Music GetMusic(string name) {
180  if (Main.dedServ) { return null; }
181  string modName, subName;
182  SplitName(name, out modName, out subName);
183  Mod mod = ModLoader.GetMod(modName);
184  if (mod == null) { throw new MissingResourceException("Missing mod: " + name); }
185  return mod.GetMusic(subName);
186  }
187 
191  public static bool MusicExists(string name) {
192  if (!name.Contains('/')) { return false; }
193  string modName, subName;
194  SplitName(name, out modName, out subName);
195  Mod mod = ModLoader.GetMod(modName);
196  return mod != null && mod.MusicExists(subName);
197  }
198 
204  public static ModNPC GetModNPC(int type) => NPCLoader.GetNPC(type);
205 
211  public static int GetModBossHeadSlot(string texture) => NPCHeadLoader.GetBossHeadSlot(texture);
212 
218  public static int GetModHeadSlot(string texture) => NPCHeadLoader.GetHeadSlot(texture);
219 
223  public static ModItem GetModItem(int type) => ItemLoader.GetItem(type);
224 
228  public static ModDust GetModDust(int type) => ModDust.GetDust(type);
229 
235  public static ModProjectile GetModProjectile(int type) => ProjectileLoader.GetProjectile(type);
236 
240  public static ModBuff GetModBuff(int type) => BuffLoader.GetBuff(type);
241 
248  public static EquipTexture GetEquipTexture(EquipType type, int slot) => EquipLoader.GetEquipTexture(type, slot);
249 
255  public static ModMountData GetModMountData(int type) => MountLoader.GetMount(type);
256 
262  public static ModTile GetModTile(int type) => TileLoader.GetTile(type);
263 
267  public static ModWall GetModWall(int type) => WallLoader.GetWall(type);
268 
272  public static ModWaterStyle GetModWaterStyle(int style) => WaterStyleLoader.GetWaterStyle(style);
273 
277  public static ModWaterfallStyle GetModWaterfallStyle(int style) => WaterfallStyleLoader.GetWaterfallStyle(style);
278 
282  public static int GetModBackgroundSlot(string texture) => BackgroundTextureLoader.GetBackgroundSlot(texture);
283 
287  public static ModSurfaceBgStyle GetModSurfaceBgStyle(int style) => SurfaceBgStyleLoader.GetSurfaceBgStyle(style);
288 
292  public static ModUgBgStyle GetModUgBgStyle(int style) => UgBgStyleLoader.GetUgBgStyle(style);
293 
297  public static int ItemType<T>() where T : ModItem => GetInstance<T>()?.item.type ?? 0;
298 
302  public static byte PrefixType<T>() where T : ModPrefix => GetInstance<T>()?.Type ?? 0;
303 
307  public static int DustType<T>() where T : ModDust => GetInstance<T>()?.Type ?? 0;
308 
312  public static int TileType<T>() where T : ModTile => GetInstance<T>()?.Type ?? 0;
313 
317  public static int TileEntityType<T>() where T : ModTileEntity => GetInstance<T>()?.Type ?? 0;
318 
322  public static int WallType<T>() where T : ModWall => GetInstance<T>()?.Type ?? 0;
323 
327  public static int ProjectileType<T>() where T : ModProjectile => GetInstance<T>()?.projectile.type ?? 0;
328 
332  public static int NPCType<T>() where T : ModNPC => GetInstance<T>()?.npc.type ?? 0;
333 
337  public static int BuffType<T>() where T : ModBuff => GetInstance<T>()?.Type ?? 0;
338 
342  public static int MountType<T>() where T : ModMountData => GetInstance<T>()?.Type ?? 0;
343 
344  private static LocalizedText SetLocalizedText(Dictionary<string, LocalizedText> dict, LocalizedText value) {
345  if (dict.ContainsKey(value.Key)) {
346  dict[value.Key].SetValue(value.Value);
347  }
348  else {
349  dict[value.Key] = value;
350  }
351  return dict[value.Key];
352  }
353 
354  internal static void Load(CancellationToken token) {
355  CacheVanillaState();
356 
357  Interface.loadMods.SetLoadStage("tModLoader.MSIntializing", ModLoader.Mods.Length);
358  LoadModContent(token, mod => {
359  ContentInstance.Register(mod);
360  mod.loading = true;
361  mod.AutoloadConfig();
362  mod.LoadResources();
363  mod.Autoload();
364  mod.Load();
365  mod.loading = false;
366  });
367 
368  Interface.loadMods.SetLoadStage("tModLoader.MSSettingUp");
369  ResizeArrays();
370  RecipeGroupHelper.FixRecipeGroupLookups();
371 
372  Interface.loadMods.SetLoadStage("tModLoader.MSLoading", ModLoader.Mods.Length);
373  LoadModContent(token, mod => {
374  mod.SetupContent();
375  mod.PostSetupContent();
376  });
377 
378  MemoryTracking.Finish();
379 
380  if (Main.dedServ)
381  ModNet.AssignNetIDs();
382 
383  Main.player[255] = new Player(false); // setup inventory is unnecessary
384 
385  RefreshModLanguage(Language.ActiveCulture);
386  MapLoader.SetupModMap();
387  ItemSorting.SetupWhiteLists();
388  PlayerInput.reinitialize = true;
389  SetupRecipes(token);
390  }
391 
392  private static void CacheVanillaState() {
393  EffectsTracker.CacheVanillaState();
394  }
395 
396  internal static Mod LoadingMod { get; private set; }
397  private static void LoadModContent(CancellationToken token, Action<Mod> loadAction) {
398  MemoryTracking.Checkpoint();
399  int num = 0;
400  foreach (var mod in ModLoader.Mods) {
401  token.ThrowIfCancellationRequested();
402  Interface.loadMods.SetCurrentMod(num++, $"{mod.Name} v{mod.Version}");
403  try {
404  LoadingMod = mod;
405  loadAction(mod);
406  }
407  catch (Exception e) {
408  e.Data["mod"] = mod.Name;
409  throw;
410  }
411  finally {
412  LoadingMod = null;
413  MemoryTracking.Update(mod.Name);
414  }
415  }
416  }
417 
418  private static void SetupRecipes(CancellationToken token) {
419  Interface.loadMods.SetLoadStage("tModLoader.MSAddingRecipes");
420  for (int k = 0; k < Recipe.maxRecipes; k++) {
421  token.ThrowIfCancellationRequested();
422  Main.recipe[k] = new Recipe();
423  }
424 
425  Recipe.numRecipes = 0;
426  RecipeGroupHelper.ResetRecipeGroups();
427  RecipeHooks.setupRecipes = true;
428  Recipe.SetupRecipes();
429  RecipeHooks.setupRecipes = false;
430  }
431 
432  internal static void UnloadModContent() {
433  int i = 0;
434  foreach (var mod in ModLoader.Mods.Reverse()) {
435  try {
436  if (Main.dedServ)
437  Console.WriteLine($"Unloading {mod.DisplayName}...");
438  else
439  Interface.loadMods.SetCurrentMod(i++, mod.DisplayName);
440  mod.Close();
441  mod.UnloadContent();
442  }
443  catch (Exception e) {
444  e.Data["mod"] = mod.Name;
445  throw;
446  }
447  finally {
448  MonoModHooks.RemoveAll(mod);
449  }
450  }
451  }
452 
453  internal static void Unload() {
454  ContentInstance.Clear();
455  ItemLoader.Unload();
456  EquipLoader.Unload();
457  ModPrefix.Unload();
458  ModDust.Unload();
459  TileLoader.Unload();
460  ModTileEntity.Unload();
461  WallLoader.Unload();
462  ProjectileLoader.Unload();
463  NPCLoader.Unload();
464  NPCHeadLoader.Unload();
465  PlayerHooks.Unload();
466  BuffLoader.Unload();
467  MountLoader.Unload();
468  ModGore.Unload();
469  SoundLoader.Unload();
470  DisposeMusic();
471  BackgroundTextureLoader.Unload();
472  UgBgStyleLoader.Unload();
473  SurfaceBgStyleLoader.Unload();
474  GlobalBgStyleLoader.Unload();
475  WaterStyleLoader.Unload();
476  WaterfallStyleLoader.Unload();
477  WorldHooks.Unload();
478  ResizeArrays(true);
479  for (int k = 0; k < Recipe.maxRecipes; k++) {
480  Main.recipe[k] = new Recipe();
481  }
482  Recipe.numRecipes = 0;
483  RecipeGroupHelper.ResetRecipeGroups();
484  Recipe.SetupRecipes();
485  MapLoader.UnloadModMap();
486  ItemSorting.SetupWhiteLists();
487  HotKeyLoader.Unload();
488  RecipeHooks.Unload();
489  CommandManager.Unload();
490  TagSerializer.Reload();
491  ModNet.Unload();
492  Config.ConfigManager.Unload();
493  CustomCurrencyManager.Initialize();
494  EffectsTracker.RemoveModEffects();
495 
496  CleanupModReferences();
497  }
498 
499  private static void ResizeArrays(bool unloading = false) {
500  ItemLoader.ResizeArrays(unloading);
501  EquipLoader.ResizeAndFillArrays();
502  ModPrefix.ResizeArrays();
503  Main.InitializeItemAnimations();
504  ModDust.ResizeArrays();
505  TileLoader.ResizeArrays(unloading);
506  WallLoader.ResizeArrays(unloading);
507  ProjectileLoader.ResizeArrays();
508  NPCLoader.ResizeArrays(unloading);
509  NPCHeadLoader.ResizeAndFillArrays();
510  ModGore.ResizeAndFillArrays();
511  SoundLoader.ResizeAndFillArrays();
512  MountLoader.ResizeArrays();
513  BuffLoader.ResizeArrays();
514  PlayerHooks.RebuildHooks();
515  BackgroundTextureLoader.ResizeAndFillArrays();
516  UgBgStyleLoader.ResizeAndFillArrays();
517  SurfaceBgStyleLoader.ResizeAndFillArrays();
518  GlobalBgStyleLoader.ResizeAndFillArrays(unloading);
519  WaterStyleLoader.ResizeArrays();
520  WaterfallStyleLoader.ResizeArrays();
521  WorldHooks.ResizeArrays();
522  foreach (LocalizedText text in LanguageManager.Instance._localizedTexts.Values) {
523  text.Override = null;
524  }
525  }
526 
527  public static void RefreshModLanguage(GameCulture culture) {
528  Dictionary<string, LocalizedText> dict = LanguageManager.Instance._localizedTexts;
529  foreach (ModItem item in ItemLoader.items) {
530  LocalizedText text = new LocalizedText(item.DisplayName.Key, item.DisplayName.GetTranslation(culture));
531  Lang._itemNameCache[item.item.type] = SetLocalizedText(dict, text);
532  text = new LocalizedText(item.Tooltip.Key, item.Tooltip.GetTranslation(culture));
533  if (text.Value != null) {
534  text = SetLocalizedText(dict, text);
535  Lang._itemTooltipCache[item.item.type] = ItemTooltip.FromLanguageKey(text.Key);
536  }
537  }
538  foreach (ModPrefix prefix in ModPrefix.prefixes) {
539  LocalizedText text = new LocalizedText(prefix.DisplayName.Key, prefix.DisplayName.GetTranslation(culture));
540  Lang.prefix[prefix.Type] = SetLocalizedText(dict, text);
541  }
542  foreach (var keyValuePair in MapLoader.tileEntries) {
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 (var keyValuePair in MapLoader.wallEntries) {
551  foreach (MapEntry entry in keyValuePair.Value) {
552  if (entry.translation != null) {
553  LocalizedText text = new LocalizedText(entry.translation.Key, entry.translation.GetTranslation(culture));
554  SetLocalizedText(dict, text);
555  }
556  }
557  }
558  foreach (ModProjectile proj in ProjectileLoader.projectiles) {
559  LocalizedText text = new LocalizedText(proj.DisplayName.Key, proj.DisplayName.GetTranslation(culture));
560  Lang._projectileNameCache[proj.projectile.type] = SetLocalizedText(dict, text);
561  }
562  foreach (ModNPC npc in NPCLoader.npcs) {
563  LocalizedText text = new LocalizedText(npc.DisplayName.Key, npc.DisplayName.GetTranslation(culture));
564  Lang._npcNameCache[npc.npc.type] = SetLocalizedText(dict, text);
565  }
566  foreach (ModBuff buff in BuffLoader.buffs) {
567  LocalizedText text = new LocalizedText(buff.DisplayName.Key, buff.DisplayName.GetTranslation(culture));
568  Lang._buffNameCache[buff.Type] = SetLocalizedText(dict, text);
569  text = new LocalizedText(buff.Description.Key, buff.Description.GetTranslation(culture));
570  Lang._buffDescriptionCache[buff.Type] = SetLocalizedText(dict, text);
571  }
572  foreach (Mod mod in ModLoader.Mods) {
573  foreach (ModTranslation translation in mod.translations.Values) {
574  LocalizedText text = new LocalizedText(translation.Key, translation.GetTranslation(culture));
575  SetLocalizedText(dict, text);
576  }
577  }
578  LanguageManager.Instance.ProcessCopyCommandsInTexts();
579  }
580 
581  private static void DisposeMusic() {
582  foreach (var music in Main.music.OfType<MusicStreaming>())
583  music.Dispose();
584  }
585 
590  internal static void CleanupModReferences()
591  {
592  // Clear references to ModPlayer instances
593  for (int i = 0; i < Main.player.Length; i++) {
594  Main.player[i] = new Player();
595  // player.whoAmI is only set for active players
596  }
597 
598  Main.clientPlayer = new Player(false);
599  Main.ActivePlayerFileData = new Terraria.IO.PlayerFileData();
600  Main._characterSelectMenu._playerList?.Clear();
601  Main.PlayerList.Clear();
602 
603  for (int i = 0; i < Main.npc.Length; i++) {
604  Main.npc[i] = new NPC();
605  Main.npc[i].whoAmI = i;
606  }
607 
608  for (int i = 0; i < Main.item.Length; i++) {
609  Main.item[i] = new Item();
610  // item.whoAmI is never used
611  }
612 
613  if (ItemSlot.singleSlotArray[0] != null) {
614  ItemSlot.singleSlotArray[0] = new Item();
615  }
616 
617  for (int i = 0; i < Main.chest.Length; i++) {
618  Main.chest[i] = new Chest();
619  }
620 
621  for (int i = 0; i < Main.projectile.Length; i++) {
622  Main.projectile[i] = new Projectile();
623  // projectile.whoAmI is only set for active projectiles
624  }
625 
626  TileEntity.Clear(); // drop all possible references to mod TEs
627  }
628 
629  public static Stream OpenRead(string assetName, bool newFileStream = false) {
630  if (!assetName.StartsWith("tmod:"))
631  return File.OpenRead(assetName);
632 
633  SplitName(assetName.Substring(5).Replace('\\', '/'), out var modName, out var entryPath);
634  return ModLoader.GetMod(modName).GetFileStream(entryPath, newFileStream);
635  }
636  }
637 }
static void LoadModContent(CancellationToken token, Action< Mod > loadAction)
Definition: ModContent.cs:397
static byte[] GetFileBytes(string name)
Gets the byte representation of the file with the specified name. The name is in the format of "ModFo...
Definition: ModContent.cs:43
int Type
The ID of this type of dust.
Definition: ModDust.cs:47
static ModWaterfallStyle GetWaterfallStyle(int style)
Returns the ModWaterfallStyle with the given ID.
int Type
The index of this ModMountData in the Mount.mounts array.
Definition: ModMountData.cs:37
static ModMountData GetMount(int type)
Gets the ModMountData instance corresponding to the given type. Returns null if no ModMountData has t...
Definition: MountLoader.cs:23
ModTranslation DisplayName
The translations for the display name of this NPC.
Definition: ModNPC.cs:45
This class represents a type of tile that can be added by a mod. Only one instance of this class will...
Definition: ModTile.cs:12
int Type
The numeric type used to identify this kind of tile entity.
This class serves as a place for you to place all your properties and hooks for each NPC...
Definition: ModNPC.cs:14
ModTranslation Description
The translations of this buff&#39;s description.
Definition: ModBuff.cs:43
Each background style determines in its own way how exactly the background is drawn. This class serves as a collection of functions for above-ground backgrounds.
This is the class that keeps track of all modded background textures and their slots/IDs.
static void CacheVanillaState()
Definition: ModContent.cs:392
This serves as the central class from which projectile-related functions are carried out...
static EquipTexture GetEquipTexture(EquipType type, int slot)
Gets the equipment texture for the specified equipment type and ID.
Definition: EquipLoader.cs:56
This is where all ModPlayer hooks are gathered and called.
Definition: PlayerHooks.cs:20
static Music GetMusic(string name)
Gets the music with the specified name. The name is in the same format as for texture names...
Definition: ModContent.cs:179
This is where all ModRecipe and GlobalRecipe hooks are gathered and called.
Definition: RecipeHooks.cs:9
Tile Entities are Entities tightly coupled with tiles, allowing the possibility of tiles to exhibit c...
static Texture2D GetTexture(string name)
Gets the texture with the specified name. The name is in the format of "ModFolder/OtherFolders/FileNa...
Definition: ModContent.cs:72
This serves as the central class from which ModUgBgStyle functions are supported and carried out...
static void SetupRecipes(CancellationToken token)
Definition: ModContent.cs:418
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static LocalizedText SetLocalizedText(Dictionary< string, LocalizedText > dict, LocalizedText value)
Definition: ModContent.cs:344
ModTranslation DisplayName
Definition: ModPrefix.cs:97
This serves as a place for you to program behaviors of equipment textures. This is useful for equipme...
Definition: EquipTexture.cs:8
static ModTile GetTile(int type)
Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null.
Definition: TileLoader.cs:102
Item item
The item object that this ModItem controls.
Definition: ModItem.cs:26
This serves as the central class which loads mods. It contains many static fields and methods related...
Definition: ModLoader.cs:28
Music GetMusic(string name)
Shorthand for calling ModContent.GetMusic(this.FileName(name)).
Definition: Mod.cs:1634
This serves as the central class from which tile-related functions are supported and carried out...
Definition: TileLoader.cs:14
static ModProjectile GetProjectile(int type)
Gets the ModProjectile instance corresponding to the specified type.
This is where all ModWorld hooks are gathered and called.
Definition: WorldHooks.cs:12
ushort Type
The internal ID of this type of wall.
Definition: ModWall.cs:33
Command can be used in server console during MP.
This class allows you to customize the behavior of a custom gore. Create a new instance of this and p...
Definition: ModGore.cs:12
NPC npc
The NPC object that this ModNPC controls.
Definition: ModNPC.cs:21
static int GetBackgroundSlot(string texture)
Returns the slot/ID of the background texture with the given name.
Represents a style of water that gets drawn, based on factors such as the background. This is used to determine the color of the water, as well as other things as determined by the hooks below.
Definition: ModWaterStyle.cs:8
This class serves as a central place from which NPC head slots are stored and NPC head textures are a...
static ModItem GetItem(int type)
Gets the ModItem instance corresponding to the specified type. Returns null if no modded item has the...
Definition: ItemLoader.cs:76
static ModUgBgStyle GetUgBgStyle(int style)
Returns the ModUgBgStyle object with the given ID.
This serves as a central place to store equipment slots and their corresponding textures. You will use this to obtain the IDs for your equipment textures.
Definition: EquipLoader.cs:11
Manages content added by mods. Liasons between mod content and Terraria&#39;s arrays and oversees the Loa...
Definition: ModContent.cs:26
static bool TextureExists(string name)
Returns whether or not a texture with the specified name exists.
Definition: ModContent.cs:91
static int GetHeadSlot(string texture)
Gets the index of the head texture corresponding to the given texture path.
EquipType
This is an enum of all the types of equipment that exist. An equipment type is defined as a type or l...
Definition: EquipType.cs:6
Projectile projectile
The projectile object that this ModProjectile controls.
This class is used to keep track of and support the existence of custom sounds that have been added t...
Definition: SoundLoader.cs:11
bool FileExists(string name)
Shorthand for calling ModLoader.FileExists(this.FileName(name)). Note that file extensions are used h...
ModTranslation DisplayName
The translations for the display name of this item.
Definition: ModItem.cs:53
static Stream OpenRead(string assetName, bool newFileStream=false)
Definition: ModContent.cs:629
static ModSurfaceBgStyle GetSurfaceBgStyle(int style)
Returns the ModSurfaceBgStyle object with the given ID.
This class represents a type of wall that can be added by a mod. Only one instance of this class will...
Definition: ModWall.cs:12
This serves as the central class from which item-related functions are carried out. It also stores a list of mod items by ID.
Definition: ItemLoader.cs:21
This class serves as a place for you to place all your properties and hooks for each mount...
Definition: ModMountData.cs:14
bool SoundExists(string name)
Shorthand for calling ModLoader.SoundExists(this.FileName(name)).
ushort Type
The internal ID of this type of tile.
Definition: ModTile.cs:33
static bool MusicExists(string name)
Returns whether or not a sound with the specified name exists.
Definition: ModContent.cs:191
bool TextureExists(string name)
Shorthand for calling ModLoader.TextureExists(this.FileName(name)).
Represents a style of waterfalls that gets drawn. This is mostly used to determine the color of the w...
SoundEffect GetSound(string name)
Shorthand for calling ModContent.GetSound(this.FileName(name)).
Definition: Mod.cs:1614
This serves as the central class from which WaterStyle functions are supported and carried out...
This serves as the central class from which ModCommand functions are supported and carried out...
This class serves as a place for you to define a new buff and how that buff behaves.
Definition: ModBuff.cs:6
Stream GetFileStream(string name, bool newFileStream=false)
Retrieve contents of files within the tmod file
static ModNPC GetNPC(int type)
Gets the ModNPC instance corresponding to the specified type.
Definition: NPCLoader.cs:93
bool MusicExists(string name)
Shorthand for calling ModLoader.MusicExists(this.FileName(name)).
static SoundEffect GetSound(string name)
Gets the sound with the specified name. The name is in the same format as for texture names...
Definition: ModContent.cs:147
static ModDust GetDust(int type)
Gets the ModDust instance with the given type. Returns null if no ModDust with the given type exists...
Definition: ModDust.cs:57
static ModBuff GetBuff(int type)
Gets the ModBuff instance with the given type. If no ModBuff with the given type exists, returns null.
Definition: BuffLoader.cs:77
ModTranslation DisplayName
The translations of this buff&#39;s display name.
Definition: ModBuff.cs:35
This serves as the central class from which NPC-related functions are carried out. It also stores a list of mod NPCs by ID.
Definition: NPCLoader.cs:19
static void SplitName(string name, out string domain, out string subName)
Definition: ModContent.cs:30
This serves as the central class from which buff-related functions are supported and carried out...
Definition: BuffLoader.cs:14
This class serves as a place for you to place all your properties and hooks for each projectile...
byte[] GetFileBytes(string name)
Retrieve contents of files within the tmod file
static void RefreshModLanguage(GameCulture culture)
Definition: ModContent.cs:527
This serves as the central class from which wall-related functions are supported and carried out...
Definition: WallLoader.cs:13
Mod is an abstract class that you will override. It serves as a central place from which the mod&#39;s co...
Definition: Mod.cs:24
static void ResizeArrays(bool unloading=false)
Definition: ModContent.cs:499
static int GetBossHeadSlot(string texture)
Gets the index of the boss head texture corresponding to the given texture path.
ModTranslation DisplayName
The translations for the display name of this projectile.
static Mod GetMod(string name)
Gets the instance of the Mod with the specified name.
Definition: ModLoader.cs:90
This class serves as a place for you to place all your properties and hooks for each item...
Definition: ModItem.cs:16
ModTranslation Tooltip
The translations for the display name of this tooltip.
Definition: ModItem.cs:61
This class represents a type of dust that is added by a mod. Only one instance of this class will eve...
Definition: ModDust.cs:13
int Type
The buff id of this buff.
Definition: ModBuff.cs:27
static bool SoundExists(string name)
Returns whether or not a sound with the specified name exists.
Definition: ModContent.cs:164
string GetTranslation(int culture)
This serves as the central place from which mounts are stored and mount-related functions are carried...
Definition: MountLoader.cs:13
static ModWaterStyle GetWaterStyle(int style)
Returns the ModWaterStyle with the given ID.
Each background style determines in its own way how exactly the background is drawn. This class serves as a collection of functions for underground backgrounds.
static bool FileExists(string name)
Returns whether or not a file with the specified name exists.
Definition: ModContent.cs:57