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); } } }