public void ScatterTiles(int tileX, int tileY, int radius, int scatterRadius) { int toX, toY, style = 0; Tile froTile; for (int i = tileX - radius; i <= tileX + radius; i++) { for (int j = tileY - radius; j <= tileY + radius; j++) { float xDist = i - tileX; float yDist = j - tileY; if ((xDist * xDist) + (yDist * yDist) > (radius * radius)) { continue; } // Crude froTile = Main.tile[i, j]; if (froTile == null) { continue; } if (!TileHelpers.IsSolid(froTile, true, true)) { continue; } if (TileHelpers.IsWire(froTile)) { continue; } if (froTile.lava()) { continue; } if (TileHelpers.IsNotVanillaBombable(i, j)) { continue; } var tileData = TileObjectData.GetTileData(froTile); if (tileData != null && (tileData.Width > 1 || tileData.Height > 1)) { continue; } if (!TileFinderHelpers.FindNearbyRandomMatch(TilePattern.NonSolid, tileX, tileY, scatterRadius, 100, false, out toX, out toY)) { break; } try { style = TileObjectData.GetTileStyle(froTile); } catch (Exception) { style = 0; } int oldType = froTile.type; WorldGen.KillTile(i, j, false, false, true); WorldGen.PlaceTile(toX, toY, oldType, true, true, this.projectile.owner, style); if (Main.netMode != 0) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)toX, (float)toY, 0f, 0, 0, 0); } Dust.NewDust(new Vector2(i * 16, j * 16), 0, 0, 15, 0, 0, 150, Color.Cyan, 1f); Dust.NewDust(new Vector2(toX * 16, toY * 16), 0, 0, 15, 0, 0, 150, Color.Cyan, 1f); } } }
public void ScatterTiles(int tile_x, int tile_y, int radius, int scatter_radius) { int to_x, to_y, style = 0; Tile fro_tile; for (int i = tile_x - radius; i <= tile_x + radius; i++) { for (int j = tile_y - radius; j <= tile_y + radius; j++) { float x_dist = i - tile_x; float y_dist = j - tile_y; if (Math.Sqrt((x_dist * x_dist) + (y_dist * y_dist)) > radius) { continue; } // Crude fro_tile = Main.tile[i, j]; if (fro_tile == null) { continue; } if (!TileHelpers.IsSolid(fro_tile, true, true)) { continue; } if (TileHelpers.IsWire(fro_tile)) { continue; } if (fro_tile.lava()) { continue; } if (TileHelpers.IsNotBombable(i, j)) { continue; } var tile_data = TileObjectData.GetTileData(fro_tile); if (tile_data != null && (tile_data.Width > 1 || tile_data.Height > 1)) { continue; } if (!TileFinderHelpers.FindNearbyRandomAirTile(tile_x, tile_y, scatter_radius, out to_x, out to_y)) { break; } try { style = TileObjectData.GetTileStyle(fro_tile); } catch (Exception _) { style = 0; } int old_type = fro_tile.type; WorldGen.KillTile(i, j, false, false, true); WorldGen.PlaceTile(to_x, to_y, old_type, true, true, this.projectile.owner, style); if (Main.netMode != 0) { NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)i, (float)j, 0f, 0, 0, 0); NetMessage.SendData(MessageID.TileChange, -1, -1, null, 0, (float)to_x, (float)to_y, 0f, 0, 0, 0); } Dust.NewDust(new Vector2(i * 16, j * 16), 0, 0, 15, 0, 0, 150, Color.Cyan, 1f); Dust.NewDust(new Vector2(to_x * 16, to_y * 16), 0, 0, 15, 0, 0, 150, Color.Cyan, 1f); } } }