public static bool SpreadDirt(int x, int y) { if ((double)Vector2.Distance(DelegateMethods.v2_1, new Vector2((float)x, (float)y)) > (double)DelegateMethods.f_1 || !WorldGen.PlaceTile(x, y, 0, false, false, -1, 0)) { return(false); } if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, (NetworkText)null, 1, (float)x, (float)y, 0.0f, 0, 0, 0); } Vector2 Position = new Vector2((float)(x * 16), (float)(y * 16)); int Type = 0; for (int index = 0; index < 3; ++index) { Dust dust1 = Dust.NewDustDirect(Position, 16, 16, Type, 0.0f, 0.0f, 100, Color.Transparent, 2.2f); dust1.noGravity = true; dust1.velocity.Y -= 1.2f; dust1.velocity *= 4f; Dust dust2 = Dust.NewDustDirect(Position, 16, 16, Type, 0.0f, 0.0f, 100, Color.Transparent, 1.3f); dust2.velocity.Y -= 1.2f; dust2.velocity *= 2f; } int i = x; int j1 = y + 1; if (Main.tile[i, j1] != null && !TileID.Sets.Platforms[(int)Main.tile[i, j1].type] && (Main.tile[i, j1].topSlope() || Main.tile[i, j1].halfBrick())) { WorldGen.SlopeTile(i, j1, 0, false); if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, (NetworkText)null, 14, (float)i, (float)j1, 0.0f, 0, 0, 0); } } int j2 = y - 1; if (Main.tile[i, j2] != null && !TileID.Sets.Platforms[(int)Main.tile[i, j2].type] && Main.tile[i, j2].bottomSlope()) { WorldGen.SlopeTile(i, j2, 0, false); if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, (NetworkText)null, 14, (float)i, (float)j2, 0.0f, 0, 0, 0); } } return(true); }
public static bool SpreadDirt(int x, int y) { if (Vector2.Distance(v2_1, new Vector2(x, y)) > f_1) { return(false); } if (WorldGen.PlaceTile(x, y, 0)) { if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 1, x, y); } Vector2 position = new Vector2(x * 16, y * 16); int type = 0; for (int i = 0; i < 3; i++) { Dust dust = Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 2.2f); dust.noGravity = true; dust.velocity.Y -= 1.2f; dust.velocity *= 4f; Dust dust2 = Dust.NewDustDirect(position, 16, 16, type, 0f, 0f, 100, Color.Transparent, 1.3f); dust2.velocity.Y -= 1.2f; dust2.velocity *= 2f; } int num = y + 1; if (Main.tile[x, num] != null && !TileID.Sets.Platforms[Main.tile[x, num].type] && (Main.tile[x, num].topSlope() || Main.tile[x, num].halfBrick())) { WorldGen.SlopeTile(x, num); if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 14, x, num); } } num = y - 1; if (Main.tile[x, num] != null && !TileID.Sets.Platforms[Main.tile[x, num].type] && Main.tile[x, num].bottomSlope()) { WorldGen.SlopeTile(x, num); if (Main.netMode != 0) { NetMessage.SendData(17, -1, -1, null, 14, x, num); } } return(true); } return(false); }
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 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 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; }