private static bool CanFit( Map map, int x, int y, int z )
{
bool hasSurface = false;
LandTile lt = map.Tiles.GetLandTile( x, y );
int lowZ = 0, avgZ = 0, topZ = 0;
map.GetAverageZ( x, y, ref lowZ, ref avgZ, ref topZ );
TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;
if ( (landFlags & TileFlag.Impassable) != 0 && topZ > z && (z + 16) > lowZ )
return false;
else if ( (landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored )
hasSurface = true;
StaticTile[] staticTiles = map.Tiles.GetStaticTiles( x, y );
bool surface, impassable;
for ( int i = 0; i < staticTiles.Length; ++i )
{
if ( IsDisplayCase( staticTiles[i].ID ) )
continue;
ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];
surface = id.Surface;
impassable = id.Impassable;
if ( (surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + 16) > staticTiles[i].Z )
return false;
else if ( surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight) )
hasSurface = true;
}
Sector sector = map.GetSector( x, y );
List<Item> items = sector.Items;
for ( int i = 0; i < items.Count; ++i )
{
Item item = items[i];
if ( item.AtWorldPoint( x, y ) )
{
ItemData id = item.ItemData;
surface = id.Surface;
impassable = id.Impassable;
if ( (surface || impassable) && (item.Z + id.CalcHeight) > z && (z + 16) > item.Z )
return false;
else if ( surface && !impassable && z == (item.Z + id.CalcHeight) )
hasSurface = true;
}
}
return hasSurface;
}