public static void NetAddWater(int x, int y) { if (((((x < (Main.maxTilesX - 5)) && (y < (Main.maxTilesY - 5))) && ((x >= 5) && (y >= 5))) && (Main.tile[x, y] != null)) && (Main.tile[x, y].liquid != 0)) { for (int i = 0; i < numLiquid; i++) { if ((Main.liquid[i].x == x) && (Main.liquid[i].y == y)) { Main.liquid[i].kill = 0; Main.tile[x, y].skipLiquid = true; return; } } if (numLiquid >= (maxLiquid - 1)) { LiquidBuffer.AddBuffer(x, y); } else { Main.tile[x, y].checkingLiquid = true; Main.tile[x, y].skipLiquid = true; Main.liquid[numLiquid].kill = 0; Main.liquid[numLiquid].x = x; Main.liquid[numLiquid].y = y; numLiquid++; int netMode = Main.netMode; if (Main.tile[x, y].active && (Main.tileWaterDeath[Main.tile[x, y].type] || (Main.tile[x, y].lava && Main.tileLavaDeath[Main.tile[x, y].type]))) { WorldGen.KillTile(x, y, false, false, false); if (Main.netMode == 2) { NetMessage.SendData(0x11, -1, -1, "", 0, (float)x, (float)y, 0f, 0); } } } } }
public static bool CutTiles(int x, int y) { if (!WorldGen.InWorld(x, y, 1)) { return(false); } if (Main.tile[x, y] == null) { return(false); } if (!Main.tileCut[Main.tile[x, y].type]) { return(true); } if (Main.tile[x, y + 1] != null && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380) { WorldGen.KillTile(x, y); if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, "", 0, x, y); } } return(true); }
// Token: 0x0600019D RID: 413 RVA: 0x0002E3DC File Offset: 0x0002C5DC public static bool CutTiles(int x, int y) { if (!WorldGen.InWorld(x, y, 1)) { return(false); } if (Main.tile[x, y] == null) { return(false); } if (!Main.tileCut[(int)Main.tile[x, y].type]) { return(true); } if (WorldGen.CanCutTile(x, y, DelegateMethods.tilecut_0)) { WorldGen.KillTile(x, y, false, false, false); if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, (float)x, (float)y, 0f, 0, 0, 0); } } return(true); }
public static bool CutTiles(int x, int y) { if (!WorldGen.InWorld(x, y, 1)) { return(false); } if (Main.tile[x, y] == null) { return(false); } if (!Main.tileCut[Main.tile[x, y].type]) { return(true); } if (Main.tile[x, y + 1] != null && Main.tile[x, y + 1].type != 78 && Main.tile[x, y + 1].type != 380) { WorldGen.KillTile(x, y, false, false, false); if (Main.netMode != 0) { NetMessage.SendData((int)PacketTypes.Tile, -1, -1, "", 0, (float)x, (float)y, 0f, 0, 0, 0); } } return(true); }
public static bool CutTiles(int x, int y) { if (!WorldGen.InWorld(x, y, 1)) { return(false); } if (Main.tile[x, y] == null) { return(false); } if (!Main.tileCut[Main.tile[x, y].type]) { return(true); } if (WorldGen.CanCutTile(x, y, tilecut_0)) { WorldGen.KillTile(x, y); if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 0, x, y); } } return(true); }
public static Microsoft.Xna.Framework.Vector2 HurtTiles(Microsoft.Xna.Framework.Vector2 Position, Microsoft.Xna.Framework.Vector2 Velocity, int Width, int Height, bool fireImmune = false) { Microsoft.Xna.Framework.Vector2 vector = Position; int num = (int)(Position.X / 16f) - 1; int num2 = (int)((Position.X + (float)Width) / 16f) + 2; int num3 = (int)(Position.Y / 16f) - 1; int num4 = (int)((Position.Y + (float)Height) / 16f) + 2; if (num < 0) { num = 0; } if (num2 > Main.maxTilesX) { num2 = Main.maxTilesX; } if (num3 < 0) { num3 = 0; } if (num4 > Main.maxTilesY) { num4 = Main.maxTilesY; } for (int i = num; i < num2; i++) { for (int j = num3; j < num4; j++) { if (Main.tile[i, j] != null && Main.tile[i, j].active && (Main.tile[i, j].type == 32 || Main.tile[i, j].type == 37 || Main.tile[i, j].type == 48 || Main.tile[i, j].type == 53 || Main.tile[i, j].type == 57 || Main.tile[i, j].type == 58 || Main.tile[i, j].type == 69 || Main.tile[i, j].type == 76 || Main.tile[i, j].type == 112 || Main.tile[i, j].type == 116 || Main.tile[i, j].type == 123)) { Microsoft.Xna.Framework.Vector2 vector2; vector2.X = (float)(i * 16); vector2.Y = (float)(j * 16); int num5 = 0; int type = (int)Main.tile[i, j].type; if (type == 32 || type == 69 || type == 80) { if (vector.X + (float)Width > vector2.X && vector.X < vector2.X + 16f && vector.Y + (float)Height > vector2.Y && (double)vector.Y < (double)vector2.Y + 16.01) { int num6 = 1; if (vector.X + (float)(Width / 2) < vector2.X + 8f) { num6 = -1; } num5 = 10; if (type == 69) { num5 = 17; } else { if (type == 80) { num5 = 6; } } if (type == 32 || type == 69) { WorldGen.KillTile(i, j, false, false, false); if (Main.netMode == 1 && !Main.tile[i, j].active && Main.netMode == 1) { NetMessage.SendData(17, -1, -1, "", 4, (float)i, (float)j, 0f, 0); } } return(new Microsoft.Xna.Framework.Vector2((float)num6, (float)num5)); } } else { if (type == 53 || type == 112 || type == 116 || type == 123) { if (vector.X + (float)Width - 2f >= vector2.X && vector.X + 2f <= vector2.X + 16f && vector.Y + (float)Height - 2f >= vector2.Y && vector.Y + 2f <= vector2.Y + 16f) { int num7 = 1; if (vector.X + (float)(Width / 2) < vector2.X + 8f) { num7 = -1; } num5 = 20; return(new Microsoft.Xna.Framework.Vector2((float)num7, (float)num5)); } } else { if (vector.X + (float)Width >= vector2.X && vector.X <= vector2.X + 16f && vector.Y + (float)Height >= vector2.Y && (double)vector.Y <= (double)vector2.Y + 16.01) { int num8 = 1; if (vector.X + (float)(Width / 2) < vector2.X + 8f) { num8 = -1; } if (!fireImmune && (type == 37 || type == 58 || type == 76)) { num5 = 20; } if (type == 48) { num5 = 40; } return(new Microsoft.Xna.Framework.Vector2((float)num8, (float)num5)); } } } } } } return(default(Microsoft.Xna.Framework.Vector2)); }
public static bool Place(TileObject toBePlaced) { TileObjectData tileData = TileObjectData.GetTileData(toBePlaced.type, toBePlaced.style, toBePlaced.alternate); if (tileData == null) { return(false); } if (tileData.HookPlaceOverride.hook != null) { int num1; int num2; if (tileData.HookPlaceOverride.processedCoordinates) { num1 = toBePlaced.xCoord; num2 = toBePlaced.yCoord; } else { num1 = toBePlaced.xCoord + (int)tileData.Origin.X; num2 = toBePlaced.yCoord + (int)tileData.Origin.Y; } if (tileData.HookPlaceOverride.hook(num1, num2, toBePlaced.type, toBePlaced.style, 1, toBePlaced.alternate) == tileData.HookPlaceOverride.badReturn) { return(false); } } else { ushort type = (ushort)toBePlaced.type; int placementStyle = tileData.CalculatePlacementStyle(toBePlaced.style, toBePlaced.alternate, toBePlaced.random); int num1 = 0; if (tileData.StyleWrapLimit > 0) { num1 = placementStyle / tileData.StyleWrapLimit * tileData.StyleLineSkip; placementStyle %= tileData.StyleWrapLimit; } int num2; int num3; if (tileData.StyleHorizontal) { num2 = tileData.CoordinateFullWidth * placementStyle; num3 = tileData.CoordinateFullHeight * num1; } else { num2 = tileData.CoordinateFullWidth * num1; num3 = tileData.CoordinateFullHeight * placementStyle; } int xCoord = toBePlaced.xCoord; int yCoord = toBePlaced.yCoord; for (int index1 = 0; index1 < tileData.Width; ++index1) { for (int index2 = 0; index2 < tileData.Height; ++index2) { Tile tileSafely = Framing.GetTileSafely(xCoord + index1, yCoord + index2); if (tileSafely.active() && tileSafely.type != (ushort)484 && (Main.tileCut[(int)tileSafely.type] || TileID.Sets.BreakableWhenPlacing[(int)tileSafely.type])) { WorldGen.KillTile(xCoord + index1, yCoord + index2, false, false, false); if (!Main.tile[xCoord + index1, yCoord + index2].active() && Main.netMode == 1) { NetMessage.SendData(17, -1, -1, (NetworkText)null, 0, (float)(yCoord + index1), (float)(yCoord + index2), 0.0f, 0, 0, 0); } } } } for (int index1 = 0; index1 < tileData.Width; ++index1) { int num4 = num2 + index1 * (tileData.CoordinateWidth + tileData.CoordinatePadding); int num5 = num3; for (int index2 = 0; index2 < tileData.Height; ++index2) { Tile tileSafely = Framing.GetTileSafely(xCoord + index1, yCoord + index2); if (!tileSafely.active()) { tileSafely.active(true); tileSafely.frameX = (short)num4; tileSafely.frameY = (short)num5; tileSafely.type = type; } num5 += tileData.CoordinateHeights[index2] + tileData.CoordinatePadding; } } } if (tileData.FlattenAnchors) { AnchorData anchorBottom = tileData.AnchorBottom; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num = toBePlaced.xCoord + anchorBottom.checkStart; int j = toBePlaced.yCoord + tileData.Height; for (int index = 0; index < anchorBottom.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(num + index, j); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(num + index, j, 0, false); } } } AnchorData anchorTop = tileData.AnchorTop; if (anchorTop.tileCount != 0 && (anchorTop.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num = toBePlaced.xCoord + anchorTop.checkStart; int j = toBePlaced.yCoord - 1; for (int index = 0; index < anchorTop.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(num + index, j); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(num + index, j, 0, false); } } } AnchorData anchorRight = tileData.AnchorRight; if (anchorRight.tileCount != 0 && (anchorRight.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int i = toBePlaced.xCoord + tileData.Width; int num = toBePlaced.yCoord + anchorRight.checkStart; for (int index = 0; index < anchorRight.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(i, num + index); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(i, num + index, 0, false); } } } AnchorData anchorLeft = tileData.AnchorLeft; if (anchorLeft.tileCount != 0 && (anchorLeft.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int i = toBePlaced.xCoord - 1; int num = toBePlaced.yCoord + anchorLeft.checkStart; for (int index = 0; index < anchorLeft.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(i, num + index); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(i, num + index, 0, false); } } } } return(true); }
public static void LavaCheck(int x, int y) { Tile tile = Main.tile[x - 1, y]; Tile tile2 = Main.tile[x + 1, y]; Tile tile3 = Main.tile[x, y - 1]; Tile tile4 = Main.tile[x, y + 1]; Tile tile5 = Main.tile[x, y]; if ((tile.liquid > 0 && !tile.lava()) || (tile2.liquid > 0 && !tile2.lava()) || (tile3.liquid > 0 && !tile3.lava())) { int num = 0; int type = 56; if (!tile.lava()) { num += tile.liquid; tile.liquid = 0; } if (!tile2.lava()) { num += tile2.liquid; tile2.liquid = 0; } if (!tile3.lava()) { num += tile3.liquid; tile3.liquid = 0; } if (tile.honey() || tile2.honey() || tile3.honey()) { type = 230; } if (num < 24) { return; } if (tile5.active() && Main.tileObsidianKill[tile5.type]) { WorldGen.KillTile(x, y); if (Main.netMode == 2) { NetMessage.SendData(17, -1, -1, "", 0, x, y); } } if (!tile5.active()) { tile5.liquid = 0; tile5.lava(false); WorldGen.PlaceTile(x, y, type, true, true); WorldGen.SquareTileFrame(x, y); if (Main.netMode == 2) { NetMessage.SendTileSquare(-1, x - 1, y - 1, 3); } } } else { if (tile4.liquid <= 0 || tile4.lava()) { return; } if (Main.tileCut[tile4.type]) { WorldGen.KillTile(x, y + 1); if (Main.netMode == 2) { NetMessage.SendData(17, -1, -1, "", 0, x, y + 1); } } else if (tile4.active() && Main.tileObsidianKill[tile4.type]) { WorldGen.KillTile(x, y + 1); if (Main.netMode == 2) { NetMessage.SendData(17, -1, -1, "", 0, x, y + 1); } } if (tile4.active()) { return; } if (tile5.liquid < 24) { tile5.liquid = 0; tile5.liquidType(0); if (Main.netMode == 2) { NetMessage.SendTileSquare(-1, x - 1, y, 3); } return; } int type2 = 56; if (tile4.honey()) { type2 = 230; } tile5.liquid = 0; tile5.lava(false); tile4.liquid = 0; WorldGen.PlaceTile(x, y + 1, type2, true, true); WorldGen.SquareTileFrame(x, y + 1); if (Main.netMode == 2) { NetMessage.SendTileSquare(-1, x - 1, y, 3); } } }
public static void HoneyCheck(int x, int y) { Tile tile = Main.tile[x - 1, y]; Tile tile2 = Main.tile[x + 1, y]; Tile tile3 = Main.tile[x, y - 1]; Tile tile4 = Main.tile[x, y + 1]; Tile tile5 = Main.tile[x, y]; if ((tile.liquid > 0 && tile.liquidType() == 0) || (tile2.liquid > 0 && tile2.liquidType() == 0) || (tile3.liquid > 0 && tile3.liquidType() == 0)) { int num = 0; if (tile.liquidType() == 0) { num += tile.liquid; tile.liquid = 0; } if (tile2.liquidType() == 0) { num += tile2.liquid; tile2.liquid = 0; } if (tile3.liquidType() == 0) { num += tile3.liquid; tile3.liquid = 0; } if (num < 32) { return; } if (tile5.active() && Main.tileObsidianKill[tile5.type]) { WorldGen.KillTile(x, y); if (Main.netMode == 2) { NetMessage.SendData(17, -1, -1, "", 0, x, y); } } if (!tile5.active()) { tile5.liquid = 0; tile5.liquidType(0); WorldGen.PlaceTile(x, y, 229, true, true); WorldGen.SquareTileFrame(x, y); if (Main.netMode == 2) { NetMessage.SendTileSquare(-1, x - 1, y - 1, 3); } } } else { if (tile4.liquid <= 0 || tile4.liquidType() != 0) { return; } if (Main.tileCut[tile4.type]) { WorldGen.KillTile(x, y + 1); if (Main.netMode == 2) { NetMessage.SendData(17, -1, -1, "", 0, x, y + 1); } } else if (tile4.active() && Main.tileObsidianKill[tile4.type]) { WorldGen.KillTile(x, y + 1); if (Main.netMode == 2) { NetMessage.SendData(17, -1, -1, "", 0, x, y + 1); } } if (tile4.active()) { return; } if (tile5.liquid < 32) { tile5.liquid = 0; tile5.liquidType(0); if (Main.netMode == 2) { NetMessage.SendTileSquare(-1, x - 1, y, 3); } return; } tile5.liquid = 0; tile5.liquidType(0); tile4.liquid = 0; tile4.liquidType(0); WorldGen.PlaceTile(x, y + 1, 229, true, true); WorldGen.SquareTileFrame(x, y + 1); if (Main.netMode == 2) { NetMessage.SendTileSquare(-1, x - 1, y, 3); } } }
public static bool Place(TileObject toBePlaced) { TileObjectData tileData = TileObjectData.GetTileData(toBePlaced.type, toBePlaced.style, toBePlaced.alternate); if (tileData == null) { return(false); } if (tileData.HookPlaceOverride.hook != null) { int arg; int arg2; if (tileData.HookPlaceOverride.processedCoordinates) { arg = toBePlaced.xCoord; arg2 = toBePlaced.yCoord; } else { arg = toBePlaced.xCoord + tileData.Origin.X; arg2 = toBePlaced.yCoord + tileData.Origin.Y; } if (tileData.HookPlaceOverride.hook(arg, arg2, toBePlaced.type, toBePlaced.style, 1, toBePlaced.alternate) == tileData.HookPlaceOverride.badReturn) { return(false); } } else { ushort num = (ushort)toBePlaced.type; int num2 = 0; int num3 = 0; int num4 = tileData.CalculatePlacementStyle(toBePlaced.style, toBePlaced.alternate, toBePlaced.random); int num5 = 0; if (tileData.StyleWrapLimit > 0) { num5 = num4 / tileData.StyleWrapLimit * tileData.StyleLineSkip; num4 %= tileData.StyleWrapLimit; } if (tileData.StyleHorizontal) { num2 = tileData.CoordinateFullWidth * num4; num3 = tileData.CoordinateFullHeight * num5; } else { num2 = tileData.CoordinateFullWidth * num5; num3 = tileData.CoordinateFullHeight * num4; } int num6 = toBePlaced.xCoord; int num7 = toBePlaced.yCoord; for (int i = 0; i < tileData.Width; i++) { for (int j = 0; j < tileData.Height; j++) { Tile tileSafely = Framing.GetTileSafely(num6 + i, num7 + j); if (tileSafely.active() && tileSafely.type != 484 && (Main.tileCut[tileSafely.type] || TileID.Sets.BreakableWhenPlacing[tileSafely.type])) { WorldGen.KillTile(num6 + i, num7 + j); if (!Main.tile[num6 + i, num7 + j].active() && Main.netMode == 1) { NetMessage.SendData(17, -1, -1, null, 0, num7 + i, num7 + j); } } } } for (int k = 0; k < tileData.Width; k++) { int num8 = num2 + k * (tileData.CoordinateWidth + tileData.CoordinatePadding); int num9 = num3; for (int l = 0; l < tileData.Height; l++) { Tile tileSafely2 = Framing.GetTileSafely(num6 + k, num7 + l); if (!tileSafely2.active()) { tileSafely2.active(active: true); tileSafely2.frameX = (short)num8; tileSafely2.frameY = (short)num9; tileSafely2.type = num; } num9 += tileData.CoordinateHeights[l] + tileData.CoordinatePadding; } } } if (tileData.FlattenAnchors) { AnchorData anchorBottom = tileData.AnchorBottom; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num10 = toBePlaced.xCoord + anchorBottom.checkStart; int j2 = toBePlaced.yCoord + tileData.Height; for (int m = 0; m < anchorBottom.tileCount; m++) { Tile tileSafely3 = Framing.GetTileSafely(num10 + m, j2); if (Main.tileSolid[tileSafely3.type] && !Main.tileSolidTop[tileSafely3.type] && tileSafely3.blockType() != 0) { WorldGen.SlopeTile(num10 + m, j2); } } } anchorBottom = tileData.AnchorTop; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num11 = toBePlaced.xCoord + anchorBottom.checkStart; int j3 = toBePlaced.yCoord - 1; for (int n = 0; n < anchorBottom.tileCount; n++) { Tile tileSafely4 = Framing.GetTileSafely(num11 + n, j3); if (Main.tileSolid[tileSafely4.type] && !Main.tileSolidTop[tileSafely4.type] && tileSafely4.blockType() != 0) { WorldGen.SlopeTile(num11 + n, j3); } } } anchorBottom = tileData.AnchorRight; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int i2 = toBePlaced.xCoord + tileData.Width; int num12 = toBePlaced.yCoord + anchorBottom.checkStart; for (int num13 = 0; num13 < anchorBottom.tileCount; num13++) { Tile tileSafely5 = Framing.GetTileSafely(i2, num12 + num13); if (Main.tileSolid[tileSafely5.type] && !Main.tileSolidTop[tileSafely5.type] && tileSafely5.blockType() != 0) { WorldGen.SlopeTile(i2, num12 + num13); } } } anchorBottom = tileData.AnchorLeft; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int i3 = toBePlaced.xCoord - 1; int num14 = toBePlaced.yCoord + anchorBottom.checkStart; for (int num15 = 0; num15 < anchorBottom.tileCount; num15++) { Tile tileSafely6 = Framing.GetTileSafely(i3, num14 + num15); if (Main.tileSolid[tileSafely6.type] && !Main.tileSolidTop[tileSafely6.type] && tileSafely6.blockType() != 0) { WorldGen.SlopeTile(i3, num14 + num15); } } } } return(true); }
public static bool Place(TileObject toBePlaced) { TileObjectData tileData = TileObjectData.GetTileData(toBePlaced.type, toBePlaced.style, toBePlaced.alternate); if (tileData == null) { return(false); } if (tileData.HookPlaceOverride.hook != null) { int num1; int num2; if (tileData.HookPlaceOverride.processedCoordinates) { num1 = toBePlaced.xCoord; num2 = toBePlaced.yCoord; } else { num1 = toBePlaced.xCoord + (int)tileData.Origin.X; num2 = toBePlaced.yCoord + (int)tileData.Origin.Y; } if (tileData.HookPlaceOverride.hook(num1, num2, toBePlaced.type, toBePlaced.style, 1) == tileData.HookPlaceOverride.badReturn) { return(false); } } else { ushort num1 = (ushort)toBePlaced.type; int num2 = tileData.CalculatePlacementStyle(toBePlaced.style, toBePlaced.alternate, toBePlaced.random); int num3 = 0; if (tileData.StyleWrapLimit > 0) { num3 = num2 / tileData.StyleWrapLimit; num2 %= tileData.StyleWrapLimit; } int num4; int num5; if (tileData.StyleHorizontal) { num4 = tileData.CoordinateFullWidth * num2; num5 = tileData.CoordinateFullHeight * num3; } else { num4 = tileData.CoordinateFullWidth * num3; num5 = tileData.CoordinateFullHeight * num2; } int num6 = toBePlaced.xCoord; int num7 = toBePlaced.yCoord; for (int index1 = 0; index1 < tileData.Width; ++index1) { for (int index2 = 0; index2 < tileData.Height; ++index2) { Tile tileSafely = Framing.GetTileSafely(num6 + index1, num7 + index2); if (tileSafely.active() && Main.tileCut[(int)tileSafely.type]) { WorldGen.KillTile(num6 + index1, num7 + index2, false, false, false); } } } for (int index1 = 0; index1 < tileData.Width; ++index1) { int num8 = num4 + index1 * (tileData.CoordinateWidth + tileData.CoordinatePadding); int num9 = num5; for (int index2 = 0; index2 < tileData.Height; ++index2) { Tile tileSafely = Framing.GetTileSafely(num6 + index1, num7 + index2); if (!tileSafely.active()) { tileSafely.active(true); tileSafely.frameX = (short)num8; tileSafely.frameY = (short)num9; tileSafely.type = num1; } num9 += tileData.CoordinateHeights[index2] + tileData.CoordinatePadding; } } } if (tileData.FlattenAnchors) { AnchorData anchorData = tileData.AnchorBottom; if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num = toBePlaced.xCoord + anchorData.checkStart; int j = toBePlaced.yCoord + tileData.Height; for (int index = 0; index < anchorData.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(num + index, j); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(num + index, j, 0); } } } anchorData = tileData.AnchorTop; if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num = toBePlaced.xCoord + anchorData.checkStart; int j = toBePlaced.yCoord - 1; for (int index = 0; index < anchorData.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(num + index, j); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(num + index, j, 0); } } } anchorData = tileData.AnchorRight; if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int i = toBePlaced.xCoord + tileData.Width; int num = toBePlaced.yCoord + anchorData.checkStart; for (int index = 0; index < anchorData.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(i, num + index); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(i, num + index, 0); } } } anchorData = tileData.AnchorLeft; if (anchorData.tileCount != 0 && (anchorData.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int i = toBePlaced.xCoord - 1; int num = toBePlaced.yCoord + anchorData.checkStart; for (int index = 0; index < anchorData.tileCount; ++index) { Tile tileSafely = Framing.GetTileSafely(i, num + index); if (Main.tileSolid[(int)tileSafely.type] && !Main.tileSolidTop[(int)tileSafely.type] && tileSafely.blockType() != 0) { WorldGen.SlopeTile(i, num + index, 0); } } } } return(true); }
public unsafe static int HurtTiles(ref Vector2 Position, ref Vector2 Velocity, int Width, int Height, bool fireImmune = false) { int num = ((int)Position.X >> 4) - 1; int num2 = ((int)Position.X + Width >> 4) + 1; int num3 = ((int)Position.Y >> 4) - 1; int num4 = ((int)Position.Y + Height >> 4) + 1; if (num < 0) { num = 0; } if (num2 > Main.maxTilesX) { num2 = Main.maxTilesX; } if (num3 < 0) { num3 = 0; } if (num4 > Main.maxTilesY) { num4 = Main.maxTilesY; } fixed(Tile *ptr = Main.tile) { for (int i = num; i < num2; i++) { Tile *ptr2 = ptr + (i * 1440 + num3); int num5 = num3; while (num5 < num4) { if (ptr2->active != 0) { int type = ptr2->type; if (type == 32 || type == 37 || type == 48 || type == 53 || type == 57 || type == 58 || type == 69 || type == 76 || type == 112 || type == 116 || type == 123) { double num6 = i << 4; double num7 = num5 << 4; int result = 0; switch (type) { case 32: case 69: case 80: if ((double)(Position.X + (float)Width) > num6 && (double)Position.X < num6 + 16.0 && (double)(Position.Y + (float)Height) > num7 && (double)Position.Y < num7 + 16.01) { result = 10; switch (type) { case 69: result = 17; break; case 80: result = 6; break; } if ((type == 32 || type == 69) && WorldGen.KillTile(i, num5)) { NetMessage.CreateMessage5(17, 4, i, num5, 0); NetMessage.SendMessage(); } return(result); } break; case 53: case 112: case 116: case 123: if ((double)(Position.X + (float)Width - 2f) >= num6 && (double)(Position.X + 2f) <= num6 + 16.0 && (double)(Position.Y + (float)Height - 2f) >= num7 && (double)(Position.Y + 2f) <= num7 + 16.0) { return(20); } break; default: if ((double)(Position.X + (float)Width) >= num6 && (double)Position.X <= num6 + 16.0 && (double)(Position.Y + (float)Height) >= num7 && (double)Position.Y <= num7 + 16.01) { if (type == 48) { result = 40; } else if (!fireImmune && (type == 37 || type == 58 || type == 76)) { result = 20; } return(result); } break; } } } num5++; ptr2++; } } } return(0); }
public static bool Place(TileObject toBePlaced) { int num; int num1; TileObjectData tileData = TileObjectData.GetTileData(toBePlaced.type, toBePlaced.style, toBePlaced.alternate); if (tileData == null) { return false; } if (tileData.HookPlaceOverride.hook == null) { ushort num2 = (ushort)toBePlaced.type; int coordinateFullWidth = 0; int coordinateFullHeight = 0; int styleWrapLimit = tileData.CalculatePlacementStyle(toBePlaced.style, toBePlaced.alternate, toBePlaced.random); int styleWrapLimit1 = 0; if (tileData.StyleWrapLimit > 0) { styleWrapLimit1 = styleWrapLimit / tileData.StyleWrapLimit; styleWrapLimit = styleWrapLimit % tileData.StyleWrapLimit; } if (!tileData.StyleHorizontal) { coordinateFullWidth = tileData.CoordinateFullWidth * styleWrapLimit1; coordinateFullHeight = tileData.CoordinateFullHeight * styleWrapLimit; } else { coordinateFullWidth = tileData.CoordinateFullWidth * styleWrapLimit; coordinateFullHeight = tileData.CoordinateFullHeight * styleWrapLimit1; } int num3 = toBePlaced.xCoord; int num4 = toBePlaced.yCoord; for (int i = 0; i < tileData.Width; i++) { for (int j = 0; j < tileData.Height; j++) { Tile tileSafely = Framing.GetTileSafely(num3 + i, num4 + j); if (tileSafely.active() && Main.tileCut[tileSafely.type]) { WorldGen.KillTile(num3 + i, num4 + j, false, false, false); } } } for (int k = 0; k < tileData.Width; k++) { int coordinateWidth = coordinateFullWidth + k * (tileData.CoordinateWidth + tileData.CoordinatePadding); int coordinateHeights = coordinateFullHeight; for (int l = 0; l < tileData.Height; l++) { Tile tile = Framing.GetTileSafely(num3 + k, num4 + l); if (!tile.active()) { tile.active(true); tile.frameX = (short)coordinateWidth; tile.frameY = (short)coordinateHeights; tile.type = num2; } coordinateHeights = coordinateHeights + tileData.CoordinateHeights[l] + tileData.CoordinatePadding; } } } else { if (!tileData.HookPlaceOverride.processedCoordinates) { num = toBePlaced.xCoord + tileData.Origin.X; num1 = toBePlaced.yCoord + tileData.Origin.Y; } else { num = toBePlaced.xCoord; num1 = toBePlaced.yCoord; } if (tileData.HookPlaceOverride.hook(num, num1, toBePlaced.type, toBePlaced.style, 1) == tileData.HookPlaceOverride.badReturn) { return false; } } if (tileData.FlattenAnchors) { AnchorData anchorBottom = tileData.AnchorBottom; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num5 = toBePlaced.xCoord + anchorBottom.checkStart; int num6 = toBePlaced.yCoord + tileData.Height; for (int m = 0; m < anchorBottom.tileCount; m++) { Tile tileSafely1 = Framing.GetTileSafely(num5 + m, num6); if (Main.tileSolid[tileSafely1.type] && !Main.tileSolidTop[tileSafely1.type] && tileSafely1.blockType() != 0) { WorldGen.SlopeTile(num5 + m, num6, 0); } } } anchorBottom = tileData.AnchorTop; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num7 = toBePlaced.xCoord + anchorBottom.checkStart; int num8 = toBePlaced.yCoord - 1; for (int n = 0; n < anchorBottom.tileCount; n++) { Tile tile1 = Framing.GetTileSafely(num7 + n, num8); if (Main.tileSolid[tile1.type] && !Main.tileSolidTop[tile1.type] && tile1.blockType() != 0) { WorldGen.SlopeTile(num7 + n, num8, 0); } } } anchorBottom = tileData.AnchorRight; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num9 = toBePlaced.xCoord + tileData.Width; int num10 = toBePlaced.yCoord + anchorBottom.checkStart; for (int o = 0; o < anchorBottom.tileCount; o++) { Tile tileSafely2 = Framing.GetTileSafely(num9, num10 + o); if (Main.tileSolid[tileSafely2.type] && !Main.tileSolidTop[tileSafely2.type] && tileSafely2.blockType() != 0) { WorldGen.SlopeTile(num9, num10 + o, 0); } } } anchorBottom = tileData.AnchorLeft; if (anchorBottom.tileCount != 0 && (anchorBottom.type & AnchorType.SolidTile) == AnchorType.SolidTile) { int num11 = toBePlaced.xCoord - 1; int num12 = toBePlaced.yCoord + anchorBottom.checkStart; for (int p = 0; p < anchorBottom.tileCount; p++) { Tile tile2 = Framing.GetTileSafely(num11, num12 + p); if (Main.tileSolid[tile2.type] && !Main.tileSolidTop[tile2.type] && tile2.blockType() != 0) { WorldGen.SlopeTile(num11, num12 + p, 0); } } } } return true; }
public static Vector2 HurtTiles(Vector2 Position, Vector2 Velocity, int Width, int Height, bool fireImmune = false) { Vector2 vector = Position; int num = (int)(Position.X / 16f) - 1; int num2 = (int)((Position.X + (float)Width) / 16f) + 2; int num3 = (int)(Position.Y / 16f) - 1; int num4 = (int)((Position.Y + (float)Height) / 16f) + 2; if (num < 0) { num = 0; } if (num2 > Main.maxTilesX) { num2 = Main.maxTilesX; } if (num3 < 0) { num3 = 0; } if (num4 > Main.maxTilesY) { num4 = Main.maxTilesY; } Vector2 vector2 = default(Vector2); for (int i = num; i < num2; i++) { for (int j = num3; j < num4; j++) { if (Main.tile[i, j] == null || !Main.tile[i, j].active || (Main.tile[i, j].type != 32 && Main.tile[i, j].type != 37 && Main.tile[i, j].type != 48 && Main.tile[i, j].type != 53 && Main.tile[i, j].type != 57 && Main.tile[i, j].type != 58 && Main.tile[i, j].type != 69 && Main.tile[i, j].type != 76 && Main.tile[i, j].type != 112 && Main.tile[i, j].type != 116 && Main.tile[i, j].type != 123)) { continue; } vector2.X = i * 16; vector2.Y = j * 16; int num5 = 0; int type = Main.tile[i, j].type; switch (type) { case 32: case 69: case 80: { if (!(vector.X + (float)Width > vector2.X) || !(vector.X < vector2.X + 16f) || !(vector.Y + (float)Height > vector2.Y) || !((double)vector.Y < (double)vector2.Y + 16.01)) { continue; } int num6 = 1; if (vector.X + (float)(Width / 2) < vector2.X + 8f) { num6 = -1; } num5 = 10; switch (type) { case 69: num5 = 17; break; case 80: num5 = 6; break; } if (type == 32 || type == 69) { WorldGen.KillTile(i, j); if (Main.netMode == 1 && !Main.tile[i, j].active && Main.netMode == 1) { NetMessage.SendData(17, -1, -1, "", 4, i, j); } } return(new Vector2(num6, num5)); } case 53: case 112: case 116: case 123: if (vector.X + (float)Width - 2f >= vector2.X && vector.X + 2f <= vector2.X + 16f && vector.Y + (float)Height - 2f >= vector2.Y && vector.Y + 2f <= vector2.Y + 16f) { int num7 = 1; if (vector.X + (float)(Width / 2) < vector2.X + 8f) { num7 = -1; } num5 = 20; return(new Vector2(num7, num5)); } continue; } if (vector.X + (float)Width >= vector2.X && vector.X <= vector2.X + 16f && vector.Y + (float)Height >= vector2.Y && (double)vector.Y <= (double)vector2.Y + 16.01) { int num8 = 1; if (vector.X + (float)(Width / 2) < vector2.X + 8f) { num8 = -1; } if (!fireImmune && (type == 37 || type == 58 || type == 76)) { num5 = 20; } if (type == 48) { num5 = 40; } return(new Vector2(num8, num5)); } } } return(default(Vector2)); }
public static Vector2 HurtTiles(Vector2 Position, Vector2 Velocity, int Width, int Height, bool fireImmune = false) { Vector2 vector2 = Position; int num = ((int)(Position.X / 16f)) - 1; int maxTilesX = ((int)((Position.X + Width) / 16f)) + 2; int num3 = ((int)(Position.Y / 16f)) - 1; int maxTilesY = ((int)((Position.Y + Height) / 16f)) + 2; if (num < 0) { num = 0; } if (maxTilesX > Main.maxTilesX) { maxTilesX = Main.maxTilesX; } if (num3 < 0) { num3 = 0; } if (maxTilesY > Main.maxTilesY) { maxTilesY = Main.maxTilesY; } for (int i = num; i < maxTilesX; i++) { for (int j = num3; j < maxTilesY; j++) { Vector2 vector; if (((Main.tile[i, j] == null) || !Main.tile[i, j].active) || ((((Main.tile[i, j].type != 0x20) && (Main.tile[i, j].type != 0x25)) && ((Main.tile[i, j].type != 0x30) && (Main.tile[i, j].type != 0x35))) && ((((Main.tile[i, j].type != 0x39) && (Main.tile[i, j].type != 0x3a)) && ((Main.tile[i, j].type != 0x45) && (Main.tile[i, j].type != 0x4c))) && (((Main.tile[i, j].type != 0x70) && (Main.tile[i, j].type != 0x74)) && (Main.tile[i, j].type != 0x7b))))) { continue; } vector.X = i * 0x10; vector.Y = j * 0x10; int num7 = 0; int type = Main.tile[i, j].type; if (((type == 0x20) || (type == 0x45)) || (type == 80)) { if ((((vector2.X + Width) <= vector.X) || (vector2.X >= (vector.X + 16f))) || (((vector2.Y + Height) <= vector.Y) || (vector2.Y >= (vector.Y + 16.01)))) { continue; } int num9 = 1; if ((vector2.X + (Width / 2)) < (vector.X + 8f)) { num9 = -1; } num7 = 10; switch (type) { case 0x45: num7 = 0x11; break; case 80: num7 = 6; break; } switch (type) { case 0x20: case 0x45: WorldGen.KillTile(i, j, false, false, false); if (((Main.netMode == 1) && !Main.tile[i, j].active) && (Main.netMode == 1)) { NetMessage.SendData(0x11, -1, -1, "", 4, (float)i, (float)j, 0f, 0); } break; } return(new Vector2((float)num9, (float)num7)); } if (((type == 0x35) || (type == 0x70)) || ((type == 0x74) || (type == 0x7b))) { if (((((vector2.X + Width) - 2f) >= vector.X) && ((vector2.X + 2f) <= (vector.X + 16f))) && ((((vector2.Y + Height) - 2f) >= vector.Y) && ((vector2.Y + 2f) <= (vector.Y + 16f)))) { int num10 = 1; if ((vector2.X + (Width / 2)) < (vector.X + 8f)) { num10 = -1; } num7 = 20; return(new Vector2((float)num10, (float)num7)); } } else if ((((vector2.X + Width) >= vector.X) && (vector2.X <= (vector.X + 16f))) && (((vector2.Y + Height) >= vector.Y) && (vector2.Y <= (vector.Y + 16.01)))) { int num11 = 1; if ((vector2.X + (Width / 2)) < (vector.X + 8f)) { num11 = -1; } if (!fireImmune && (((type == 0x25) || (type == 0x3a)) || (type == 0x4c))) { num7 = 20; } if (type == 0x30) { num7 = 40; } return(new Vector2((float)num11, (float)num7)); } } } return(new Vector2()); }