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

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

+ Collaboration diagram for Terraria.ModLoader.WallLoader:

Static Public Member Functions

static void AnimateWalls ()
 
static bool CanExplode (int i, int j, int type)
 
static bool CreateDust (int i, int j, int type, ref int dustType)
 
static bool Drop (int i, int j, int type, ref int dropType)
 
static ModWall GetWall (int type)
 Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null. More...
 
static bool KillSound (int i, int j, int type)
 
static void KillWall (int i, int j, int type, ref bool fail)
 
static void ModifyLight (int i, int j, int type, ref float r, ref float g, ref float b)
 
static void NumDust (int i, int j, int type, bool fail, ref int numDust)
 
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 void RandomUpdate (int i, int j, int type)
 

Static Public Attributes

static int WallCount => nextWall
 

Private Member Functions

delegate bool DelegateCreateDust (int i, int j, int type, ref int dustType)
 
delegate bool DelegateDrop (int i, int j, int type, ref int dropType)
 
delegate void DelegateKillWall (int i, int j, int type, ref bool fail)
 
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)
 

Static Private Member Functions

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

Static Private Attributes

static Func< int, int, int, bool >[] HookCanExplode
 
static DelegateCreateDust[] HookCreateDust
 
static DelegateDrop[] HookDrop
 
static Func< int, int, int, bool >[] HookKillSound
 
static DelegateKillWall[] HookKillWall
 
static DelegateModifyLight[] HookModifyLight
 
static DelegateNumDust[] HookNumDust
 
static Action< int, int, int, Item >[] HookPlaceInWorld
 
static Action< int, int, int, SpriteBatch >[] HookPostDraw
 
static Func< int, int, int, SpriteBatch, bool >[] HookPreDraw
 
static Action< int, int, int >[] HookRandomUpdate
 
static bool loaded = false
 
static int nextWall = WallID.Count
 

Detailed Description

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

Definition at line 13 of file WallLoader.cs.

Member Function Documentation

static void Terraria.ModLoader.WallLoader.AnimateWalls ( )
static

Definition at line 224 of file WallLoader.cs.

References Terraria.ModLoader.ModWall.AnimateWall(), and Terraria.ModLoader.ModWall.Type.

224  {
225  if (loaded) {
226  for (int i = 0; i < walls.Count; i++) {
227  ModWall modWall = walls[i];
228  modWall.AnimateWall(ref Main.wallFrame[modWall.Type], ref Main.wallFrameCounter[modWall.Type]);
229  }
230  }
231  }

+ Here is the call graph for this function:

static bool Terraria.ModLoader.WallLoader.CanExplode ( int  i,
int  j,
int  type 
)
static

Definition at line 196 of file WallLoader.cs.

196  {
197  foreach (var hook in HookCanExplode) {
198  if (!hook(i, j, type)) {
199  return false;
200  }
201  }
202  return GetWall(type)?.CanExplode(i, j) ?? true;
203  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
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.
Definition: ModWall.cs:171
static Func< int, int, int, bool >[] HookCanExplode
Definition: WallLoader.cs:29
static bool Terraria.ModLoader.WallLoader.CreateDust ( int  i,
int  j,
int  type,
ref int  dustType 
)
static

Definition at line 168 of file WallLoader.cs.

168  {
169  foreach (var hook in HookCreateDust) {
170  if (!hook(i, j, type, ref dustType)) {
171  return false;
172  }
173  }
174  return GetWall(type)?.CreateDust(i, j, ref dustType) ?? true;
175  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
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...
Definition: ModWall.cs:149
static DelegateCreateDust[] HookCreateDust
Definition: WallLoader.cs:24
delegate bool Terraria.ModLoader.WallLoader.DelegateCreateDust ( int  i,
int  j,
int  type,
ref int  dustType 
)
private
delegate bool Terraria.ModLoader.WallLoader.DelegateDrop ( int  i,
int  j,
int  type,
ref int  dropType 
)
private
delegate void Terraria.ModLoader.WallLoader.DelegateKillWall ( int  i,
int  j,
int  type,
ref bool  fail 
)
private
delegate void Terraria.ModLoader.WallLoader.DelegateModifyLight ( int  i,
int  j,
int  type,
ref float  r,
ref float  g,
ref float  b 
)
private
delegate void Terraria.ModLoader.WallLoader.DelegateNumDust ( int  i,
int  j,
int  type,
bool  fail,
ref int  num 
)
private
static bool Terraria.ModLoader.WallLoader.Drop ( int  i,
int  j,
int  type,
ref int  dropType 
)
static

Definition at line 178 of file WallLoader.cs.

178  {
179  foreach (var hook in HookDrop) {
180  if (!hook(i, j, type, ref dropType)) {
181  return false;
182  }
183  }
184  return GetWall(type)?.Drop(i, j, ref dropType) ?? true;
185  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static DelegateDrop[] HookDrop
Definition: WallLoader.cs:26
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...
Definition: ModWall.cs:157
static ModWall Terraria.ModLoader.WallLoader.GetWall ( int  type)
static

Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.

Definition at line 50 of file WallLoader.cs.

50  {
51  return type >= WallID.Count && type < WallCount ? walls[type - WallID.Count] : null;
52  }
static bool Terraria.ModLoader.WallLoader.KillSound ( int  i,
int  j,
int  type 
)
static

Definition at line 141 of file WallLoader.cs.

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

141  {
142  foreach (var hook in HookKillSound) {
143  if (!hook(i, j, type)) {
144  return false;
145  }
146  }
147  ModWall modWall = GetWall(type);
148  if (modWall != null) {
149  if (!modWall.KillSound(i, j)) {
150  return false;
151  }
152  Main.PlaySound(modWall.soundType, i * 16, j * 16, modWall.soundStyle);
153  return false;
154  }
155  return true;
156  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static Func< int, int, int, bool >[] HookKillSound
Definition: WallLoader.cs:20

+ Here is the call graph for this function:

static void Terraria.ModLoader.WallLoader.KillWall ( int  i,
int  j,
int  type,
ref bool  fail 
)
static

Definition at line 188 of file WallLoader.cs.

188  {
189  GetWall(type)?.KillWall(i, j, ref fail);
190 
191  foreach (var hook in HookKillWall) {
192  hook(i, j, type, ref fail);
193  }
194  }
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 h...
Definition: ModWall.cs:165
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static DelegateKillWall[] HookKillWall
Definition: WallLoader.cs:28
static void Terraria.ModLoader.WallLoader.ModifyLight ( int  i,
int  j,
int  type,
ref float  r,
ref float  g,
ref float  b 
)
static

Definition at line 206 of file WallLoader.cs.

206  {
207  GetWall(type)?.ModifyLight(i, j, ref r, ref g, ref b);
208 
209  foreach (var hook in HookModifyLight) {
210  hook(i, j, type, ref r, ref g, ref b);
211  }
212  }
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 f...
Definition: ModWall.cs:185
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static DelegateModifyLight[] HookModifyLight
Definition: WallLoader.cs:31
static void Terraria.ModLoader.WallLoader.NumDust ( int  i,
int  j,
int  type,
bool  fail,
ref int  numDust 
)
static

Definition at line 159 of file WallLoader.cs.

159  {
160  GetWall(type)?.NumDust(i, j, fail, ref numDust);
161 
162  foreach (var hook in HookNumDust) {
163  hook(i, j, type, fail, ref numDust);
164  }
165  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static DelegateNumDust[] HookNumDust
Definition: WallLoader.cs:22
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 hi...
Definition: ModWall.cs:143
static void Terraria.ModLoader.WallLoader.PlaceInWorld ( int  i,
int  j,
Item  item 
)
static

Definition at line 253 of file WallLoader.cs.

253  {
254  int type = item.createWall;
255  if (type < 0)
256  return;
257 
258  foreach (var hook in HookPlaceInWorld) {
259  hook(i, j, type, item);
260  }
261 
262  GetWall(type)?.PlaceInWorld(i, j, item);
263  }
virtual void PlaceInWorld(int i, int j, Item item)
Called after this wall is placed in the world by way of the item provided.
Definition: ModWall.cs:216
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static Action< int, int, int, Item >[] HookPlaceInWorld
Definition: WallLoader.cs:35
static void Terraria.ModLoader.WallLoader.PostDraw ( int  i,
int  j,
int  type,
SpriteBatch  spriteBatch 
)
static

Definition at line 245 of file WallLoader.cs.

245  {
246  GetWall(type)?.PostDraw(i, j, spriteBatch);
247 
248  foreach (var hook in HookPostDraw) {
249  hook(i, j, type, spriteBatch);
250  }
251  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
static Action< int, int, int, SpriteBatch >[] HookPostDraw
Definition: WallLoader.cs:34
virtual void PostDraw(int i, int j, SpriteBatch spriteBatch)
Allows you to draw things in front of the wall at the given coordinates.
Definition: ModWall.cs:210
static bool Terraria.ModLoader.WallLoader.PreDraw ( int  i,
int  j,
int  type,
SpriteBatch  spriteBatch 
)
static

Definition at line 235 of file WallLoader.cs.

235  {
236  foreach (var hook in HookPreDraw) {
237  if (!hook(i, j, type, spriteBatch)) {
238  return false;
239  }
240  }
241  return GetWall(type)?.PreDraw(i, j, spriteBatch) ?? true;
242  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
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 fro...
Definition: ModWall.cs:203
static Func< int, int, int, SpriteBatch, bool >[] HookPreDraw
Definition: WallLoader.cs:33
static void Terraria.ModLoader.WallLoader.RandomUpdate ( int  i,
int  j,
int  type 
)
static

Definition at line 216 of file WallLoader.cs.

216  {
217  GetWall(type)?.RandomUpdate(i, j);
218 
219  foreach (var hook in HookRandomUpdate) {
220  hook(i, j, type);
221  }
222  }
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists, returns null.
Definition: WallLoader.cs:50
virtual void RandomUpdate(int i, int j)
Called whenever the world randomly decides to update the tile containing this wall in a given tick...
Definition: ModWall.cs:191
static Action< int, int, int >[] HookRandomUpdate
Definition: WallLoader.cs:32
static void Terraria.ModLoader.WallLoader.Resize2DArray< T > ( ref T  array[,],
int  newSize 
)
staticprivate

Definition at line 54 of file WallLoader.cs.

54  {
55  int dim1 = array.GetLength(0);
56  int dim2 = array.GetLength(1);
57  T[,] newArray = new T[newSize, dim2];
58  for (int j = 0; j < newSize && j < dim1; j++) {
59  for (int k = 0; k < dim2; k++) {
60  newArray[j, k] = array[j, k];
61  }
62  }
63  array = newArray;
64  }

Member Data Documentation

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

Definition at line 29 of file WallLoader.cs.

DelegateCreateDust [] Terraria.ModLoader.WallLoader.HookCreateDust
staticprivate

Definition at line 24 of file WallLoader.cs.

DelegateDrop [] Terraria.ModLoader.WallLoader.HookDrop
staticprivate

Definition at line 26 of file WallLoader.cs.

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

Definition at line 20 of file WallLoader.cs.

DelegateKillWall [] Terraria.ModLoader.WallLoader.HookKillWall
staticprivate

Definition at line 28 of file WallLoader.cs.

DelegateModifyLight [] Terraria.ModLoader.WallLoader.HookModifyLight
staticprivate

Definition at line 31 of file WallLoader.cs.

DelegateNumDust [] Terraria.ModLoader.WallLoader.HookNumDust
staticprivate

Definition at line 22 of file WallLoader.cs.

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

Definition at line 35 of file WallLoader.cs.

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

Definition at line 34 of file WallLoader.cs.

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

Definition at line 33 of file WallLoader.cs.

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

Definition at line 32 of file WallLoader.cs.

bool Terraria.ModLoader.WallLoader.loaded = false
staticprivate

Definition at line 18 of file WallLoader.cs.

int Terraria.ModLoader.WallLoader.nextWall = WallID.Count
staticprivate

Definition at line 15 of file WallLoader.cs.

int Terraria.ModLoader.WallLoader.WallCount => nextWall
static

Definition at line 45 of file WallLoader.cs.