tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.ModWall Class Reference

This class represents a type of wall that can be added by a mod. Only one instance of this class will ever exist for each type of wall that is added. Any hooks that are called will be called by the instance corresponding to the wall type. More...

+ Collaboration diagram for Terraria.ModLoader.ModWall:

Public Member Functions

void AddMapEntry (Color color, LocalizedText name, Func< string, int, int, string > nameFunc)
 Adds an entry to the minimap for this wall 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. More...
 
void AddMapEntry (Color color, LocalizedText name=null)
 Adds an entry to the minimap for this wall with the given color and display name. This should be called in SetDefaults. More...
 
void AddMapEntry (Color color, ModTranslation name)
 Adds an entry to the minimap for this wall with the given color and display name. This should be called in SetDefaults. More...
 
void AddMapEntry (Color color, ModTranslation name, Func< string, int, int, string > nameFunc)
 Adds an entry to the minimap for this wall 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. More...
 
virtual void AnimateWall (ref byte frame, ref byte frameCounter)
 Allows you to animate your wall. Use frameCounter to keep track of how long the current frame has been active, and use frame to change the current frame. More...
 
virtual bool Autoload (ref string name, ref string texture)
 Allows you to modify the name and texture path of this wall when it is autoloaded. Return true to autoload this wall. When a wall is autoloaded, that means you do not need to manually call Mod.AddWall. By default returns the mod's autoload property. More...
 
virtual bool CanExplode (int i, int j)
 Whether or not the wall 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. More...
 
virtual bool CreateDust (int i, int j, ref int type)
 Allows you to modify the default type of dust created when the wall at the given coordinates is hit. Return false to stop the default dust (the type parameter) from being created. Returns true by default. More...
 
ModTranslation CreateMapEntryName (string key=null)
 Creates a ModTranslation object that you can use in AddMapEntry. More...
 
virtual bool Drop (int i, int j, ref int type)
 Allows you to customize which items the wall at the given coordinates drops. Return false to stop the game from dropping the tile's default item (the type parameter). Returns true by default. More...
 
virtual ushort GetMapOption (int i, int j)
 Allows you to choose which minimap entry the wall at the given coordinates will use. 0 is the first entry added by AddMapEntry, 1 is the second entry, etc. Returns 0 by default. More...
 
virtual bool KillSound (int i, int j)
 Allows you to customize which sound you want to play when the wall at the given coordinates is hit. Return false to stop the game from playing its default sound for the wall. Returns true by default. More...
 
virtual void KillWall (int i, int j, ref bool fail)
 Allows you to determine what happens when the tile at the given coordinates is killed or hit with a hammer. Fail determines whether the tile is mined (whether it is killed). More...
 
virtual void ModifyLight (int i, int j, ref float r, ref float g, ref float b)
 Allows you to determine how much light this wall emits. This can also let you light up the block in front of this wall. More...
 
virtual void NumDust (int i, int j, bool fail, ref int num)
 Allows you to change how many dust particles are created when the wall at the given coordinates is hit. More...
 
virtual void PlaceInWorld (int i, int j, Item item)
 Called after this wall is placed in the world by way of the item provided. More...
 
virtual void PostDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things in front of the wall at the given coordinates. More...
 
virtual bool PreDraw (int i, int j, SpriteBatch spriteBatch)
 Allows you to draw things behind the wall at the given coordinates. Return false to stop the game from drawing the wall normally. Returns true by default. More...
 
virtual void RandomUpdate (int i, int j)
 Called whenever the world randomly decides to update the tile containing this wall in a given tick. Useful for things such as growing or spreading. More...
 
virtual void SetDefaults ()
 Allows you to set the properties of this wall. Many properties are stored as arrays throughout Terraria's code. More...
 

Public Attributes

int drop = 0
 The default type of item dropped when this wall is killed. Defaults to 0, which means no item. More...
 
int dustType = 0
 The default type of dust made when this wall is hit. Defaults to 0. More...
 
int soundStyle = 1
 The default style of sound made when this wall is hit. Defaults to 1. More...
 
int soundType = 0
 The default type of sound made when this wall is hit. Defaults to 0. More...
 

Properties

Mod mod [get, set]
 The mod which has added this type of ModWall. More...
 
string Name [get, set]
 The name of this type of wall. More...
 
ushort Type [get, set]
 The internal ID of this type of wall. More...
 

Detailed Description

This class represents a type of wall that can be added by a mod. Only one instance of this class will ever exist for each type of wall that is added. Any hooks that are called will be called by the instance corresponding to the wall type.

Definition at line 12 of file ModWall.cs.

Member Function Documentation

◆ AddMapEntry() [1/4]

void Terraria.ModLoader.ModWall.AddMapEntry ( Color  color,
LocalizedText  name,
Func< string, int, int, string >  nameFunc 
)

Adds an entry to the minimap for this wall 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.

Definition at line 97 of file ModWall.cs.

97 {
98 if (!MapLoader.initialized) {
99 MapEntry entry = new MapEntry(color, name, nameFunc);
100 if (!MapLoader.wallEntries.Keys.Contains(Type)) {
101 MapLoader.wallEntries[Type] = new List<MapEntry>();
102 }
103 MapLoader.wallEntries[Type].Add(entry);
104 }
105 }
ushort Type
The internal ID of this type of wall.
Definition: ModWall.cs:33

References Terraria.ModLoader.ModWall.Type.

◆ AddMapEntry() [2/4]

void Terraria.ModLoader.ModWall.AddMapEntry ( Color  color,
LocalizedText  name = null 
)

Adds an entry to the minimap for this wall with the given color and display name. This should be called in SetDefaults.

Definition at line 59 of file ModWall.cs.

59 {
60 if (!MapLoader.initialized) {
61 MapEntry entry = new MapEntry(color, name);
62 if (!MapLoader.wallEntries.Keys.Contains(Type)) {
63 MapLoader.wallEntries[Type] = new List<MapEntry>();
64 }
65 MapLoader.wallEntries[Type].Add(entry);
66 }
67 }

References Terraria.ModLoader.ModWall.Type.

◆ AddMapEntry() [3/4]

void Terraria.ModLoader.ModWall.AddMapEntry ( Color  color,
ModTranslation  name 
)

Adds an entry to the minimap for this wall with the given color and display name. This should be called in SetDefaults.

Definition at line 84 of file ModWall.cs.

84 {
85 if (!MapLoader.initialized) {
86 MapEntry entry = new MapEntry(color, name);
87 if (!MapLoader.wallEntries.Keys.Contains(Type)) {
88 MapLoader.wallEntries[Type] = new List<MapEntry>();
89 }
90 MapLoader.wallEntries[Type].Add(entry);
91 }
92 }

References Terraria.ModLoader.ModWall.Type.

◆ AddMapEntry() [4/4]

void Terraria.ModLoader.ModWall.AddMapEntry ( Color  color,
ModTranslation  name,
Func< string, int, int, string >  nameFunc 
)

Adds an entry to the minimap for this wall 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.

Definition at line 110 of file ModWall.cs.

110 {
111 if (!MapLoader.initialized) {
112 MapEntry entry = new MapEntry(color, name, nameFunc);
113 if (!MapLoader.wallEntries.Keys.Contains(Type)) {
114 MapLoader.wallEntries[Type] = new List<MapEntry>();
115 }
116 MapLoader.wallEntries[Type].Add(entry);
117 }
118 }

References Terraria.ModLoader.ModWall.Type.

◆ AnimateWall()

virtual void Terraria.ModLoader.ModWall.AnimateWall ( ref byte  frame,
ref byte  frameCounter 
)
virtual

Allows you to animate your wall. Use frameCounter to keep track of how long the current frame has been active, and use frame to change the current frame.

Definition at line 197 of file ModWall.cs.

197 {
198 }

Referenced by Terraria.ModLoader.WallLoader.AnimateWalls().

+ Here is the caller graph for this function:

◆ Autoload()

virtual bool Terraria.ModLoader.ModWall.Autoload ( ref string  name,
ref string  texture 
)
virtual

Allows you to modify the name and texture path of this wall when it is autoloaded. Return true to autoload this wall. When a wall is autoloaded, that means you do not need to manually call Mod.AddWall. By default returns the mod's autoload property.

Definition at line 123 of file ModWall.cs.

123 {
124 return mod.Properties.Autoload;
125 }
ModProperties Properties
Definition: Mod.cs:52
Mod mod
The mod which has added this type of ModWall.
Definition: ModWall.cs:17
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...

References Terraria.ModLoader.ModProperties.Autoload, Terraria.ModLoader.ModWall.mod, and Terraria.ModLoader.Mod.Properties.

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

+ Here is the caller graph for this function:

◆ CanExplode()

virtual bool Terraria.ModLoader.ModWall.CanExplode ( int  i,
int  j 
)
virtual

Whether or not the wall 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.

Definition at line 171 of file ModWall.cs.

171 {
172 return true;
173 }

Referenced by Terraria.ModLoader.WallLoader.CanExplode().

+ Here is the caller graph for this function:

◆ CreateDust()

virtual bool Terraria.ModLoader.ModWall.CreateDust ( int  i,
int  j,
ref int  type 
)
virtual

Allows you to modify the default type of dust created when the wall at the given coordinates is hit. Return false to stop the default dust (the type parameter) from being created. Returns true by default.

Definition at line 149 of file ModWall.cs.

149 {
150 type = dustType;
151 return true;
152 }
int dustType
The default type of dust made when this wall is hit. Defaults to 0.
Definition: ModWall.cs:50

References Terraria.ModLoader.ModWall.dustType.

Referenced by Terraria.ModLoader.WallLoader.CreateDust().

+ Here is the caller graph for this function:

◆ CreateMapEntryName()

ModTranslation Terraria.ModLoader.ModWall.CreateMapEntryName ( string  key = null)

Creates a ModTranslation object that you can use in AddMapEntry.

Parameters
keyThe key for the ModTranslation. The full key will be MapObject.ModName.key
Returns

Definition at line 74 of file ModWall.cs.

74 {
75 if (string.IsNullOrEmpty(key)) {
76 key = Name;
77 }
78 return mod.GetOrCreateTranslation(string.Format("Mods.{0}.MapObject.{1}", mod.Name, key));
79 }
virtual string Name
Stores the name of the mod. This name serves as the mod's identification, and also helps with saving ...
Definition: Mod.cs:42
string Name
The name of this type of wall.
Definition: ModWall.cs:25

References Terraria.ModLoader.ModWall.mod, Terraria.ModLoader.Mod.Name, and Terraria.ModLoader.ModWall.Name.

◆ Drop()

virtual bool Terraria.ModLoader.ModWall.Drop ( int  i,
int  j,
ref int  type 
)
virtual

Allows you to customize which items the wall at the given coordinates drops. Return false to stop the game from dropping the tile's default item (the type parameter). Returns true by default.

Definition at line 157 of file ModWall.cs.

157 {
158 type = drop;
159 return true;
160 }
int drop
The default type of item dropped when this wall is killed. Defaults to 0, which means no item.
Definition: ModWall.cs:54

References Terraria.ModLoader.ModWall.drop.

Referenced by Terraria.ModLoader.WallLoader.Drop().

+ Here is the caller graph for this function:

◆ GetMapOption()

virtual ushort Terraria.ModLoader.ModWall.GetMapOption ( int  i,
int  j 
)
virtual

Allows you to choose which minimap entry the wall at the given coordinates will use. 0 is the first entry added by AddMapEntry, 1 is the second entry, etc. Returns 0 by default.

Definition at line 178 of file ModWall.cs.

178 {
179 return 0;
180 }

◆ KillSound()

virtual bool Terraria.ModLoader.ModWall.KillSound ( int  i,
int  j 
)
virtual

Allows you to customize which sound you want to play when the wall at the given coordinates is hit. Return false to stop the game from playing its default sound for the wall. Returns true by default.

Definition at line 136 of file ModWall.cs.

136 {
137 return true;
138 }

Referenced by Terraria.ModLoader.WallLoader.KillSound().

+ Here is the caller graph for this function:

◆ KillWall()

virtual void Terraria.ModLoader.ModWall.KillWall ( int  i,
int  j,
ref bool  fail 
)
virtual

Allows you to determine what happens when the tile at the given coordinates is killed or hit with a hammer. Fail determines whether the tile is mined (whether it is killed).

Definition at line 165 of file ModWall.cs.

165 {
166 }

Referenced by Terraria.ModLoader.WallLoader.KillWall().

+ Here is the caller graph for this function:

◆ ModifyLight()

virtual void Terraria.ModLoader.ModWall.ModifyLight ( int  i,
int  j,
ref float  r,
ref float  g,
ref float  b 
)
virtual

Allows you to determine how much light this wall emits. This can also let you light up the block in front of this wall.

Definition at line 185 of file ModWall.cs.

185 {
186 }

Referenced by Terraria.ModLoader.WallLoader.ModifyLight().

+ Here is the caller graph for this function:

◆ NumDust()

virtual void Terraria.ModLoader.ModWall.NumDust ( int  i,
int  j,
bool  fail,
ref int  num 
)
virtual

Allows you to change how many dust particles are created when the wall at the given coordinates is hit.

Definition at line 143 of file ModWall.cs.

143 {
144 }

Referenced by Terraria.ModLoader.WallLoader.NumDust().

+ Here is the caller graph for this function:

◆ PlaceInWorld()

virtual void Terraria.ModLoader.ModWall.PlaceInWorld ( int  i,
int  j,
Item  item 
)
virtual

Called after this wall is placed in the world by way of the item provided.

Definition at line 216 of file ModWall.cs.

216 {
217 }

Referenced by Terraria.ModLoader.WallLoader.PlaceInWorld().

+ Here is the caller graph for this function:

◆ PostDraw()

virtual void Terraria.ModLoader.ModWall.PostDraw ( int  i,
int  j,
SpriteBatch  spriteBatch 
)
virtual

Allows you to draw things in front of the wall at the given coordinates.

Definition at line 210 of file ModWall.cs.

210 {
211 }

Referenced by Terraria.ModLoader.WallLoader.PostDraw().

+ Here is the caller graph for this function:

◆ PreDraw()

virtual bool Terraria.ModLoader.ModWall.PreDraw ( int  i,
int  j,
SpriteBatch  spriteBatch 
)
virtual

Allows you to draw things behind the wall at the given coordinates. Return false to stop the game from drawing the wall normally. Returns true by default.

Definition at line 203 of file ModWall.cs.

203 {
204 return true;
205 }

Referenced by Terraria.ModLoader.WallLoader.PreDraw().

+ Here is the caller graph for this function:

◆ RandomUpdate()

virtual void Terraria.ModLoader.ModWall.RandomUpdate ( int  i,
int  j 
)
virtual

Called whenever the world randomly decides to update the tile containing this wall in a given tick. Useful for things such as growing or spreading.

Definition at line 191 of file ModWall.cs.

191 {
192 }

Referenced by Terraria.ModLoader.WallLoader.RandomUpdate().

+ Here is the caller graph for this function:

◆ SetDefaults()

virtual void Terraria.ModLoader.ModWall.SetDefaults ( )
virtual

Allows you to set the properties of this wall. Many properties are stored as arrays throughout Terraria's code.

Definition at line 130 of file ModWall.cs.

130 {
131 }

Member Data Documentation

◆ drop

int Terraria.ModLoader.ModWall.drop = 0

The default type of item dropped when this wall is killed. Defaults to 0, which means no item.

Definition at line 54 of file ModWall.cs.

Referenced by Terraria.ModLoader.ModWall.Drop().

◆ dustType

int Terraria.ModLoader.ModWall.dustType = 0

The default type of dust made when this wall is hit. Defaults to 0.

Definition at line 50 of file ModWall.cs.

Referenced by Terraria.ModLoader.ModWall.CreateDust().

◆ soundStyle

int Terraria.ModLoader.ModWall.soundStyle = 1

The default style of sound made when this wall is hit. Defaults to 1.

Definition at line 46 of file ModWall.cs.

Referenced by Terraria.ModLoader.WallLoader.KillSound().

◆ soundType

int Terraria.ModLoader.ModWall.soundType = 0

The default type of sound made when this wall is hit. Defaults to 0.

Definition at line 42 of file ModWall.cs.

Referenced by Terraria.ModLoader.WallLoader.KillSound().

Property Documentation

◆ mod

Mod Terraria.ModLoader.ModWall.mod
getset

The mod which has added this type of ModWall.

Definition at line 17 of file ModWall.cs.

17 {
18 get;
19 internal set;
20 }

Referenced by Terraria.ModLoader.ModWall.Autoload(), and Terraria.ModLoader.ModWall.CreateMapEntryName().

◆ Name

string Terraria.ModLoader.ModWall.Name
getset

The name of this type of wall.

Definition at line 25 of file ModWall.cs.

25 {
26 get;
27 internal set;
28 }

Referenced by Terraria.ModLoader.Mod.AutoloadWall(), and Terraria.ModLoader.ModWall.CreateMapEntryName().

◆ Type

ushort Terraria.ModLoader.ModWall.Type
getset

The internal ID of this type of wall.

Definition at line 33 of file ModWall.cs.

33 {
34 get;
35 internal set;
36 }

Referenced by Terraria.ModLoader.ModWall.AddMapEntry(), and Terraria.ModLoader.WallLoader.AnimateWalls().