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

Remove() public méthode

public Remove ( int itemID, int x, int y, int z ) : void
itemID int
x int
y int
z int
Résultat void
		public void Remove( int itemID, int x, int y, int z )
		{
			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.ID == itemID && tile.Z == z )
					{
						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_ItemID == itemID && tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z )
					{
						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 override void SetInitialState()
        {
            m_Current = new DesignState(this, GetEmptyFoundation());

            // explicitly unused in StaticHousing
			m_Design = null;
			m_Backup = null;
            
            //init the other two design states just so they don't crash the base's serilization      
            MultiComponentList y = new MultiComponentList(m_Current.Components);
            MultiComponentList x = new MultiComponentList(StaticHouseHelper.GetComponents(m_HouseBlueprintID));
            
            //merge x into y.
            //first, remove all in y
            for (int i = y.List.Length - 1; i >= 0; i--)
            {
                y.Remove(y.List[i].m_ItemID, y.List[i].m_OffsetX, y.List[i].m_OffsetY, y.List[i].m_OffsetZ);
            }

            //then add all the ones we want to the list
            for (int i = 0; i < x.List.Length; ++i)
            {
                y.Add(x.List[i].m_ItemID, x.List[i].m_OffsetX, x.List[i].m_OffsetY, x.List[i].m_OffsetZ,true);
            }

            m_Current.Components = y;

			return;
        }