1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
4 using System.Collections.Generic;
38 internal string texture;
42 public virtual string HighlightTexture => texture +
"_Highlight";
46 public int soundType = 0;
50 public int soundStyle = 1;
54 public int dustType = 0;
62 public int animationFrameHeight = 0;
66 public float mineResist = 1f;
70 public int minPick = 0;
74 public bool disableSmartCursor =
false;
78 public bool disableSmartInteract =
false;
82 public int[] adjTiles =
new int[0];
86 public int closeDoorID = -1;
90 public int openDoorID = -1;
94 public string chest =
"";
98 public int chestDrop = 0;
102 public string dresser =
"";
106 public int dresserDrop = 0;
110 public bool bed =
false;
114 public bool torch =
false;
118 public bool sapling =
false;
124 Array.Resize(ref array, array.Length + 1);
125 array[array.Length - 1] = Type;
132 if (!MapLoader.initialized) {
133 MapEntry entry =
new MapEntry(color, name);
134 if (!MapLoader.tileEntries.Keys.Contains(Type)) {
135 MapLoader.tileEntries[Type] =
new List<MapEntry>();
137 MapLoader.tileEntries[Type].Add(entry);
147 if (
string.IsNullOrEmpty(key)) {
150 return mod.GetOrCreateTranslation(
string.Format(
"Mods.{0}.MapObject.{1}", mod.Name, key));
157 if (!MapLoader.initialized) {
158 MapEntry entry =
new MapEntry(color, name);
159 if (!MapLoader.tileEntries.Keys.Contains(Type)) {
160 MapLoader.tileEntries[Type] =
new List<MapEntry>();
162 MapLoader.tileEntries[Type].Add(entry);
169 public void AddMapEntry(Color color, LocalizedText name, Func<string, int, int, string> nameFunc) {
170 if (!MapLoader.initialized) {
171 MapEntry entry =
new MapEntry(color, name, nameFunc);
172 if (!MapLoader.tileEntries.Keys.Contains(Type)) {
173 MapLoader.tileEntries[Type] =
new List<MapEntry>();
175 MapLoader.tileEntries[Type].Add(entry);
183 if (!MapLoader.initialized) {
184 MapEntry entry =
new MapEntry(color, name, nameFunc);
185 if (!MapLoader.tileEntries.Keys.Contains(Type)) {
186 MapLoader.tileEntries[Type] =
new List<MapEntry>();
188 MapLoader.tileEntries[Type].Add(entry);
222 public virtual bool Autoload(ref
string name, ref
string texture) {
223 return mod.Properties.Autoload;
260 public virtual void NumDust(
int i,
int j,
bool fail, ref
int num) {
278 public virtual void DropCritterChance(
int i,
int j, ref
int wormChance, ref
int grassHopperChance, ref
int jungleGrubChance) {
286 public virtual bool Drop(
int i,
int j) {
295 public virtual bool CanKillTile(
int i,
int j, ref
bool blockDamaged) {
304 public virtual void KillTile(
int i,
int j, ref
bool fail, ref
bool effectOnly, ref
bool noItem) {
337 public virtual void ModifyLight(
int i,
int j, ref
float r, ref
float g, ref
float b) {
362 public virtual void SetDrawPositions(
int i,
int j, ref
int width, ref
int offsetY, ref
int height) {
378 public virtual void AnimateTile(ref
int frame, ref
int frameCounter) {
398 public virtual bool PreDraw(
int i,
int j, SpriteBatch spriteBatch) {
408 public virtual void DrawEffects(
int i,
int j, SpriteBatch spriteBatch, ref Color drawColor, ref
int nextSpecialDrawIndex) {
416 public virtual void PostDraw(
int i,
int j, SpriteBatch spriteBatch) {
424 public virtual void SpecialDraw(
int i,
int j, SpriteBatch spriteBatch) {
449 public virtual bool TileFrame(
int i,
int j, ref
bool resetFrame, ref
bool noBreak) {
467 [Obsolete(
"ModTile.RightClick will return a bool value later. This version is deprecated since v0.11.5, please use ModTile.NewRightClick instead and return true if a tile interaction has occurred.")]
519 public virtual bool Slope(
int i,
int j) {
543 public virtual void WalkDust(ref
int dustType, ref
bool makeDust, ref Color color) {
577 public virtual bool IsLockedChest(
int i,
int j) =>
false;
591 public virtual bool UnlockChest(
int i,
int j, ref
short frameXAdjustment, ref
int dustType, ref
bool manual) =>
false;
virtual void ChangeWaterfallStyle(ref int style)
Allows you to change the style of waterfall that passes through or over this type of tile...
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...
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...
This class represents a type of tile that can be added by a mod. Only one instance of this class will...
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...
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...
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...
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...
virtual bool HasWalkDust()
Whether or not this tile creates dust when the player walks on it. Returns false by default...
virtual bool NewRightClick(int i, int j)
Allows you to make something happen when this tile is right-clicked by the player. Return true to indicate that a tile interaction has occurred, preventing other right click actions like minion targetting from happening. Returns false by default.
virtual bool CanExplode(int i, int j)
Whether or not the tile at the given coordinates can be killed by an explosion (ie. bombs). Returns true by default; return false to stop an explosion from destroying it.
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 ...
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...
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 ...
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...
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.
ModTranslation CreateMapEntryName(string key=null)
Creates a ModTranslation object that you can use in AddMapEntry.
void AddToArray(ref int[] array)
A convenient method for adding this tile's Type to the given array. This can be used with the arrays ...
This serves as the central class from which tile-related functions are supported and carried out...
virtual bool AutoSelect(int i, int j, Item item)
Allows you to determine whether the given item can become selected when the cursor is hovering over t...
virtual void HitWire(int i, int j)
Allows you to make something happen when a wire current passes through this tile. ...
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...
virtual bool Dangersense(int i, int j, Player player)
Allows you to determine whether this block glows red when the given player has the Dangersense buff...
virtual void FloorVisuals(Player player)
Allows you to make something happen when a player stands on this type of tile. For example...
void AddMapEntry(Color color, ModTranslation name)
Adds an entry to the minimap for this tile with the given color and display name. This should be call...
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.
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...
This class represents a type of modded cactus. The cactus will share a tile ID with the vanilla cacti...
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...
virtual void RightClick(int i, int j)
Allows you to make something happen when this tile is right-clicked by the player.
virtual void AnimateTile(ref int frame, ref int frameCounter)
Allows you to animate your tile. Use frameCounter to keep track of how long the current frame has bee...
void SetModCactus(ModCactus cactus)
Allows this tile to grow the given modded cactus.
virtual bool Slope(int i, int j)
Allows you to control how hammers slope this tile. Return true to allow it to slope normally...
virtual void PostSetDefaults()
Allows you to override some default properties of this tile, such as Main.tileNoSunLight and Main...
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...
virtual bool Drop(int i, int j)
Allows you to customize which items the tile at the given coordinates drops. Remember that the x...
virtual void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset)
Animates an individual tile. i and j are the coordinates of the Tile in question. frameXOffset and fr...
void AddMapEntry(Color color, ModTranslation name, Func< string, int, int, string > nameFunc)
Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.
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...
void SetModPalmTree(ModPalmTree palmTree)
Allows this tile to grow the given modded palm tree.
void AddMapEntry(Color color, LocalizedText name=null)
Adds an entry to the minimap for this tile with the given color and display name. This should be call...
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...
void AddMapEntry(Color color, LocalizedText name, Func< string, int, int, string > nameFunc)
Adds an entry to the minimap for this tile with the given color, default display name, and display name function. The parameters for the function are the default display name, x-coordinate, and y-coordinate. This should be called in SetDefaults.
virtual void SetDefaults()
Allows you to set the properties of this tile. Many properties are stored as arrays throughout Terrar...
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
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.
virtual bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak)
Called whenever this tile updates due to being placed or being next to a tile that is changed...
virtual bool HasSmartInteract()
Whether or not the smart interact function can select this tile. Useful for things like chests...
This class represents a type of modded tree. The tree will share a tile ID with the vanilla trees (5)...
void SetModTree(ModTree tree)
Allows this tile to grow the given modded tree.
This class represents a type of modded palm tree. The palm tree will share a tile ID with the vanilla...
virtual int SaplingGrowthType(ref int style)
Allows this tile to support a sapling that can eventually grow into a tree. The type of the sapling s...
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.
virtual ushort GetMapOption(int i, int j)
Allows you to choose which minimap entry the tile at the given coordinates will use. 0 is the first entry added by AddMapEntry, 1 is the second entry, etc. Returns 0 by default.
virtual bool Autoload(ref string name, ref string texture)
Allows you to modify the name and texture path of this tile when it is autoloaded. Return true to autoload this tile. When a tile is autoloaded, that means you do not need to manually call Mod.AddTile. By default returns the mod's autoload property.
virtual bool KillSound(int i, int j)
Allows you to customize which sound you want to play when the tile at the given coordinates is hit...