Server.MultiComponentList.RemoveXYZH C# (CSharp) Méthode

RemoveXYZH() public méthode

public RemoveXYZH ( int x, int y, int z, int minHeight ) : void
x int
y int
z int
minHeight int
Résultat void
		public void RemoveXYZH( int x, int y, int z, int minHeight )
		{
			int vx = x + m_Center.m_X;
			int vy = y + m_Center.m_Y;

			if ( vx >= 0 && vx < m_Width && vy >= 0 && vy < m_Height )
			{
				StaticTile[] oldTiles = m_Tiles[vx][vy];

				for ( int i = 0; i < oldTiles.Length; ++i )
				{
					StaticTile tile = oldTiles[i];

					if ( tile.Z == z && tile.Height >= minHeight )
					{
						StaticTile[] newTiles = new StaticTile[oldTiles.Length - 1];

						for ( int j = 0; j < i; ++j )
							newTiles[j] = oldTiles[j];

						for ( int j = i + 1; j < oldTiles.Length; ++j )
							newTiles[j - 1] = oldTiles[j];

						m_Tiles[vx][vy] = newTiles;

						break;
					}
				}

				MultiTileEntry[] oldList = m_List;

				for ( int i = 0; i < oldList.Length; ++i )
				{
					MultiTileEntry tile = oldList[i];

					if ( tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z && TileData.ItemTable[tile.m_ItemID & TileData.MaxItemValue].Height >= minHeight )
					{
						MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1];

						for ( int j = 0; j < i; ++j )
							newList[j] = oldList[j];

						for ( int j = i + 1; j < oldList.Length; ++j )
							newList[j - 1] = oldList[j];

						m_List = newList;

						break;
					}
				}
			}
		}

Usage Example

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