tModLoader v0.11.8.9
A mod to make and play Terraria mods
ModWall.cs
Go to the documentation of this file.
1using Microsoft.Xna.Framework;
2using Microsoft.Xna.Framework.Graphics;
3using System;
4using System.Collections.Generic;
5using Terraria.Localization;
6
7namespace 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}
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
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
This class represents a type of wall that can be added by a mod. Only one instance of this class will...
Definition: ModWall.cs:13
ModTranslation CreateMapEntryName(string key=null)
Creates a ModTranslation object that you can use in AddMapEntry.
Definition: ModWall.cs:74
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
int dustType
The default type of dust made when this wall is hit. Defaults to 0.
Definition: ModWall.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
virtual bool CanExplode(int i, int j)
Whether or not the wall at the given coordinates can be killed by an explosion (ie....
Definition: ModWall.cs:171
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,...
Definition: ModWall.cs:110
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 ushort GetMapOption(int i, int j)
Allows you to choose which minimap entry the wall at the given coordinates will use....
Definition: ModWall.cs:178
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
int drop
The default type of item dropped when this wall is killed. Defaults to 0, which means no item.
Definition: ModWall.cs:54
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 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 SetDefaults()
Allows you to set the properties of this wall. Many properties are stored as arrays throughout Terrar...
Definition: ModWall.cs:130
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
int soundType
The default type of sound made when this wall is hit. Defaults to 0.
Definition: ModWall.cs:42
string Name
The name of this type of wall.
Definition: ModWall.cs:25
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 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
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
ushort Type
The internal ID of this type of wall.
Definition: ModWall.cs:33
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....
Definition: ModWall.cs:123
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,...
Definition: ModWall.cs:97
int soundStyle
The default style of sound made when this wall is hit. Defaults to 1.
Definition: ModWall.cs:46
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
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
Mod mod
The mod which has added this type of ModWall.
Definition: ModWall.cs:17
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
bool Autoload
Whether or not this mod will autoload content by default. Autoloading content means you do not need t...