public static void Generate( Rectangle2D region )
{
for ( int rx = 0; rx < region.Width; ++rx )
{
for ( int ry = 0; ry < region.Height; ++ry )
{
int vx = rx + region.X;
int vy = ry + region.Y;
StaticTile[] tiles = m_Map.Tiles.GetStaticTiles( vx, vy );
for ( int i = 0; i < tiles.Length; ++i )
{
StaticTile tile = tiles[i];
int id = tile.ID;
int z = tile.Z;
if ( IsWestFrame( id ) )
{
if ( IsEastFrame( vx + 2, vy, z ) )
{
AddDoor( vx + 1, vy, z, DoorFacing.WestCW );
}
else if ( IsEastFrame( vx + 3, vy, z ) )
{
BaseDoor first = AddDoor( vx + 1, vy, z, DoorFacing.WestCW );
BaseDoor second = AddDoor( vx + 2, vy, z, DoorFacing.EastCCW );
if ( first != null && second != null )
{
first.Link = second;
second.Link = first;
}
else
{
if ( first != null )
first.Delete();
if ( second != null )
second.Delete();
}
}
}
else if ( IsNorthFrame( id ) )
{
if ( IsSouthFrame( vx, vy + 2, z ) )
{
AddDoor( vx, vy + 1, z, DoorFacing.SouthCW );
}
else if ( IsSouthFrame( vx, vy + 3, z ) )
{
BaseDoor first = AddDoor( vx, vy + 1, z, DoorFacing.NorthCCW );
BaseDoor second = AddDoor( vx, vy + 2, z, DoorFacing.SouthCW );
if ( first != null && second != null )
{
first.Link = second;
second.Link = first;
}
else
{
if ( first != null )
first.Delete();
if ( second != null )
second.Delete();
}
}
}
}
}
}
}
}