Terraria ModLoader  0.10.1.5
A framework for Terraria mods
Terraria.ModLoader.TileLoader Class Reference

This serves as the central class from which tile-related functions are supported and carried out. More...

+ Collaboration diagram for Terraria.ModLoader.TileLoader:

Static Public Member Functions

static void AdjTiles (Player player, int type)
 
static void AnimateTiles ()
 
static int AutoSelect (int i, int j, Player player)
 
static bool CanDropAcorn (int type)
 
static bool CanExplode (int i, int j)
 
static bool CanGrowModCactus (int type)
 
static bool CanGrowModPalmTree (int type)
 
static bool CanGrowModTree (int type)
 
static bool CanKillTile (int i, int j, int type, ref bool blockDamaged)
 
static bool CanPlace (int i, int j, int type)
 
static void ChangeWaterfallStyle (int type, ref int style)
 
static void CheckModTile (int i, int j, int type)
 
static int CloseDoorID (Tile tile)
 
static bool CreateDust (int i, int j, int type, ref int dustType)
 
static bool Dangersense (int i, int j, int type, Player player)
 
static void DisableSmartCursor (Tile tile, ref bool disable)
 
static void DisableSmartInteract (Tile tile, ref bool disable)
 
static void DrawEffects (int i, int j, int type, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
 
static bool Drop (int i, int j, int type)
 
static void DropCritterChance (int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance)
 
static void DropPalmTreeWood (int type, ref int wood)
 
static void DropTreeWood (int type, ref int wood)
 
static void FixSmartInteractCoords (int type, ref int width, ref int height, ref int frameWidth, ref int frameHeight, ref int extraX, ref int extraY)
 
static void FloorVisuals (int type, Player player)
 
static Texture2D GetCactusTexture (int type)
 
static Texture2D GetPalmTreeTexture (Tile tile)
 
static Texture2D GetPalmTreeTopTextures (int type)
 
static ModTile GetTile (int type)
 Gets the ModTile instance with the given type. If no ModTile with the given type exists, returns null. More...
 
static Texture2D GetTreeBranchTextures (int type, int i, int j, int trunkOffset, ref int frame)
 
static Texture2D GetTreeTexture (Tile tile)
 
static Texture2D GetTreeTopTextures (int type, int i, int j, ref int frame, ref int frameWidth, ref int frameHeight, ref int xOffsetLeft, ref int yOffset)
 
static bool HasSmartInteract (int type)
 
static bool HasWalkDust (int type)
 
static void HitWire (int i, int j, int type)
 
static bool IsClosedDoor (Tile tile)
 
static bool IsDresser (int type)
 
static bool IsModBed (int type)
 
static bool IsModMusicBox (Tile tile)
 
static bool IsSapling (int type)
 
static bool IsTorch (int type)
 
static void KillMultiTile (int i, int j, int frameX, int frameY, int type)
 
static bool KillSound (int i, int j, int type)
 
static void KillTile (int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem)
 
static void MineDamage (int minePower, ref int damage)
 
static string ModChestName (int type)
 
static string ModDresserName (int type)
 
static void ModifyLight (int i, int j, int type, ref float r, ref float g, ref float b)
 
static void MouseOver (int i, int j)
 
static void MouseOverFar (int i, int j)
 
static void NearbyEffects (int i, int j, int type, bool closer)
 
static void NumDust (int i, int j, int type, bool fail, ref int numDust)
 
static int OpenDoorID (Tile tile)
 
static void PalmTreeDust (Tile tile, ref int dust)
 
static void PalmTreeGrowthFXGore (int type, ref int gore)
 
static void PickPowerCheck (Tile target, int pickPower, ref int damage)
 
static void PlaceInWorld (int i, int j, Item item)
 
static void PostDraw (int i, int j, int type, SpriteBatch spriteBatch)
 
static bool PreDraw (int i, int j, int type, SpriteBatch spriteBatch)
 
static bool PreHitWire (int i, int j, int type)
 
static void RandomUpdate (int i, int j, int type)
 
static void RightClick (int i, int j)
 
static bool SaplingGrowthType (int type, ref int saplingType, ref int style)
 
static void SetAnimationFrame (int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
 Sets the animation frame. Sets frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type]; and then calls ModTile.AnimateIndividualTile More...
 
static void SetDrawPositions (int i, int j, ref int width, ref int offsetY, ref int height)
 
static void SetSpriteEffects (int i, int j, int type, ref SpriteEffects spriteEffects)
 
static bool Slope (int i, int j, int type)
 
static void SpecialDraw (int type, int specX, int specY, SpriteBatch spriteBatch)
 Special Draw calls ModTile and GlobalTile SpecialDraw methods. Special Draw is called from DrawTiles after the draw loop, allowing for basically another layer above tiles. Main.specX and Main.specY are used to specify tiles to call SpecialDraw on. Use DrawEffects hook to queue for SpecialDraw. More...
 
static bool TileFrame (int i, int j, int type, ref bool resetFrame, ref bool noBreak)
 
static void TreeDust (Tile tile, ref int dust)
 
static void TreeGrowthFXGore (int type, ref int gore)
 
static void WalkDust (int type, ref int dustType, ref bool makeDust, ref Color color)
 

Static Public Attributes

static int TileCount => nextTile
 

Private Member Functions

delegate bool DelegateCanKillTile (int i, int j, int type, ref bool blockDamaged)
 
delegate void DelegateChangeWaterfallStyle (int type, ref int style)
 
delegate bool DelegateCreateDust (int i, int j, int type, ref int dustType)
 
delegate void DelegateDrawEffects (int i, int j, int type, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
 
delegate void DelegateDropCritterChance (int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance)
 
delegate void DelegateKillTile (int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem)
 
delegate void DelegateModifyLight (int i, int j, int type, ref float r, ref float g, ref float b)
 
delegate void DelegateNumDust (int i, int j, int type, bool fail, ref int num)
 
delegate int DelegateSaplingGrowthType (int type, ref int style)
 
delegate void DelegateSetSpriteEffects (int i, int j, int type, ref SpriteEffects spriteEffects)
 
delegate bool DelegateTileFrame (int i, int j, int type, ref bool resetFrame, ref bool noBreak)
 

Static Private Member Functions

static void Resize2DArray< T > (ref T[,] array, int newSize)
 

Static Private Attributes

static Func< int, int[]>[] HookAdjTiles
 
static Action[] HookAnimateTile
 
static Func< int, int, int, Item, bool >[] HookAutoSelect
 
static Func< int, int, int, bool >[] HookCanExplode
 
static DelegateCanKillTile[] HookCanKillTile
 
static Func< int, int, int, bool >[] HookCanPlace
 
static DelegateChangeWaterfallStyle[] HookChangeWaterfallStyle
 
static DelegateCreateDust[] HookCreateDust
 
static Func< int, int, int, Player, bool >[] HookDangersense
 
static DelegateDrawEffects[] HookDrawEffects
 
static Func< int, int, int, bool >[] HookDrop
 
static DelegateDropCritterChance[] HookDropCritterChance
 
static Action< int, Player >[] HookFloorVisuals
 
static Action< int, int, int >[] HookHitWire
 
static Func< int, int, int, bool >[] HookKillSound
 
static DelegateKillTile[] HookKillTile
 
static DelegateModifyLight[] HookModifyLight
 
static Action< int, int, int >[] HookMouseOver
 
static Action< int, int, int >[] HookMouseOverFar
 
static Action< int, int, int, bool >[] HookNearbyEffects
 
static DelegateNumDust[] HookNumDust
 
static Action< int, int, Item >[] HookPlaceInWorld
 
static Action< int, int, int, SpriteBatch >[] HookPostDraw
 
static Func< int, int, int, SpriteBatch, bool >[] HookPreDraw
 
static Func< int, int, int, bool >[] HookPreHitWire
 
static Action< int, int, int >[] HookRandomUpdate
 
static Action< int, int, int >[] HookRightClick
 
static DelegateSaplingGrowthType[] HookSaplingGrowthType
 
static DelegateSetSpriteEffects[] HookSetSpriteEffects
 
static Func< int, int, int, bool >[] HookSlope
 
static Action< int, int, int, SpriteBatch >[] HookSpecialDraw
 
static DelegateTileFrame[] HookTileFrame
 
static bool loaded = false
 
static int nextTile = TileID.Count
 
static readonly int vanillaChairCount = TileID.Sets.RoomNeeds.CountsAsChair.Length
 
static readonly int vanillaDoorCount = TileID.Sets.RoomNeeds.CountsAsDoor.Length
 
static readonly int vanillaTableCount = TileID.Sets.RoomNeeds.CountsAsTable.Length
 
static readonly int vanillaTorchCount = TileID.Sets.RoomNeeds.CountsAsTorch.Length
 

Detailed Description

This serves as the central class from which tile-related functions are supported and carried out.

Definition at line 14 of file TileLoader.cs.

Member Function Documentation

static void Terraria.ModLoader.TileLoader.AdjTiles ( Player  player,
int  type 
)
static

Definition at line 796 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.adjTiles.

796  {
797  ModTile modTile = GetTile(type);
798  if (modTile != null) {
799  foreach (int k in modTile.adjTiles) {
800  player.adjTile[k] = true;
801  }
802  }
803  foreach (var hook in HookAdjTiles) {
804  int[] adjTiles = hook(type);
805  foreach (int k in adjTiles) {
806  player.adjTile[k] = true;
807  }
808  }
809  }
static Func< int, int[]>[] HookAdjTiles
Definition: TileLoader.cs:72
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
static void Terraria.ModLoader.TileLoader.AnimateTiles ( )
static

Definition at line 672 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.AnimateTile(), and Terraria.ModLoader.ModTile.Type.

672  {
673  if (loaded) {
674  for (int i = 0; i < tiles.Count; i++) {
675  ModTile modTile = tiles[i];
676  modTile.AnimateTile(ref Main.tileFrame[modTile.Type], ref Main.tileFrameCounter[modTile.Type]);
677  }
678  foreach (var hook in HookAnimateTile) {
679  hook();
680  }
681  }
682  }
static Action[] HookAnimateTile
Definition: TileLoader.cs:62

+ Here is the call graph for this function:

static int Terraria.ModLoader.TileLoader.AutoSelect ( int  i,
int  j,
Player  player 
)
static

Definition at line 840 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.AutoSelect(), and Terraria.ModLoader.Item.

840  {
841  if (!Main.tile[i, j].active()) {
842  return -1;
843  }
844  int type = Main.tile[i, j].type;
845  ModTile modTile = GetTile(type);
846  for (int k = 0; k < 50; k++) {
847  Item item = player.inventory[k];
848  if (item.type == 0 || item.stack == 0) {
849  continue;
850  }
851  if (modTile != null && modTile.AutoSelect(i, j, item)) {
852  return k;
853  }
854  foreach (var hook in HookAutoSelect) {
855  if (hook(i, j, type, item)) {
856  return k;
857  }
858  }
859  }
860  return -1;
861  }
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
static Func< int, int, int, Item, bool >[] HookAutoSelect
Definition: TileLoader.cs:76

+ Here is the call graph for this function:

static bool Terraria.ModLoader.TileLoader.CanDropAcorn ( int  type)
static

Definition at line 964 of file TileLoader.cs.

964  {
965  return trees.ContainsKey(type) ? trees[type].CanDropAcorn() : false;
966  }
static bool Terraria.ModLoader.TileLoader.CanExplode ( int  i,
int  j 
)
static

Definition at line 595 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.CanExplode().

595  {
596  int type = Main.tile[i, j].type;
597  ModTile modTile = GetTile(type);
598  if (modTile != null && !modTile.CanExplode(i, j)) {
599  return false;
600  }
601  foreach (var hook in HookCanExplode) {
602  if (!hook(i, j, type)) {
603  return false;
604  }
605  }
606  return true;
607  }
static Func< int, int, int, bool >[] HookCanExplode
Definition: TileLoader.cs:55
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

+ Here is the call graph for this function:

static bool Terraria.ModLoader.TileLoader.CanGrowModCactus ( int  type)
static

Definition at line 1018 of file TileLoader.cs.

1018  {
1019  return cacti.ContainsKey(type);
1020  }
static bool Terraria.ModLoader.TileLoader.CanGrowModPalmTree ( int  type)
static

Definition at line 988 of file TileLoader.cs.

988  {
989  return palmTrees.ContainsKey(type);
990  }
static bool Terraria.ModLoader.TileLoader.CanGrowModTree ( int  type)
static

Definition at line 948 of file TileLoader.cs.

948  {
949  return trees.ContainsKey(type);
950  }
static bool Terraria.ModLoader.TileLoader.CanKillTile ( int  i,
int  j,
int  type,
ref bool  blockDamaged 
)
static

Definition at line 573 of file TileLoader.cs.

573  {
574  foreach (var hook in HookCanKillTile) {
575  if (!hook(i, j, type, ref blockDamaged)) {
576  return false;
577  }
578  }
579  return GetTile(type)?.CanKillTile(i, j, ref blockDamaged) ?? true;
580  }
static DelegateCanKillTile[] HookCanKillTile
Definition: TileLoader.cs:52
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
virtual bool CanKillTile(int i, int j, ref bool blockDamaged)
Allows you to determine whether or not the tile at the given coordinates can be hit by anything...
Definition: ModTile.cs:295
static bool Terraria.ModLoader.TileLoader.CanPlace ( int  i,
int  j,
int  type 
)
static

Definition at line 786 of file TileLoader.cs.

786  {
787  foreach (var hook in HookCanPlace) {
788  if (!hook(i, j, type)) {
789  return false;
790  }
791  }
792  return GetTile(type)?.CanPlace(i, j) ?? true;
793  }
virtual bool CanPlace(int i, int j)
Allows you to stop this tile from being placed at the given coordinates. Return false to block the ti...
Definition: ModTile.cs:458
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
static Func< int, int, int, bool >[] HookCanPlace
Definition: TileLoader.cs:71
static void Terraria.ModLoader.TileLoader.ChangeWaterfallStyle ( int  type,
ref int  style 
)
static

Definition at line 909 of file TileLoader.cs.

909  {
910  GetTile(type)?.ChangeWaterfallStyle(ref style);
911  foreach (var hook in HookChangeWaterfallStyle) {
912  hook(type, ref style);
913  }
914  }
virtual void ChangeWaterfallStyle(ref int style)
Allows you to change the style of waterfall that passes through or over this type of tile...
Definition: ModTile.cs:539
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
static DelegateChangeWaterfallStyle[] HookChangeWaterfallStyle
Definition: TileLoader.cs:82
static void Terraria.ModLoader.TileLoader.CheckModTile ( int  i,
int  j,
int  type 
)
static

Definition at line 297 of file TileLoader.cs.

297  {
298  if (WorldGen.destroyObject) {
299  return;
300  }
301  TileObjectData tileData = TileObjectData.GetTileData(type, 0, 0);
302  if (tileData == null) {
303  return;
304  }
305  int frameX = Main.tile[i, j].frameX;
306  int frameY = Main.tile[i, j].frameY;
307  int subX = frameX / tileData.CoordinateFullWidth;
308  int subY = frameY / tileData.CoordinateFullHeight;
309  int wrap = tileData.StyleWrapLimit;
310  if (wrap == 0) {
311  wrap = 1;
312  }
313  int subTile = tileData.StyleHorizontal ? subY * wrap + subX : subX * wrap + subY;
314  int style = subTile / tileData.StyleMultiplier;
315  int alternate = subTile % tileData.StyleMultiplier;
316  for (int k = 0; k < tileData.AlternatesCount; k++) {
317  if (alternate >= tileData.Alternates[k].Style && alternate <= tileData.Alternates[k].Style + tileData.RandomStyleRange) {
318  alternate = k;
319  break;
320  }
321  }
322  tileData = TileObjectData.GetTileData(type, style, alternate + 1);
323  int partFrameX = frameX % tileData.CoordinateFullWidth;
324  int partFrameY = frameY % tileData.CoordinateFullHeight;
325  int partX = partFrameX / (tileData.CoordinateWidth + tileData.CoordinatePadding);
326  int partY = 0;
327  int remainingFrameY = partFrameY;
328  while (remainingFrameY > 0) {
329  remainingFrameY -= tileData.CoordinateHeights[partY] + tileData.CoordinatePadding;
330  partY++;
331  }
332  i -= partX;
333  j -= partY;
334  int originX = i + tileData.Origin.X;
335  int originY = j + tileData.Origin.Y;
336  TileObject objectData;
337  bool partiallyDestroyed = false;
338  for (int x = i; x < i + tileData.Width; x++) {
339  for (int y = j; y < j + tileData.Height; y++) {
340  if (!Main.tile[x, y].active() || Main.tile[x, y].type != type) {
341  partiallyDestroyed = true;
342  break;
343  }
344  }
345  if (partiallyDestroyed) {
346  break;
347  }
348  }
349  if (partiallyDestroyed || !TileObject.CanPlace(originX, originY, type, style, 0, out objectData, true, true)) {
350  WorldGen.destroyObject = true;
351  for (int x = i; x < i + tileData.Width; x++) {
352  for (int y = j; y < j + tileData.Height; y++) {
353  if (Main.tile[x, y].type == type && Main.tile[x, y].active()) {
354  WorldGen.KillTile(x, y, false, false, false);
355  }
356  }
357  }
358  KillMultiTile(i, j, frameX - partFrameX, frameY - partFrameY, type);
359  WorldGen.destroyObject = false;
360  for (int x = i - 1; x < i + tileData.Width + 2; x++) {
361  for (int y = j - 1; y < j + tileData.Height + 2; y++) {
362  WorldGen.TileFrame(x, y, false, false);
363  }
364  }
365  }
366  TileObject.objectPreview.Active = false;
367  }
static void KillMultiTile(int i, int j, int frameX, int frameY, int type)
Definition: TileLoader.cs:591
static int Terraria.ModLoader.TileLoader.CloseDoorID ( Tile  tile)
static

Definition at line 403 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.closeDoorID.

403  {
404  ModTile modTile = GetTile(tile.type);
405  if (modTile != null) {
406  return modTile.closeDoorID;
407  }
408  if (tile.type == TileID.OpenDoor) {
409  return TileID.ClosedDoor;
410  }
411  return -1;
412  }
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
static bool Terraria.ModLoader.TileLoader.CreateDust ( int  i,
int  j,
int  type,
ref int  dustType 
)
static

Definition at line 533 of file TileLoader.cs.

533  {
534  foreach (var hook in HookCreateDust) {
535  if (!hook(i, j, type, ref dustType)) {
536  return false;
537  }
538  }
539  return GetTile(type)?.CreateDust(i, j, ref dustType) ?? true;
540  }
virtual bool CreateDust(int i, int j, ref int type)
Allows you to modify the default type of dust created when the tile at the given coordinates is hit...
Definition: ModTile.cs:268
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
static DelegateCreateDust[] HookCreateDust
Definition: TileLoader.cs:47
static bool Terraria.ModLoader.TileLoader.Dangersense ( int  i,
int  j,
int  type,
Player  player 
)
static

Definition at line 630 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.Dangersense().

630  {
631  ModTile modTile = GetTile(type);
632  if (modTile != null && modTile.Dangersense(i, j, player)) {
633  return true;
634  }
635  foreach (var hook in HookDangersense) {
636  if (hook(i, j, type, player)) {
637  return true;
638  }
639  }
640  return false;
641  }
static Func< int, int, int, Player, bool >[] HookDangersense
Definition: TileLoader.cs:59
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

+ Here is the call graph for this function:

delegate bool Terraria.ModLoader.TileLoader.DelegateCanKillTile ( int  i,
int  j,
int  type,
ref bool  blockDamaged 
)
private
delegate void Terraria.ModLoader.TileLoader.DelegateChangeWaterfallStyle ( int  type,
ref int  style 
)
private
delegate bool Terraria.ModLoader.TileLoader.DelegateCreateDust ( int  i,
int  j,
int  type,
ref int  dustType 
)
private
delegate void Terraria.ModLoader.TileLoader.DelegateDrawEffects ( int  i,
int  j,
int  type,
SpriteBatch  spriteBatch,
ref Color  drawColor,
ref int  nextSpecialDrawIndex 
)
private
delegate void Terraria.ModLoader.TileLoader.DelegateDropCritterChance ( int  i,
int  j,
int  type,
ref int  wormChance,
ref int  grassHopperChance,
ref int  jungleGrubChance 
)
private
delegate void Terraria.ModLoader.TileLoader.DelegateKillTile ( int  i,
int  j,
int  type,
ref bool  fail,
ref bool  effectOnly,
ref bool  noItem 
)
private
delegate void Terraria.ModLoader.TileLoader.DelegateModifyLight ( int  i,
int  j,
int  type,
ref float  r,
ref float  g,
ref float  b 
)
private
delegate void Terraria.ModLoader.TileLoader.DelegateNumDust ( int  i,
int  j,
int  type,
bool  fail,
ref int  num 
)
private
delegate int Terraria.ModLoader.TileLoader.DelegateSaplingGrowthType ( int  type,
ref int  style 
)
private
delegate void Terraria.ModLoader.TileLoader.DelegateSetSpriteEffects ( int  i,
int  j,
int  type,
ref SpriteEffects  spriteEffects 
)
private
delegate bool Terraria.ModLoader.TileLoader.DelegateTileFrame ( int  i,
int  j,
int  type,
ref bool  resetFrame,
ref bool  noBreak 
)
private
static void Terraria.ModLoader.TileLoader.DisableSmartCursor ( Tile  tile,
ref bool  disable 
)
static

Definition at line 369 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.disableSmartCursor.

369  {
370  if (tile.active()) {
371  ModTile modTile = GetTile(tile.type);
372  if (modTile != null) {
373  disable = modTile.disableSmartCursor;
374  }
375  }
376  }
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
static void Terraria.ModLoader.TileLoader.DisableSmartInteract ( Tile  tile,
ref bool  disable 
)
static

Definition at line 378 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.disableSmartInteract.

378  {
379  if (tile.active()) {
380  ModTile modTile = GetTile(tile.type);
381  if (modTile != null) {
382  disable = modTile.disableSmartInteract;
383  }
384  }
385  }
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
static void Terraria.ModLoader.TileLoader.DrawEffects ( int  i,
int  j,
int  type,
SpriteBatch  spriteBatch,
ref Color  drawColor,
ref int  nextSpecialDrawIndex 
)
static

Definition at line 714 of file TileLoader.cs.

714  {
715  GetTile(type)?.DrawEffects(i, j, spriteBatch, ref drawColor, ref nextSpecialDrawIndex);
716  foreach (var hook in HookDrawEffects) {
717  hook(i, j, type, spriteBatch, ref drawColor, ref nextSpecialDrawIndex);
718  }
719  }
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
virtual void DrawEffects(int i, int j, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
Allows you to make stuff happen whenever the tile at the given coordinates is drawn. For example, creating dust or changing the color the tile is drawn in.
Definition: ModTile.cs:408
static DelegateDrawEffects[] HookDrawEffects
Definition: TileLoader.cs:65
static bool Terraria.ModLoader.TileLoader.Drop ( int  i,
int  j,
int  type 
)
static

Definition at line 553 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.drop, Terraria.ModLoader.ModTile.Drop(), and Terraria.ModLoader.Item.

553  {
554  foreach (var hook in HookDrop) {
555  if (!hook(i, j, type)) {
556  return false;
557  }
558  }
559  ModTile modTile = GetTile(type);
560  if (modTile != null) {
561  if (!modTile.Drop(i, j)) {
562  return false;
563  }
564  if (modTile.drop > 0) {
565  Item.NewItem(i * 16, j * 16, 16, 16, modTile.drop, 1, false, -1);
566  }
567  return false;
568  }
569  return true;
570  }
static Func< int, int, int, bool >[] HookDrop
Definition: TileLoader.cs:50
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

+ Here is the call graph for this function:

static void Terraria.ModLoader.TileLoader.DropCritterChance ( int  i,
int  j,
int  type,
ref int  wormChance,
ref int  grassHopperChance,
ref int  jungleGrubChance 
)
static

Definition at line 543 of file TileLoader.cs.

543  {
544  GetTile(type)?.DropCritterChance(i, j, ref wormChance, ref grassHopperChance, ref jungleGrubChance);
545 
546  foreach (var hook in HookDropCritterChance) {
547  hook(i, j, type, ref wormChance, ref grassHopperChance, ref jungleGrubChance);
548  }
549  }
virtual void DropCritterChance(int i, int j, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance)
Allows you to modify the chance the tile at the given coordinates has of spawning a certain critter w...
Definition: ModTile.cs:278
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
static DelegateDropCritterChance[] HookDropCritterChance
Definition: TileLoader.cs:49
static void Terraria.ModLoader.TileLoader.DropPalmTreeWood ( int  type,
ref int  wood 
)
static

Definition at line 1004 of file TileLoader.cs.

1004  {
1005  if (palmTrees.ContainsKey(type)) {
1006  wood = palmTrees[type].DropWood();
1007  }
1008  }
static void Terraria.ModLoader.TileLoader.DropTreeWood ( int  type,
ref int  wood 
)
static

Definition at line 968 of file TileLoader.cs.

968  {
969  if (trees.ContainsKey(type)) {
970  wood = trees[type].DropWood();
971  }
972  }
static void Terraria.ModLoader.TileLoader.FixSmartInteractCoords ( int  type,
ref int  width,
ref int  height,
ref int  frameWidth,
ref int  frameHeight,
ref int  extraX,
ref int  extraY 
)
static

Definition at line 493 of file TileLoader.cs.

493  {
494  ModTile modTile = GetTile(type);
495  if (modTile != null) {
496  TileObjectData data = TileObjectData.GetTileData(type, 0);
497  width = data.Width;
498  height = data.Height;
499  frameWidth = data.CoordinateWidth + data.CoordinatePadding;
500  frameHeight = data.CoordinateHeights[0] + data.CoordinatePadding;
501  extraY = data.CoordinateFullHeight % frameHeight;
502  }
503  }
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
static void Terraria.ModLoader.TileLoader.FloorVisuals ( int  type,
Player  player 
)
static

Definition at line 883 of file TileLoader.cs.

883  {
884  GetTile(type)?.FloorVisuals(player);
885 
886  foreach (var hook in HookFloorVisuals) {
887  hook(type, player);
888  }
889  }
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
virtual void FloorVisuals(Player player)
Allows you to make something happen when a player stands on this type of tile. For example...
Definition: ModTile.cs:516
static Action< int, Player >[] HookFloorVisuals
Definition: TileLoader.cs:80
static Texture2D Terraria.ModLoader.TileLoader.GetCactusTexture ( int  type)
static

Definition at line 1022 of file TileLoader.cs.

1022  {
1023  return cacti.ContainsKey(type) ? cacti[type].GetTexture() : null;
1024  }
static Texture2D Terraria.ModLoader.TileLoader.GetPalmTreeTexture ( Tile  tile)
static

Definition at line 1010 of file TileLoader.cs.

1010  {
1011  return tile.active() && palmTrees.ContainsKey(tile.type) ? palmTrees[tile.type].GetTexture() : null;
1012  }
static Texture2D Terraria.ModLoader.TileLoader.GetPalmTreeTopTextures ( int  type)
static

Definition at line 1014 of file TileLoader.cs.

1014  {
1015  return palmTrees.ContainsKey(type) ? palmTrees[type].GetTopTextures() : null;
1016  }
static ModTile Terraria.ModLoader.TileLoader.GetTile ( 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.

Definition at line 102 of file TileLoader.cs.

Referenced by Terraria.ModLoader.Mod.AddMusicBox().

102  {
103  return type >= TileID.Count && type < TileCount ? tiles[type - TileID.Count] : null;
104  }

+ Here is the caller graph for this function:

static Texture2D Terraria.ModLoader.TileLoader.GetTreeBranchTextures ( int  type,
int  i,
int  j,
int  trunkOffset,
ref int  frame 
)
static

Definition at line 984 of file TileLoader.cs.

984  {
985  return trees.ContainsKey(type) ? trees[type].GetBranchTextures(i, j, trunkOffset, ref frame) : null;
986  }
static Texture2D Terraria.ModLoader.TileLoader.GetTreeTexture ( Tile  tile)
static

Definition at line 974 of file TileLoader.cs.

974  {
975  return tile.active() && trees.ContainsKey(tile.type) ? trees[tile.type].GetTexture() : null;
976  }
static Texture2D Terraria.ModLoader.TileLoader.GetTreeTopTextures ( int  type,
int  i,
int  j,
ref int  frame,
ref int  frameWidth,
ref int  frameHeight,
ref int  xOffsetLeft,
ref int  yOffset 
)
static

Definition at line 978 of file TileLoader.cs.

979  {
980  return trees.ContainsKey(type) ? trees[type].GetTopTextures(i, j, ref frame,
981  ref frameWidth, ref frameHeight, ref xOffsetLeft, ref yOffset) : null;
982  }
static bool Terraria.ModLoader.TileLoader.HasSmartInteract ( int  type)
static

Definition at line 489 of file TileLoader.cs.

489  {
490  return GetTile(type)?.HasSmartInteract() ?? false;
491  }
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
virtual bool HasSmartInteract()
Whether or not the smart interact function can select this tile. Useful for things like chests...
Definition: ModTile.cs:242
static bool Terraria.ModLoader.TileLoader.HasWalkDust ( int  type)
static

Definition at line 901 of file TileLoader.cs.

901  {
902  return GetTile(type)?.HasWalkDust() ?? false;
903  }
virtual bool HasWalkDust()
Whether or not this tile creates dust when the player walks on it. Returns false by default...
Definition: ModTile.cs:522
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
static void Terraria.ModLoader.TileLoader.HitWire ( int  i,
int  j,
int  type 
)
static

Definition at line 875 of file TileLoader.cs.

875  {
876  GetTile(type)?.HitWire(i, j);
877 
878  foreach (var hook in HookHitWire) {
879  hook(i, j, type);
880  }
881  }
static Action< int, int, int >[] HookHitWire
Definition: TileLoader.cs:78
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
virtual void HitWire(int i, int j)
Allows you to make something happen when a wire current passes through this tile. ...
Definition: ModTile.cs:500
static bool Terraria.ModLoader.TileLoader.IsClosedDoor ( Tile  tile)
static

Definition at line 413 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.openDoorID.

413  {
414  ModTile modTile = GetTile(tile.type);
415  if (modTile != null) {
416  return modTile.openDoorID > -1;
417  }
418  return tile.type == TileID.ClosedDoor;
419  }
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
static bool Terraria.ModLoader.TileLoader.IsDresser ( int  type)
static

Definition at line 429 of file TileLoader.cs.

429  {
430  if (type == TileID.Dressers) {
431  return true;
432  }
433  return ModDresserName(type).Length > 0;
434  }
static string ModDresserName(int type)
Definition: TileLoader.cs:436
static bool Terraria.ModLoader.TileLoader.IsModBed ( int  type)
static

Definition at line 444 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.bed.

444  {
445  ModTile modTile = GetTile(type);
446  if (modTile == null) {
447  return false;
448  }
449  return modTile.bed;
450  }
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
static bool Terraria.ModLoader.TileLoader.IsModMusicBox ( Tile  tile)
static

Definition at line 468 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.PostSetDefaults(), Terraria.ModLoader.ModTile.SetDefaults(), and Terraria.ModLoader.ModTile.Type.

468  {
469  return SoundLoader.tileToMusic.ContainsKey(tile.type)
470  && SoundLoader.tileToMusic[tile.type].ContainsKey(tile.frameY / 36 * 36);
471  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.TileLoader.IsSapling ( int  type)
static

Definition at line 460 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.sapling.

460  {
461  ModTile modTile = GetTile(type);
462  if (modTile == null) {
463  return type == TileID.Saplings;
464  }
465  return modTile.sapling;
466  }
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
static bool Terraria.ModLoader.TileLoader.IsTorch ( int  type)
static

Definition at line 452 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.torch.

452  {
453  ModTile modTile = GetTile(type);
454  if (modTile == null) {
455  return type == TileID.Torches;
456  }
457  return modTile.torch;
458  }
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
static void Terraria.ModLoader.TileLoader.KillMultiTile ( int  i,
int  j,
int  frameX,
int  frameY,
int  type 
)
static

Definition at line 591 of file TileLoader.cs.

591  {
592  GetTile(type)?.KillMultiTile(i, j, frameX, frameY);
593  }
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
virtual void KillMultiTile(int i, int j, int frameX, int frameY)
This hook is called exactly once whenever a block encompassing multiple tiles is destroyed. You can use it to make your multi-tile block drop a single item, for example.
Definition: ModTile.cs:312
static bool Terraria.ModLoader.TileLoader.KillSound ( int  i,
int  j,
int  type 
)
static

Definition at line 506 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.KillSound(), Terraria.ModLoader.ModTile.soundStyle, and Terraria.ModLoader.ModTile.soundType.

506  {
507  foreach (var hook in HookKillSound) {
508  if (!hook(i, j, type)) {
509  return false;
510  }
511  }
512  ModTile modTile = GetTile(type);
513  if (modTile != null) {
514  if (!modTile.KillSound(i, j)) {
515  return false;
516  }
517  Main.PlaySound(modTile.soundType, i * 16, j * 16, modTile.soundStyle);
518  return false;
519  }
520  return true;
521  }
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
static Func< int, int, int, bool >[] HookKillSound
Definition: TileLoader.cs:43

+ Here is the call graph for this function:

static void Terraria.ModLoader.TileLoader.KillTile ( int  i,
int  j,
int  type,
ref bool  fail,
ref bool  effectOnly,
ref bool  noItem 
)
static

Definition at line 583 of file TileLoader.cs.

583  {
584  GetTile(type)?.KillTile(i, j, ref fail, ref effectOnly, ref noItem);
585 
586  foreach (var hook in HookKillTile) {
587  hook(i, j, type, ref fail, ref effectOnly, ref noItem);
588  }
589  }
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
virtual void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem)
Allows you to determine what happens when the tile at the given coordinates is killed or hit with a p...
Definition: ModTile.cs:304
static DelegateKillTile[] HookKillTile
Definition: TileLoader.cs:54
static void Terraria.ModLoader.TileLoader.MineDamage ( int  minePower,
ref int  damage 
)
static

Definition at line 771 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.mineResist.

771  {
772  Tile target = Main.tile[Player.tileTargetX, Player.tileTargetY];
773  ModTile modTile = GetTile(target.type);
774  damage += modTile != null ? (int)(minePower / modTile.mineResist) : minePower;
775  }
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
static string Terraria.ModLoader.TileLoader.ModChestName ( int  type)
static

Definition at line 421 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.chest.

421  {
422  ModTile modTile = GetTile(type);
423  if (modTile != null) {
424  return modTile.chest;
425  }
426  return "";
427  }
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
static string Terraria.ModLoader.TileLoader.ModDresserName ( int  type)
static

Definition at line 436 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.dresser.

436  {
437  ModTile modTile = GetTile(type);
438  if (modTile != null) {
439  return modTile.dresser;
440  }
441  return "";
442  }
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
static void Terraria.ModLoader.TileLoader.ModifyLight ( int  i,
int  j,
int  type,
ref float  r,
ref float  g,
ref float  b 
)
static

Definition at line 619 of file TileLoader.cs.

619  {
620  if (!Main.tileLighted[type]) {
621  return;
622  }
623  GetTile(type)?.ModifyLight(i, j, ref r, ref g, ref b);
624 
625  foreach (var hook in HookModifyLight) {
626  hook(i, j, type, ref r, ref g, ref b);
627  }
628  }
virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b)
Allows you to determine how much light this block emits. Make sure you set Main.tileLighted[Type] to ...
Definition: ModTile.cs:337
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
static DelegateModifyLight[] HookModifyLight
Definition: TileLoader.cs:58
static void Terraria.ModLoader.TileLoader.MouseOver ( int  i,
int  j 
)
static

Definition at line 822 of file TileLoader.cs.

822  {
823  int type = Main.tile[i, j].type;
824  GetTile(type)?.MouseOver(i, j);
825 
826  foreach (var hook in HookMouseOver) {
827  hook(i, j, type);
828  }
829  }
virtual void MouseOver(int i, int j)
Allows you to make something happen when the mouse hovers over this tile. Useful for showing item ico...
Definition: ModTile.cs:475
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
static Action< int, int, int >[] HookMouseOver
Definition: TileLoader.cs:74
static void Terraria.ModLoader.TileLoader.MouseOverFar ( int  i,
int  j 
)
static

Definition at line 831 of file TileLoader.cs.

831  {
832  int type = Main.tile[i, j].type;
833  GetTile(type)?.MouseOverFar(i, j);
834 
835  foreach (var hook in HookMouseOverFar) {
836  hook(i, j, type);
837  }
838  }
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
static Action< int, int, int >[] HookMouseOverFar
Definition: TileLoader.cs:75
virtual void MouseOverFar(int i, int j)
Allows you to make something happen when the mouse hovers over this tile, even when the player is far...
Definition: ModTile.cs:483
static void Terraria.ModLoader.TileLoader.NearbyEffects ( int  i,
int  j,
int  type,
bool  closer 
)
static

Definition at line 610 of file TileLoader.cs.

610  {
611  GetTile(type)?.NearbyEffects(i, j, closer);
612 
613  foreach (var hook in HookNearbyEffects) {
614  hook(i, j, type, closer);
615  }
616  }
virtual void NearbyEffects(int i, int j, bool closer)
Allows you to make things happen when this tile is within a certain range of the player (around the s...
Definition: ModTile.cs:329
static Action< int, int, int, bool >[] HookNearbyEffects
Definition: TileLoader.cs:56
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
static void Terraria.ModLoader.TileLoader.NumDust ( int  i,
int  j,
int  type,
bool  fail,
ref int  numDust 
)
static

Definition at line 524 of file TileLoader.cs.

524  {
525  GetTile(type)?.NumDust(i, j, fail, ref numDust);
526 
527  foreach (var hook in HookNumDust) {
528  hook(i, j, type, fail, ref numDust);
529  }
530  }
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
static DelegateNumDust[] HookNumDust
Definition: TileLoader.cs:45
virtual void NumDust(int i, int j, bool fail, ref int num)
Allows you to change how many dust particles are created when the tile at the given coordinates is hi...
Definition: ModTile.cs:260
static int Terraria.ModLoader.TileLoader.OpenDoorID ( Tile  tile)
static

Definition at line 389 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.openDoorID.

389  {
390  ModTile modTile = GetTile(tile.type);
391  if (modTile != null) {
392  return modTile.openDoorID;
393  }
394  if (tile.type == TileID.ClosedDoor && (tile.frameY < 594 || tile.frameY > 646 || tile.frameX >= 54)) {
395  return TileID.OpenDoor;
396  }
397  return -1;
398  }
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
static void Terraria.ModLoader.TileLoader.PalmTreeDust ( Tile  tile,
ref int  dust 
)
static

Definition at line 992 of file TileLoader.cs.

992  {
993  if (tile.active() && palmTrees.ContainsKey(tile.type)) {
994  dust = palmTrees[tile.type].CreateDust();
995  }
996  }
static void Terraria.ModLoader.TileLoader.PalmTreeGrowthFXGore ( int  type,
ref int  gore 
)
static

Definition at line 998 of file TileLoader.cs.

998  {
999  if (palmTrees.ContainsKey(type)) {
1000  gore = palmTrees[type].GrowthFXGore();
1001  }
1002  }
static void Terraria.ModLoader.TileLoader.PickPowerCheck ( Tile  target,
int  pickPower,
ref int  damage 
)
static

Definition at line 778 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.minPick.

778  {
779  ModTile modTile = GetTile(target.type);
780  if (modTile != null && pickPower < modTile.minPick) {
781  damage = 0;
782  }
783  }
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
static void Terraria.ModLoader.TileLoader.PlaceInWorld ( int  i,
int  j,
Item  item 
)
static

Definition at line 1026 of file TileLoader.cs.

1026  {
1027  int type = item.createTile;
1028  if (type < 0)
1029  return;
1030 
1031  foreach (var hook in HookPlaceInWorld) {
1032  hook(i, j, item);
1033  }
1034 
1035  GetTile(type)?.PlaceInWorld(i, j, item);
1036  }
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
static Action< int, int, Item >[] HookPlaceInWorld
Definition: TileLoader.cs:85
virtual void PlaceInWorld(int i, int j, Item item)
Allows you to do something when this tile is placed.
Definition: ModTile.cs:557
static void Terraria.ModLoader.TileLoader.PostDraw ( int  i,
int  j,
int  type,
SpriteBatch  spriteBatch 
)
static

Definition at line 722 of file TileLoader.cs.

722  {
723  GetTile(type)?.PostDraw(i, j, spriteBatch);
724 
725  foreach (var hook in HookPostDraw) {
726  hook(i, j, type, spriteBatch);
727  }
728  }
virtual void PostDraw(int i, int j, SpriteBatch spriteBatch)
Allows you to draw things in front of the tile at the given coordinates. This can also be used to do ...
Definition: ModTile.cs:416
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
static Action< int, int, int, SpriteBatch >[] HookPostDraw
Definition: TileLoader.cs:66
static bool Terraria.ModLoader.TileLoader.PreDraw ( int  i,
int  j,
int  type,
SpriteBatch  spriteBatch 
)
static

Definition at line 705 of file TileLoader.cs.

705  {
706  foreach (var hook in HookPreDraw) {
707  if (!hook(i, j, type, spriteBatch)) {
708  return false;
709  }
710  }
711  return GetTile(type)?.PreDraw(i, j, spriteBatch) ?? true;
712  }
virtual bool PreDraw(int i, int j, SpriteBatch spriteBatch)
Allows you to draw things behind the tile at the given coordinates. Return false to stop the game fro...
Definition: ModTile.cs:398
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
static Func< int, int, int, SpriteBatch, bool >[] HookPreDraw
Definition: TileLoader.cs:63
static bool Terraria.ModLoader.TileLoader.PreHitWire ( int  i,
int  j,
int  type 
)
static

Definition at line 863 of file TileLoader.cs.

863  {
864  foreach (var hook in HookPreHitWire) {
865  if (!hook(i, j, type)) {
866  return false;
867  }
868  }
869  return true;
870  }
static Func< int, int, int, bool >[] HookPreHitWire
Definition: TileLoader.cs:77
static void Terraria.ModLoader.TileLoader.RandomUpdate ( int  i,
int  j,
int  type 
)
static

Definition at line 744 of file TileLoader.cs.

744  {
745  if (!Main.tile[i, j].active()) {
746  return;
747  }
748  GetTile(type)?.RandomUpdate(i, j);
749 
750  foreach (var hook in HookRandomUpdate) {
751  hook(i, j, type);
752  }
753  }
virtual void RandomUpdate(int i, int j)
Called whenever the world randomly decides to update this tile in a given tick. Useful for things suc...
Definition: ModTile.cs:441
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
static Action< int, int, int >[] HookRandomUpdate
Definition: TileLoader.cs:68
static void Terraria.ModLoader.TileLoader.Resize2DArray< T > ( ref T  array[,],
int  newSize 
)
staticprivate

Definition at line 106 of file TileLoader.cs.

106  {
107  int dim1 = array.GetLength(0);
108  int dim2 = array.GetLength(1);
109  T[,] newArray = new T[newSize, dim2];
110  for (int j = 0; j < newSize && j < dim1; j++) {
111  for (int k = 0; k < dim2; k++) {
112  newArray[j, k] = array[j, k];
113  }
114  }
115  array = newArray;
116  }
static void Terraria.ModLoader.TileLoader.RightClick ( int  i,
int  j 
)
static

Definition at line 812 of file TileLoader.cs.

812  {
813  int type = Main.tile[i, j].type;
814  GetTile(type)?.RightClick(i, j);
815 
816  foreach (var hook in HookRightClick) {
817  hook(i, j, type);
818  }
819  }
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
virtual void RightClick(int i, int j)
Allows you to make something happen when this tile is right-clicked by the player.
Definition: ModTile.cs:467
static Action< int, int, int >[] HookRightClick
Definition: TileLoader.cs:73
static bool Terraria.ModLoader.TileLoader.SaplingGrowthType ( int  type,
ref int  saplingType,
ref int  style 
)
static

Definition at line 916 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.SaplingGrowthType().

916  {
917  int originalType = saplingType;
918  int originalStyle = style;
919  bool flag = false;
920  ModTile modTile = GetTile(type);
921  if (modTile != null) {
922  saplingType = modTile.SaplingGrowthType(ref style);
923  if (IsSapling(saplingType)) {
924  originalType = saplingType;
925  originalStyle = style;
926  flag = true;
927  }
928  else {
929  saplingType = originalType;
930  style = originalStyle;
931  }
932  }
933  foreach (var hook in HookSaplingGrowthType) {
934  saplingType = hook(type, ref style);
935  if (IsSapling(saplingType)) {
936  originalType = saplingType;
937  originalStyle = style;
938  flag = true;
939  }
940  else {
941  saplingType = originalType;
942  style = originalStyle;
943  }
944  }
945  return flag;
946  }
static DelegateSaplingGrowthType[] HookSaplingGrowthType
Definition: TileLoader.cs:84
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
static bool IsSapling(int type)
Definition: TileLoader.cs:460

+ Here is the call graph for this function:

static void Terraria.ModLoader.TileLoader.SetAnimationFrame ( int  type,
int  i,
int  j,
ref int  frameXOffset,
ref int  frameYOffset 
)
static

Sets the animation frame. Sets frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type]; and then calls ModTile.AnimateIndividualTile

Parameters
typeThe tile type.
iThe x position in tile coordinates.
jThe y position in tile coordinates.
frameXOffsetThe offset to frameX.
frameYOffsetThe offset to frameY.

Definition at line 694 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.AnimateIndividualTile(), and Terraria.ModLoader.ModTile.animationFrameHeight.

694  {
695  ModTile modTile = GetTile(type);
696  if (modTile != null) {
697  frameYOffset = modTile.animationFrameHeight * Main.tileFrame[type];
698  modTile.AnimateIndividualTile(type, i, j, ref frameXOffset, ref frameYOffset);
699  }
700  }
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

+ Here is the call graph for this function:

static void Terraria.ModLoader.TileLoader.SetDrawPositions ( int  i,
int  j,
ref int  width,
ref int  offsetY,
ref int  height 
)
static

Definition at line 653 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.SetDrawPositions().

653  {
654  Tile tile = Main.tile[i, j];
655  if (tile.type >= TileID.Count) {
656  TileObjectData tileData = TileObjectData.GetTileData(tile.type, 0, 0);
657  if (tileData != null) {
658  int partFrameY = tile.frameY % tileData.CoordinateFullHeight;
659  int partY = 0;
660  while (partFrameY > 0) {
661  partFrameY -= tileData.CoordinateHeights[partY] + tileData.CoordinatePadding;
662  partY++;
663  }
664  width = tileData.CoordinateWidth;
665  offsetY = tileData.DrawYOffset;
666  height = tileData.CoordinateHeights[partY];
667  }
668  GetTile(tile.type).SetDrawPositions(i, j, ref width, ref offsetY, ref height);
669  }
670  }
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
virtual void SetDrawPositions(int i, int j, ref int width, ref int offsetY, ref int height)
Allows you to customize the position in which this tile is drawn. Width refers to the width of one fr...
Definition: ModTile.cs:362

+ Here is the call graph for this function:

static void Terraria.ModLoader.TileLoader.SetSpriteEffects ( int  i,
int  j,
int  type,
ref SpriteEffects  spriteEffects 
)
static

Definition at line 644 of file TileLoader.cs.

644  {
645  GetTile(type)?.SetSpriteEffects(i, j, ref spriteEffects);
646 
647  foreach (var hook in HookSetSpriteEffects) {
648  hook(i, j, type, ref spriteEffects);
649  }
650  }
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
static DelegateSetSpriteEffects[] HookSetSpriteEffects
Definition: TileLoader.cs:61
virtual void SetSpriteEffects(int i, int j, ref SpriteEffects spriteEffects)
Allows you to determine whether or not the tile will draw itself flipped in the world.
Definition: ModTile.cs:354
static bool Terraria.ModLoader.TileLoader.Slope ( int  i,
int  j,
int  type 
)
static

Definition at line 892 of file TileLoader.cs.

892  {
893  foreach (var hook in HookSlope) {
894  if (!hook(i, j, type)) {
895  return true;
896  }
897  }
898  return !GetTile(type)?.Slope(i, j) ?? false;
899  }
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
static Func< int, int, int, bool >[] HookSlope
Definition: TileLoader.cs:79
virtual bool Slope(int i, int j)
Allows you to control how hammers slope this tile. Return true to allow it to slope normally...
Definition: ModTile.cs:508
static void Terraria.ModLoader.TileLoader.SpecialDraw ( int  type,
int  specX,
int  specY,
SpriteBatch  spriteBatch 
)
static

Special Draw calls ModTile and GlobalTile SpecialDraw methods. Special Draw is called from DrawTiles after the draw loop, allowing for basically another layer above tiles. Main.specX and Main.specY are used to specify tiles to call SpecialDraw on. Use DrawEffects hook to queue for SpecialDraw.

Definition at line 733 of file TileLoader.cs.

733  {
734  GetTile(type)?.SpecialDraw(specX, specY, spriteBatch);
735 
736  foreach (var hook in HookSpecialDraw) {
737  hook(specX, specY, type, spriteBatch);
738  }
739  }
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
virtual void SpecialDraw(int i, int j, SpriteBatch spriteBatch)
Special Draw. Only called if coordinates are placed in Main.specX/Y during DrawEffects. Useful for drawing things that would otherwise be impossible to draw due to draw order, such as items in item frames.
Definition: ModTile.cs:424
static Action< int, int, int, SpriteBatch >[] HookSpecialDraw
Definition: TileLoader.cs:67
static bool Terraria.ModLoader.TileLoader.TileFrame ( int  i,
int  j,
int  type,
ref bool  resetFrame,
ref bool  noBreak 
)
static

Definition at line 756 of file TileLoader.cs.

References Terraria.ModLoader.ModTile.TileFrame().

756  {
757  ModTile modTile = GetTile(type);
758  bool flag = true;
759  if (modTile != null) {
760  flag = modTile.TileFrame(i, j, ref resetFrame, ref noBreak);
761  }
762  foreach (var hook in HookTileFrame) {
763  flag &= hook(i, j, type, ref resetFrame, ref noBreak);
764  }
765  return flag;
766  }
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
static DelegateTileFrame[] HookTileFrame
Definition: TileLoader.cs:70

+ Here is the call graph for this function:

static void Terraria.ModLoader.TileLoader.TreeDust ( Tile  tile,
ref int  dust 
)
static

Definition at line 952 of file TileLoader.cs.

952  {
953  if (tile.active() && trees.ContainsKey(tile.type)) {
954  dust = trees[tile.type].CreateDust();
955  }
956  }
static void Terraria.ModLoader.TileLoader.TreeGrowthFXGore ( int  type,
ref int  gore 
)
static

Definition at line 958 of file TileLoader.cs.

958  {
959  if (trees.ContainsKey(type)) {
960  gore = trees[type].GrowthFXGore();
961  }
962  }
static void Terraria.ModLoader.TileLoader.WalkDust ( int  type,
ref int  dustType,
ref bool  makeDust,
ref Color  color 
)
static

Definition at line 905 of file TileLoader.cs.

905  {
906  GetTile(type)?.WalkDust(ref dustType, ref makeDust, ref color);
907  }
virtual void WalkDust(ref int dustType, ref bool makeDust, ref Color color)
Allows you to modify the dust created when the player walks on this tile. The makeDust parameter is w...
Definition: ModTile.cs:532
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

Member Data Documentation

Func<int, int[]> [] Terraria.ModLoader.TileLoader.HookAdjTiles
staticprivate

Definition at line 72 of file TileLoader.cs.

Action [] Terraria.ModLoader.TileLoader.HookAnimateTile
staticprivate

Definition at line 62 of file TileLoader.cs.

Func<int, int, int, Item, bool> [] Terraria.ModLoader.TileLoader.HookAutoSelect
staticprivate

Definition at line 76 of file TileLoader.cs.

Func<int, int, int, bool> [] Terraria.ModLoader.TileLoader.HookCanExplode
staticprivate

Definition at line 55 of file TileLoader.cs.

DelegateCanKillTile [] Terraria.ModLoader.TileLoader.HookCanKillTile
staticprivate

Definition at line 52 of file TileLoader.cs.

Func<int, int, int, bool> [] Terraria.ModLoader.TileLoader.HookCanPlace
staticprivate

Definition at line 71 of file TileLoader.cs.

DelegateChangeWaterfallStyle [] Terraria.ModLoader.TileLoader.HookChangeWaterfallStyle
staticprivate

Definition at line 82 of file TileLoader.cs.

DelegateCreateDust [] Terraria.ModLoader.TileLoader.HookCreateDust
staticprivate

Definition at line 47 of file TileLoader.cs.

Func<int, int, int, Player, bool> [] Terraria.ModLoader.TileLoader.HookDangersense
staticprivate

Definition at line 59 of file TileLoader.cs.

DelegateDrawEffects [] Terraria.ModLoader.TileLoader.HookDrawEffects
staticprivate

Definition at line 65 of file TileLoader.cs.

Func<int, int, int, bool> [] Terraria.ModLoader.TileLoader.HookDrop
staticprivate

Definition at line 50 of file TileLoader.cs.

DelegateDropCritterChance [] Terraria.ModLoader.TileLoader.HookDropCritterChance
staticprivate

Definition at line 49 of file TileLoader.cs.

Action<int, Player> [] Terraria.ModLoader.TileLoader.HookFloorVisuals
staticprivate

Definition at line 80 of file TileLoader.cs.

Action<int, int, int> [] Terraria.ModLoader.TileLoader.HookHitWire
staticprivate

Definition at line 78 of file TileLoader.cs.

Func<int, int, int, bool> [] Terraria.ModLoader.TileLoader.HookKillSound
staticprivate

Definition at line 43 of file TileLoader.cs.

DelegateKillTile [] Terraria.ModLoader.TileLoader.HookKillTile
staticprivate

Definition at line 54 of file TileLoader.cs.

DelegateModifyLight [] Terraria.ModLoader.TileLoader.HookModifyLight
staticprivate

Definition at line 58 of file TileLoader.cs.

Action<int, int, int> [] Terraria.ModLoader.TileLoader.HookMouseOver
staticprivate

Definition at line 74 of file TileLoader.cs.

Action<int, int, int> [] Terraria.ModLoader.TileLoader.HookMouseOverFar
staticprivate

Definition at line 75 of file TileLoader.cs.

Action<int, int, int, bool> [] Terraria.ModLoader.TileLoader.HookNearbyEffects
staticprivate

Definition at line 56 of file TileLoader.cs.

DelegateNumDust [] Terraria.ModLoader.TileLoader.HookNumDust
staticprivate

Definition at line 45 of file TileLoader.cs.

Action<int, int, Item> [] Terraria.ModLoader.TileLoader.HookPlaceInWorld
staticprivate

Definition at line 85 of file TileLoader.cs.

Action<int, int, int, SpriteBatch> [] Terraria.ModLoader.TileLoader.HookPostDraw
staticprivate

Definition at line 66 of file TileLoader.cs.

Func<int, int, int, SpriteBatch, bool> [] Terraria.ModLoader.TileLoader.HookPreDraw
staticprivate

Definition at line 63 of file TileLoader.cs.

Func<int, int, int, bool> [] Terraria.ModLoader.TileLoader.HookPreHitWire
staticprivate

Definition at line 77 of file TileLoader.cs.

Action<int, int, int> [] Terraria.ModLoader.TileLoader.HookRandomUpdate
staticprivate

Definition at line 68 of file TileLoader.cs.

Action<int, int, int> [] Terraria.ModLoader.TileLoader.HookRightClick
staticprivate

Definition at line 73 of file TileLoader.cs.

DelegateSaplingGrowthType [] Terraria.ModLoader.TileLoader.HookSaplingGrowthType
staticprivate

Definition at line 84 of file TileLoader.cs.

DelegateSetSpriteEffects [] Terraria.ModLoader.TileLoader.HookSetSpriteEffects
staticprivate

Definition at line 61 of file TileLoader.cs.

Func<int, int, int, bool> [] Terraria.ModLoader.TileLoader.HookSlope
staticprivate

Definition at line 79 of file TileLoader.cs.

Action<int, int, int, SpriteBatch> [] Terraria.ModLoader.TileLoader.HookSpecialDraw
staticprivate

Definition at line 67 of file TileLoader.cs.

DelegateTileFrame [] Terraria.ModLoader.TileLoader.HookTileFrame
staticprivate

Definition at line 70 of file TileLoader.cs.

bool Terraria.ModLoader.TileLoader.loaded = false
staticprivate

Definition at line 37 of file TileLoader.cs.

int Terraria.ModLoader.TileLoader.nextTile = TileID.Count
staticprivate

Definition at line 31 of file TileLoader.cs.

readonly int Terraria.ModLoader.TileLoader.vanillaChairCount = TileID.Sets.RoomNeeds.CountsAsChair.Length
staticprivate

Definition at line 38 of file TileLoader.cs.

readonly int Terraria.ModLoader.TileLoader.vanillaDoorCount = TileID.Sets.RoomNeeds.CountsAsDoor.Length
staticprivate

Definition at line 41 of file TileLoader.cs.

readonly int Terraria.ModLoader.TileLoader.vanillaTableCount = TileID.Sets.RoomNeeds.CountsAsTable.Length
staticprivate

Definition at line 39 of file TileLoader.cs.

readonly int Terraria.ModLoader.TileLoader.vanillaTorchCount = TileID.Sets.RoomNeeds.CountsAsTorch.Length
staticprivate

Definition at line 40 of file TileLoader.cs.