public static bool DeleteStairs( MultiComponentList mcl, int id, int x, int y, int z ) { int ax = x + mcl.Center.X; int ay = y + mcl.Center.Y; if ( ax < 0 || ay < 0 || ax >= mcl.Width || ay >= (mcl.Height - 1) || z < 7 || ((z - 7) % 5) != 0 ) return false; if ( IsStairBlock( id ) ) { Tile[] tiles = mcl.Tiles[ax][ay]; for ( int i = 0; i < tiles.Length; ++i ) { Tile tile = tiles[i]; if ( tile.Z == (z + 5) ) { id = tile.ID; z = tile.Z; if ( !IsStairBlock( id ) ) break; } } } int dir = 0; if ( !IsStair( id, ref dir ) ) return false; int height = ((z - 7) % 20) / 5; int xStart, yStart; int xInc, yInc; switch ( dir ) { default: case 0: // North { xStart = x; yStart = y + height; xInc = 0; yInc = -1; break; } case 1: // West { xStart = x + height; yStart = y; xInc = -1; yInc = 0; break; } case 2: // South { xStart = x; yStart = y - height; xInc = 0; yInc = 1; break; } case 3: // East { xStart = x - height; yStart = y; xInc = 1; yInc = 0; break; } } int zStart = z - (height * 5); for ( int i = 0; i < 4; ++i ) { x = xStart + (i * xInc); y = yStart + (i * yInc); for ( int j = 0; j <= i; ++j ) mcl.RemoveXYZH( x, y, zStart + (j * 5), 5 ); ax = x + mcl.Center.X; ay = y + mcl.Center.Y; if ( ax >= 1 && ax < mcl.Width && ay >= 1 && ay < mcl.Height - 1 ) { Tile[] tiles = mcl.Tiles[ax][ay]; bool hasBaseFloor = false; for ( int j = 0; !hasBaseFloor && j < tiles.Length; ++j ) hasBaseFloor = ( tiles[j].Z == 7 && (tiles[j].ID & 0x3FFF) != 1 ); if ( !hasBaseFloor ) mcl.Add( 0x31F4, x, y, 7 ); } } return true; }