public void Add( 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 = oldTiles.Length - 1; i >= 0; --i )
{
ItemData data = TileData.ItemTable[itemID & TileData.MaxItemValue];
if ( oldTiles[i].Z == z && (oldTiles[i].Height > 0 == data.Height > 0 ) )
{
bool newIsRoof = ( data.Flags & TileFlag.Roof) != 0;
bool oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & TileData.MaxItemValue].Flags & TileFlag.Roof ) != 0;
if ( newIsRoof == oldIsRoof )
Remove( oldTiles[i].ID, x, y, z );
}
}
oldTiles = m_Tiles[vx][vy];
StaticTile[] newTiles = new StaticTile[oldTiles.Length + 1];
for ( int i = 0; i < oldTiles.Length; ++i )
newTiles[i] = oldTiles[i];
newTiles[oldTiles.Length] = new StaticTile( (ushort)itemID, (sbyte)z );
m_Tiles[vx][vy] = newTiles;
MultiTileEntry[] oldList = m_List;
MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1];
for ( int i = 0; i < oldList.Length; ++i )
newList[i] = oldList[i];
newList[oldList.Length] = new MultiTileEntry( (ushort)itemID, (short)x, (short)y, (short)z, 1 );
m_List = newList;
if ( x < m_Min.m_X )
m_Min.m_X = x;
if ( y < m_Min.m_Y )
m_Min.m_Y = y;
if ( x > m_Max.m_X )
m_Max.m_X = x;
if ( y > m_Max.m_Y )
m_Max.m_Y = y;
}
}