public void RegenerateSupported(int level)
{
if (level < 2 || level > Stories) return;
bool[] objSup = ObjectSupport[level - 2];
bool[] sup = Supported[level - 2];
FloorTile[] floors = Floors[level - 1];
VMRoomMap rooms = Rooms[level - 2];
int offset = 0;
for (int y=0; y<Height; y++)
{
for (int x=0; x<Width; x++)
{
//if we are an object support or are above a room that is not outside, we're supported.
if (objSup[offset] || !RoomData[(ushort)(rooms.Map[offset])].IsOutside) sup[offset] = true;
else
{
//if we are a floor tile or are next to the floor tile, do the full 5x5 check.
bool step1 = false;
for (int i = 0; i < SupportSpread.Length; i++)
{
int newX = x + SupportSpread[i].X;
int newY = y + SupportSpread[i].Y;
if (newX < 0 || newX >= Width || newY < 0 || newY >= Height) continue;
int newOff = newY * Width + newX;
if (floors[newOff].Pattern != 0)
{
step1 = true;
break;
}
}
if (step1)
{
bool step2 = false;
for (int y2 = -2; y2 < 3; y2++)
{
for (int x2 = -2; x2 < 3; x2++)
{
int newX = x + x2;
int newY = y + y2;
if (newX < 0 || newX >= Width || newY < 0 || newY >= Height) continue;
int newOff = newY * Width + newX;
if (!RoomData[(ushort)rooms.Map[newOff]].IsOutside || (objSup[newOff] && (Math.Abs(x2)<2 && Math.Abs(y2)<2)))
{
step2 = true;
break;
}
}
if (step2) break;
}
sup[offset] = step2;
}
else sup[offset] = false;
}
offset++;
}
}
}