public static void DecompressTileBlock_Inner(BinaryReader reader, int xStart, int yStart, int width, int height)
{
Tile tile = (Tile)null;
int num1 = 0;
for (int index1 = yStart; index1 < yStart + height; ++index1)
{
for (int index2 = xStart; index2 < xStart + width; ++index2)
{
if (num1 != 0)
{
--num1;
if (Main.tile[index2, index1] == null)
Main.tile[index2, index1] = new Tile(tile);
else
Main.tile[index2, index1].CopyFrom(tile);
}
else
{
byte num2;
byte num3 = num2 = (byte)0;
tile = Main.tile[index2, index1];
if (tile == null)
{
tile = new Tile();
Main.tile[index2, index1] = tile;
}
else
tile.ClearEverything();
byte num4 = reader.ReadByte();
if (((int)num4 & 1) == 1)
{
num3 = reader.ReadByte();
if (((int)num3 & 1) == 1)
num2 = reader.ReadByte();
}
bool flag = tile.active();
if (((int)num4 & 2) == 2)
{
tile.active(true);
ushort num5 = tile.type;
int index3;
if (((int)num4 & 32) == 32)
{
byte num6 = reader.ReadByte();
index3 = (int)reader.ReadByte() << 8 | (int)num6;
}
else
index3 = (int)reader.ReadByte();
tile.type = (ushort)index3;
if (Main.tileFrameImportant[index3])
{
tile.frameX = reader.ReadInt16();
tile.frameY = reader.ReadInt16();
}
else if (!flag || (int)tile.type != (int)num5)
{
tile.frameX = (short)-1;
tile.frameY = (short)-1;
}
if (((int)num2 & 8) == 8)
tile.color(reader.ReadByte());
}
if (((int)num4 & 4) == 4)
{
tile.wall = reader.ReadByte();
if (((int)num2 & 16) == 16)
tile.wallColor(reader.ReadByte());
}
byte num7 = (byte)(((int)num4 & 24) >> 3);
if ((int)num7 != 0)
{
tile.liquid = reader.ReadByte();
if ((int)num7 > 1)
{
if ((int)num7 == 2)
tile.lava(true);
else
tile.honey(true);
}
}
var wireFlag = k_WireFlags.WIRE_NONE;
if ((int)num3 > 1)
{
if (((int)num3 & 2) == 2)
wireFlag |= k_WireFlags.WIRE_RED;
if (((int)num3 & 4) == 4)
wireFlag |= k_WireFlags.WIRE_GREEN;
if (((int)num3 & 8) == 8)
wireFlag |= k_WireFlags.WIRE_BLUE;
byte num5 = (byte)(((int)num3 & 112) >> 4);
if ((int)num5 != 0 && Main.tileSolid[(int)tile.type])
{
if ((int)num5 == 1)
tile.halfBrick(true);
else
tile.slope((byte)((uint)num5 - 1U));
}
}
if ((int)num2 > 0)
{
if (((int)num2 & 2) == 2)
wireFlag |= k_WireFlags.WIRE_ACTUATOR;
if (((int)num2 & 4) == 4)
tile.inActive(true);
}
tile.k_wireFlags = wireFlag;
switch ((byte)(((int)num4 & 192) >> 6))
{
case (byte)0:
num1 = 0;
continue;
case (byte)1:
num1 = (int)reader.ReadByte();
continue;
default:
num1 = (int)reader.ReadInt16();
continue;
}
}
}
}
short num8 = reader.ReadInt16();
for (int index = 0; index < (int)num8; ++index)
{
short num2 = reader.ReadInt16();
short num3 = reader.ReadInt16();
short num4 = reader.ReadInt16();
string str = reader.ReadString();
if ((int)num2 >= 0 && (int)num2 < 1000)
{
if (Main.chest[(int)num2] == null)
Main.chest[(int)num2] = new Chest(false);
Main.chest[(int)num2].name = str;
Main.chest[(int)num2].x = (int)num3;
Main.chest[(int)num2].y = (int)num4;
}
}
short num9 = reader.ReadInt16();
for (int index = 0; index < (int)num9; ++index)
{
short num2 = reader.ReadInt16();
short num3 = reader.ReadInt16();
short num4 = reader.ReadInt16();
string str = reader.ReadString();
if ((int)num2 >= 0 && (int)num2 < 1000)
{
if (Main.sign[(int)num2] == null)
Main.sign[(int)num2] = new Sign();
Main.sign[(int)num2].text = str;
Main.sign[(int)num2].x = (int)num3;
Main.sign[(int)num2].y = (int)num4;
}
}
short num10 = reader.ReadInt16();
for (int index = 0; index < (int)num10; ++index)
{
TileEntity tileEntity = TileEntity.Read(reader);
TileEntity.ByID[tileEntity.ID] = tileEntity;
TileEntity.ByPosition[tileEntity.Position] = tileEntity;
}
}