tModLoader v0.11.8.9
A mod to make and play Terraria mods
GlobalTile.cs
Go to the documentation of this file.
1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
3using System;
4
5namespace Terraria.ModLoader
6{
10 public class GlobalTile
11 {
15 public Mod mod {
16 get;
17 internal set;
18 }
19
23 public string Name {
24 get;
25 internal set;
26 }
27
33 public void AddToArray(ref int[] array, int type) {
34 Array.Resize(ref array, array.Length + 1);
35 array[array.Length - 1] = type;
36 }
37
43 public void AddModTree(int soilType, ModTree tree) {
44 TileLoader.trees[soilType] = tree;
45 }
46
52 public void AddModPalmTree(int soilType, ModPalmTree palmTree) {
53 TileLoader.palmTrees[soilType] = palmTree;
54 }
55
61 public void AddModCactus(int soilType, ModCactus cactus) {
62 TileLoader.cacti[soilType] = cactus;
63 }
64
70 public virtual bool Autoload(ref string name) {
71 return mod.Properties.Autoload;
72 }
73
77 public virtual void SetDefaults() {
78 }
79
87 public virtual bool KillSound(int i, int j, int type) {
88 return true;
89 }
90
99 public virtual void NumDust(int i, int j, int type, bool fail, ref int num) {
100 }
101
110 public virtual bool CreateDust(int i, int j, int type, ref int dustType) {
111 return true;
112 }
113
123 public virtual void DropCritterChance(int i, int j, int type, ref int wormChance, ref int grassHopperChance, ref int jungleGrubChance) {
124 }
125
129 public virtual bool Drop(int i, int j, int type) {
130 return true;
131 }
132
141 public virtual bool CanKillTile(int i, int j, int type, ref bool blockDamaged) {
142 return true;
143 }
144
154 public virtual void KillTile(int i, int j, int type, ref bool fail, ref bool effectOnly, ref bool noItem) {
155 }
156
164 public virtual bool CanExplode(int i, int j, int type) {
165 return true;
166 }
167
175 public virtual void NearbyEffects(int i, int j, int type, bool closer) {
176 }
177
187 public virtual void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b) {
188 }
189
198 public virtual bool Dangersense(int i, int j, int type, Player player) {
199 return false;
200 }
201
209 public virtual void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects) {
210 }
211
215 public virtual void AnimateTile() {
216 }
217
226 public virtual bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch) {
227 return true;
228 }
229
239 public virtual void DrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex) {
240 }
241
249 public virtual void PostDraw(int i, int j, int type, SpriteBatch spriteBatch) {
250 }
251
257 public virtual void SpecialDraw(int i, int j, int type, SpriteBatch spriteBatch) {
258 }
259
266 public virtual void RandomUpdate(int i, int j, int type) {
267 }
268
278 public virtual bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak) {
279 return true;
280 }
281
289 public virtual bool CanPlace(int i, int j, int type) {
290 return true;
291 }
292
298 public virtual int[] AdjTiles(int type) {
299 return new int[0];
300 }
301
308 public virtual void RightClick(int i, int j, int type) {
309 }
310
317 public virtual void MouseOver(int i, int j, int type) {
318 }
319
326 public virtual void MouseOverFar(int i, int j, int type) {
327 }
328
337 public virtual bool AutoSelect(int i, int j, int type, Item item) {
338 return false;
339 }
340
348 public virtual bool PreHitWire(int i, int j, int type) {
349 return true;
350 }
351
358 public virtual void HitWire(int i, int j, int type) {
359 }
360
368 public virtual bool Slope(int i, int j, int type) {
369 return true;
370 }
371
377 public virtual void FloorVisuals(int type, Player player) {
378 }
379
385 public virtual void ChangeWaterfallStyle(int type, ref int style) {
386 }
387
394 public virtual int SaplingGrowthType(int type, ref int style) {
395 return -1;
396 }
397
404 public virtual void PlaceInWorld(int i, int j, Item item) {
405 }
406 }
407}
This class allows you to modify the behavior of any tile in the game. Create an instance of an overri...
Definition: GlobalTile.cs:11
void AddModPalmTree(int soilType, ModPalmTree palmTree)
Allows the given type of tile to grow the given modded palm tree.
Definition: GlobalTile.cs:52
virtual bool Slope(int i, int j, int type)
Allows you to control how hammers slope any tile. Return true to allow the tile to slope normally....
Definition: GlobalTile.cs:368
virtual bool KillSound(int i, int j, int type)
Allows you to customize which sound you want to play when the tile at the given coordinates is hit....
Definition: GlobalTile.cs:87
void AddToArray(ref int[] array, int type)
A convenient method for adding an integer to the end of an array. This can be used with the arrays in...
Definition: GlobalTile.cs:33
virtual void HitWire(int i, int j, int type)
Allows you to make something happen when a wire current passes through any tile.
Definition: GlobalTile.cs:358
void AddModCactus(int soilType, ModCactus cactus)
Allows the given type of tile to grow the given modded cactus.
Definition: GlobalTile.cs:61
virtual bool Dangersense(int i, int j, int type, Player player)
Allows you to determine whether the block glows red when the given player has the Dangersense buff.
Definition: GlobalTile.cs:198
virtual void DropCritterChance(int i, int j, int type, 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: GlobalTile.cs:123
virtual bool CanExplode(int i, int j, int type)
Whether or not the tile at the given coordinates can be killed by an explosion (ie....
Definition: GlobalTile.cs:164
virtual void PlaceInWorld(int i, int j, Item item)
Allows you to do something when this tile is placed. Called on the local Client and Single Player.
Definition: GlobalTile.cs:404
void AddModTree(int soilType, ModTree tree)
Allows the given type of tile to grow the given modded tree.
Definition: GlobalTile.cs:43
virtual void FloorVisuals(int type, Player player)
Allows you to make something happen when a player stands on the given type of tile....
Definition: GlobalTile.cs:377
virtual bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch)
Allows you to draw things behind the tile at the given coordinates. Return false to stop the game fro...
Definition: GlobalTile.cs:226
virtual void PostDraw(int i, int j, int type, SpriteBatch spriteBatch)
Allows you to draw things in front of the tile at the given coordinates. This can also be used to do ...
Definition: GlobalTile.cs:249
virtual void MouseOver(int i, int j, int type)
Allows you to make something happen when the mouse hovers over any tile. Useful for showing item icon...
Definition: GlobalTile.cs:317
virtual void ChangeWaterfallStyle(int type, ref int style)
Allows you to change the style of waterfall that passes through or over any tile.
Definition: GlobalTile.cs:385
virtual void NearbyEffects(int i, int j, int type, bool closer)
Allows you to make things happen when the tile is within a certain range of the player (around the sa...
Definition: GlobalTile.cs:175
virtual void SpecialDraw(int i, int j, int type, SpriteBatch spriteBatch)
Special Draw. Only called if coordinates are placed in Main.specX/Y during DrawEffects....
Definition: GlobalTile.cs:257
virtual void KillTile(int i, int j, int type, 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: GlobalTile.cs:154
virtual void AnimateTile()
Allows animating tiles that were previously static. Loading a new texture for the tile is required fi...
Definition: GlobalTile.cs:215
virtual void NumDust(int i, int j, int type, 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: GlobalTile.cs:99
virtual bool CreateDust(int i, int j, int type, ref int dustType)
Allows you to modify the default type of dust created when the tile at the given coordinates is hit....
Definition: GlobalTile.cs:110
Mod mod
The mod to which this GlobalTile belongs to.
Definition: GlobalTile.cs:15
virtual bool PreHitWire(int i, int j, int type)
Whether or not the vanilla HitWire code and the HitWire hook is allowed to run. Useful for overriding...
Definition: GlobalTile.cs:348
virtual bool AutoSelect(int i, int j, int type, Item item)
Allows you to determine whether the given item can become selected when the cursor is hovering over a...
Definition: GlobalTile.cs:337
virtual void MouseOverFar(int i, int j, int type)
Allows you to make something happen when the mouse hovers over any tile, even when the player is far ...
Definition: GlobalTile.cs:326
virtual void DrawEffects(int i, int j, int type, SpriteBatch spriteBatch, ref Color drawColor, ref int nextSpecialDrawIndex)
Allows you to make stuff happen whenever the tile at the given coordinates is drawn....
Definition: GlobalTile.cs:239
virtual bool CanKillTile(int i, int j, int type, ref bool blockDamaged)
Allows you to determine whether or not the tile at the given coordinates can be hit by anything....
Definition: GlobalTile.cs:141
virtual int SaplingGrowthType(int type, ref int style)
Allows a tile to support a sapling that can eventually grow into a tree. The type of the sapling shou...
Definition: GlobalTile.cs:394
virtual bool Autoload(ref string name)
Allows you to automatically load a GlobalTile instead of using Mod.AddGlobalTile. Return true to allo...
Definition: GlobalTile.cs:70
virtual void SetDefaults()
Allows you to modify the properties of any tile in the game. Most properties are stored as arrays thr...
Definition: GlobalTile.cs:77
virtual int[] AdjTiles(int type)
Allows you to determine which tiles the given tile type can be considered as when looking for craftin...
Definition: GlobalTile.cs:298
virtual bool TileFrame(int i, int j, int type, ref bool resetFrame, ref bool noBreak)
Called for every tile that updates due to being placed or being next to a tile that is changed....
Definition: GlobalTile.cs:278
string Name
The name of this GlobalTile instance.
Definition: GlobalTile.cs:23
virtual void RightClick(int i, int j, int type)
Allows you to make something happen when any tile is right-clicked by the player.
Definition: GlobalTile.cs:308
virtual void SetSpriteEffects(int i, int j, int type, ref SpriteEffects spriteEffects)
Allows you to determine whether or not a tile will draw itself flipped in the world.
Definition: GlobalTile.cs:209
virtual bool CanPlace(int i, int j, int type)
Allows you to stop a tile from being placed at the given coordinates. Return false to block the tile ...
Definition: GlobalTile.cs:289
virtual bool Drop(int i, int j, int type)
Allows you to customize which items the tile at the given coordinates drops. Return false to stop the...
Definition: GlobalTile.cs:129
virtual void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b)
Allows you to determine how much light the block emits. Make sure you set Main.tileLighted[type] to t...
Definition: GlobalTile.cs:187
virtual void RandomUpdate(int i, int j, int type)
Called for every tile the world randomly decides to update in a given tick. Useful for things such as...
Definition: GlobalTile.cs:266
This class represents a type of modded cactus. The cactus will share a tile ID with the vanilla cacti...
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
Definition: Mod.cs:25
ModProperties Properties
Definition: Mod.cs:52
This class represents a type of modded palm tree. The palm tree will share a tile ID with the vanilla...
This class represents a type of modded tree. The tree will share a tile ID with the vanilla trees (5)...
This serves as the central class from which tile-related functions are supported and carried out.
Definition: TileLoader.cs:15
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...