1using Microsoft.Xna.Framework.Graphics;
 
    3using System.Collections.Generic;
 
   16        internal static readonly IList<ModWall> walls = 
new List<ModWall>();
 
   17        internal static readonly IList<GlobalWall> globalWalls = 
new List<GlobalWall>();
 
   21        private delegate 
void DelegateNumDust(
int i, 
int j, 
int type, 
bool fail, ref 
int num);
 
   25        private delegate 
bool DelegateDrop(
int i, 
int j, 
int type, ref 
int dropType);
 
   30        private delegate 
void DelegateModifyLight(
int i, 
int j, 
int type, ref 
float r, ref 
float g, ref 
float b);
 
   33        private static Func<int, int, int, SpriteBatch, bool>[] 
HookPreDraw;
 
   37        internal static int ReserveWallID() {
 
   51            return type >= WallID.Count && type < 
WallCount ? walls[type - WallID.Count] : 
null;
 
   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];
 
   66        internal static void ResizeArrays(
bool unloading = 
false) {
 
   67            Array.Resize(ref Main.wallLoaded, 
nextWall);
 
   68            for (
int k = WallID.Count; k < 
nextWall; k++) {
 
   69                Main.wallLoaded[k] = 
true;
 
   71            Resize2DArray(ref Main.wallAltTexture, 
nextWall);
 
   72            Resize2DArray(ref Main.wallAltTextureInit, 
nextWall);
 
   73            Resize2DArray(ref Main.wallAltTextureDrawn, 
nextWall);
 
   74            Array.Resize(ref Main.wallTexture, 
nextWall);
 
   75            Array.Resize(ref Main.wallHouse, 
nextWall);
 
   76            Array.Resize(ref Main.wallDungeon, 
nextWall);
 
   77            Array.Resize(ref Main.wallLight, 
nextWall);
 
   78            Array.Resize(ref Main.wallBlend, 
nextWall);
 
   79            Array.Resize(ref Main.wallLargeFrames, 
nextWall);
 
   80            Array.Resize(ref Main.wallFrame, 
nextWall);
 
   81            Array.Resize(ref Main.wallFrameCounter, 
nextWall);
 
   82            Array.Resize(ref WallID.Sets.Conversion.Grass, 
nextWall);
 
   83            Array.Resize(ref WallID.Sets.Conversion.Stone, 
nextWall);
 
   84            Array.Resize(ref WallID.Sets.Conversion.Sandstone, 
nextWall);
 
   85            Array.Resize(ref WallID.Sets.Conversion.HardenedSand, 
nextWall);
 
   86            Array.Resize(ref WallID.Sets.Transparent, 
nextWall);
 
   87            Array.Resize(ref WallID.Sets.Corrupt, 
nextWall);
 
   88            Array.Resize(ref WallID.Sets.Crimson, 
nextWall);
 
   89            Array.Resize(ref WallID.Sets.Hallow, 
nextWall);
 
   91            ModLoader.BuildGlobalHook(ref 
HookKillSound, globalWalls, g => g.KillSound);
 
   92            ModLoader.BuildGlobalHook(ref 
HookNumDust, globalWalls, g => g.NumDust);
 
   93            ModLoader.BuildGlobalHook(ref 
HookCreateDust, globalWalls, g => g.CreateDust);
 
   94            ModLoader.BuildGlobalHook(ref 
HookDrop, globalWalls, g => g.Drop);
 
   95            ModLoader.BuildGlobalHook(ref 
HookKillWall, globalWalls, g => g.KillWall);
 
   96            ModLoader.BuildGlobalHook(ref 
HookCanExplode, globalWalls, g => g.CanExplode);
 
   97            ModLoader.BuildGlobalHook(ref 
HookModifyLight, globalWalls, g => g.ModifyLight);
 
   98            ModLoader.BuildGlobalHook(ref 
HookRandomUpdate, globalWalls, g => g.RandomUpdate);
 
   99            ModLoader.BuildGlobalHook(ref 
HookPreDraw, globalWalls, g => g.PreDraw);
 
  100            ModLoader.BuildGlobalHook(ref 
HookPostDraw, globalWalls, g => g.PostDraw);
 
  101            ModLoader.BuildGlobalHook(ref 
HookPlaceInWorld, globalWalls, g => g.PlaceInWorld);
 
  108        internal static void Unload() {
 
  119        internal static void WriteType(ushort wall, 
byte[] data, ref 
int index, ref 
byte flags) {
 
  121                data[index] = (byte)(wall >> 8);
 
  131        internal static void ReadType(ref ushort wall, 
BinaryReader reader, 
byte flags, IDictionary<int, int> wallTable) {
 
  132            if ((flags & 32) == 32) {
 
  133                wall |= (ushort)(reader.ReadByte() << 8);
 
  135            if (wallTable.ContainsKey(wall)) {
 
  136                wall = (ushort)wallTable[wall];
 
  143                if (!hook(i, j, type)) {
 
  148            if (modWall != 
null) {
 
  159        public static void NumDust(
int i, 
int j, 
int type, 
bool fail, ref 
int numDust) {
 
  163                hook(i, j, type, fail, ref numDust);
 
  168        public static bool CreateDust(
int i, 
int j, 
int type, ref 
int dustType) {
 
  170                if (!hook(i, j, type, ref dustType)) {
 
  178        public static bool Drop(
int i, 
int j, 
int type, ref 
int dropType) {
 
  180                if (!hook(i, j, type, ref dropType)) {
 
  184            return GetWall(type)?.
Drop(i, j, ref dropType) ?? 
true;
 
  188        public static void KillWall(
int i, 
int j, 
int type, ref 
bool fail) {
 
  192                hook(i, j, type, ref fail);
 
  198                if (!hook(i, j, type)) {
 
  206        public static void ModifyLight(
int i, 
int j, 
int type, ref 
float r, ref 
float g, ref 
float b) {
 
  210                hook(i, j, type, ref r, ref g, ref b);
 
  226                for (
int i = 0; i < walls.Count; i++) {
 
  228                    modWall.
AnimateWall(ref Main.wallFrame[modWall.
Type], ref Main.wallFrameCounter[modWall.
Type]);
 
  235        public static bool PreDraw(
int i, 
int j, 
int type, SpriteBatch spriteBatch) {
 
  237                if (!hook(i, j, type, spriteBatch)) {
 
  245        public static void PostDraw(
int i, 
int j, 
int type, SpriteBatch spriteBatch) {
 
  249                hook(i, j, type, spriteBatch);
 
  254            int type = item.createWall;
 
  259                hook(i, j, type, item);
 
static bool AllowVanillaClients
 
This class represents a type of wall that can be added by a mod. Only one instance of this class will...
 
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...
 
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...
 
virtual bool CanExplode(int i, int j)
Whether or not the wall at the given coordinates can be killed by an explosion (ie....
 
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...
 
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...
 
virtual void RandomUpdate(int i, int j)
Called whenever the world randomly decides to update the tile containing this wall in a given tick....
 
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...
 
int soundType
The default type of sound made when this wall is hit. Defaults to 0.
 
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....
 
virtual void PlaceInWorld(int i, int j, Item item)
Called after this wall is placed in the world by way of the item provided.
 
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....
 
ushort Type
The internal ID of this type of wall.
 
int soundStyle
The default style of sound made when this wall is hit. Defaults to 1.
 
virtual void PostDraw(int i, int j, SpriteBatch spriteBatch)
Allows you to draw things in front of the wall at the given coordinates.
 
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...
 
This serves as the central class from which wall-related functions are supported and carried out.
 
static DelegateDrop[] HookDrop
 
static bool PreDraw(int i, int j, int type, SpriteBatch spriteBatch)
 
static bool CreateDust(int i, int j, int type, ref int dustType)
 
delegate bool DelegateDrop(int i, int j, int type, ref int dropType)
 
static void AnimateWalls()
 
static void PlaceInWorld(int i, int j, Item item)
 
static Func< int, int, int, bool >[] HookCanExplode
 
static DelegateKillWall[] HookKillWall
 
static ModWall GetWall(int type)
Gets the ModWall instance with the given type. If no ModWall with the given type exists,...
 
static Func< int, int, int, SpriteBatch, bool >[] HookPreDraw
 
static void KillWall(int i, int j, int type, ref bool fail)
 
static DelegateModifyLight[] HookModifyLight
 
static Action< int, int, int, SpriteBatch >[] HookPostDraw
 
static void NumDust(int i, int j, int type, bool fail, ref int numDust)
 
static void PostDraw(int i, int j, int type, SpriteBatch spriteBatch)
 
static Action< int, int, int, Item >[] HookPlaceInWorld
 
delegate void DelegateNumDust(int i, int j, int type, bool fail, ref int num)
 
delegate void DelegateKillWall(int i, int j, int type, ref bool fail)
 
static Action< int, int, int >[] HookRandomUpdate
 
static void ModifyLight(int i, int j, int type, ref float r, ref float g, ref float b)
 
static DelegateNumDust[] HookNumDust
 
static bool Drop(int i, int j, int type, ref int dropType)
 
delegate bool DelegateCreateDust(int i, int j, int type, ref int dustType)
 
static void Resize2DArray< T >(ref T[,] array, int newSize)
 
static DelegateCreateDust[] HookCreateDust
 
static bool CanExplode(int i, int j, int type)
 
static bool KillSound(int i, int j, int type)
 
static void RandomUpdate(int i, int j, int type)
 
delegate void DelegateModifyLight(int i, int j, int type, ref float r, ref float g, ref float b)
 
static Func< int, int, int, bool >[] HookKillSound