Terraria ModLoader  0.11.7.5
A mod to make and play Terraria mods
ModWall.cs
Go to the documentation of this file.
1 using Microsoft.Xna.Framework;
2 using Microsoft.Xna.Framework.Graphics;
3 using System;
4 using System.Collections.Generic;
5 using Terraria.Localization;
6 
7 namespace Terraria.ModLoader
8 {
12  public class ModWall
13  {
17  public Mod mod {
18  get;
19  internal set;
20  }
21 
25  public string Name {
26  get;
27  internal set;
28  }
29 
33  public ushort Type {
34  get;
35  internal set;
36  }
37 
38  internal string texture;
42  public int soundType = 0;
46  public int soundStyle = 1;
50  public int dustType = 0;
54  public int drop = 0;
55 
59  public void AddMapEntry(Color color, LocalizedText name = null) {
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  }
68 
74  public ModTranslation CreateMapEntryName(string key = null) {
75  if (string.IsNullOrEmpty(key)) {
76  key = Name;
77  }
78  return mod.GetOrCreateTranslation(string.Format("Mods.{0}.MapObject.{1}", mod.Name, key));
79  }
80 
84  public void AddMapEntry(Color color, ModTranslation name) {
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  }
93 
97  public void AddMapEntry(Color color, LocalizedText name, Func<string, int, int, string> nameFunc) {
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  }
106 
110  public void AddMapEntry(Color color, ModTranslation name, Func<string, int, int, string> nameFunc) {
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  }
119 
123  public virtual bool Autoload(ref string name, ref string texture) {
124  return mod.Properties.Autoload;
125  }
126 
130  public virtual void SetDefaults() {
131  }
132 
136  public virtual bool KillSound(int i, int j) {
137  return true;
138  }
139 
143  public virtual void NumDust(int i, int j, bool fail, ref int num) {
144  }
145 
149  public virtual bool CreateDust(int i, int j, ref int type) {
150  type = dustType;
151  return true;
152  }
153 
157  public virtual bool Drop(int i, int j, ref int type) {
158  type = drop;
159  return true;
160  }
161 
165  public virtual void KillWall(int i, int j, ref bool fail) {
166  }
167 
171  public virtual bool CanExplode(int i, int j) {
172  return true;
173  }
174 
178  public virtual ushort GetMapOption(int i, int j) {
179  return 0;
180  }
181 
185  public virtual void ModifyLight(int i, int j, ref float r, ref float g, ref float b) {
186  }
187 
191  public virtual void RandomUpdate(int i, int j) {
192  }
193 
197  public virtual void AnimateWall(ref byte frame, ref byte frameCounter) {
198  }
199 
203  public virtual bool PreDraw(int i, int j, SpriteBatch spriteBatch) {
204  return true;
205  }
206 
210  public virtual void PostDraw(int i, int j, SpriteBatch spriteBatch) {
211  }
212 
216  public virtual void PlaceInWorld(int i, int j, Item item) {
217  }
218  }
219 }
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
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
ModTranslation CreateMapEntryName(string key=null)
Creates a ModTranslation object that you can use in AddMapEntry.
Definition: ModWall.cs:74
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
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 call...
Definition: ModWall.cs:59
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
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
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...
Definition: ModWall.cs:136
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
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&#39;s autoload property.
Definition: ModWall.cs:123
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
This class represents a type of wall that can be added by a mod. Only one instance of this class will...
Definition: ModWall.cs:12
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
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.
Definition: ModWall.cs:110
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.
Definition: ModWall.cs:178
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
Mod is an abstract class that you will override. It serves as a central place from which the mod&#39;s co...
Definition: Mod.cs:24
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 call...
Definition: ModWall.cs:84
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.
Definition: ModWall.cs:97
virtual void SetDefaults()
Allows you to set the properties of this wall. Many properties are stored as arrays throughout Terrar...
Definition: ModWall.cs:130
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 bee...
Definition: ModWall.cs:197
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