// The first pass will fill the tilemap intersection cells, so that it can be used similarly to the standard map interpreter
    private void PerformTilemapConversion(VirtualMap map, VirtualMap[] maps, int storey)
    {
        VirtualCell conversion_cell;

        VirtualCell[,] output_cells = new VirtualCell[map.Width, map.Height];

        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                CellLocation loc = new CellLocation(i, j);
                conversion_cell = VirtualCell.Copy(map.GetCell(loc));
                ConvertTileIntersections(map, conversion_cell);
                output_cells[i, j] = conversion_cell;
            }
        }

        // We can now override the initial map!
        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                map.SetCell(i, j, output_cells[i, j]);
            }
        }
    }
    // The second pass will update the different tiles as needed
    private void PerformSpecificConversions(VirtualMap map, VirtualMap[] maps, int storey)
    {
        VirtualCell conversion_cell;

        VirtualCell[,] output_cells = new VirtualCell[map.Width, map.Height];

        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                CellLocation loc = new CellLocation(i, j);
                conversion_cell = VirtualCell.Copy(map.GetCell(loc));

                if (conversion_cell.IsFloor())
                {
                    ConvertFloor(map, conversion_cell);
                }
                else if (conversion_cell.IsDoor())
                {
                    ConvertDoor(map, conversion_cell);
                }
                else if (conversion_cell.IsWall())
                {
                    // All walls are rocks here
                    ConvertRock(map, conversion_cell);
                }
                else if (conversion_cell.IsNone())
                {
                    // All nones are rocks here
                    ConvertRock(map, conversion_cell);
                }
                else if (conversion_cell.IsRock())
                {
                    // All is rock!
                    ConvertRock(map, conversion_cell);
                }

                // Final pass on orientation randomization
                CheckOrientationRandomization(map, conversion_cell);

                // We save it in the initial map
                output_cells[i, j] = conversion_cell;
            }
        }

        // We can now override the initial map!
        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                map.SetCell(i, j, output_cells[i, j]);
            }
        }
    }
    private void PerformSpecificConversions(VirtualMap map, VirtualMap[] maps, int storey)
    {
        VirtualCell conversion_cell;

        VirtualCell[,] output_cells = new VirtualCell[map.Width, map.Height];

        // Modify the virtual map as needed
        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                CellLocation loc = new CellLocation(i, j);
                conversion_cell = VirtualCell.Copy(map.GetCell(loc));

                if (conversion_cell.IsFloor())
                {
                    ConvertFloor(map, conversion_cell);
                }
                else if (conversion_cell.IsDoor())
                {
                    ConvertDoor(map, conversion_cell);

                    bool renderWall = CheckWallRendering(map, conversion_cell);
                    if (renderWall)
                    {
                        ConvertWallOrientation(map, conversion_cell);
                    }
                }
                else if (conversion_cell.IsWall() || conversion_cell.IsEmpty())
                {
                    bool isPerimeter = ConvertPerimeterWall(map, conversion_cell);
                    if (!isPerimeter)
                    {
                        bool renderWall = CheckWallRendering(map, conversion_cell);
                        if (renderWall)
                        {
                            ConvertWallOrientation(map, conversion_cell);
                        }
                    }
                }
                else if (conversion_cell.IsNone())
                {
                    // 'None' cells may be converted to columns
                    ConvertColumn(map, conversion_cell, true);
                    ConvertPerimeterColumn(map, conversion_cell);
                }
                else if (conversion_cell.IsRock())
                {
                    // We may draw rocks
                    ConvertRock(map, conversion_cell);
                }

                // Final pass on orientation randomization
                CheckOrientationRandomization(map, conversion_cell);

                // We save the cell in the initial map
                output_cells[i, j] = conversion_cell;
            }
        }

        // We can now override the initial map!
        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                map.SetCell(i, j, output_cells[i, j]);
            }
        }

        // Additional modifications, per-storey
        // WE DO NOT HAVE ANYTHING HERE FOR NOW
    }
    // The second pass will update the different tiles as needed
    private void PerformSpecificConversions(VirtualMap map, VirtualMap[] maps, int storey)
    {
        VirtualCell conversion_cell;

        VirtualCell[,] output_cells = new VirtualCell[map.Width, map.Height];

        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                CellLocation loc = new CellLocation(i, j);
                conversion_cell = VirtualCell.Copy(map.GetCell(loc));
                //Debug.Log("CHECKING " + conversion_cell);

                if (conversion_cell.IsFloor())
                {
                    ConvertFloor(map, conversion_cell);
                }
                else if (conversion_cell.IsDoor())
                {
                    ConvertDoor(map, conversion_cell);

                    CheckWallRendering(map, conversion_cell);
//					if (renderWall) ConvertFixedWallOrientation(map,conversion_cell);

                    AddFillingFloors(map, conversion_cell);
                }
                else if (conversion_cell.IsWall())
                {
                    bool isPerimeter = ConvertWall(map, conversion_cell);

                    bool renderWall = CheckWallRendering(map, conversion_cell);
                    if (renderWall)
                    {
                        if (!isPerimeter || (isPerimeter && !behaviour.orientPerimeter))
                        {
                            ConvertFixedWallOrientation(map, conversion_cell);
                        }
                    }
                    else
                    {
                        ConvertRock(map, conversion_cell);                      // May be a rock
                    }
                    AddFillingFloors(map, conversion_cell);
                }
                else if (conversion_cell.IsNone())
                {
                    //Debug.Log("NONE CELL " + conversion_cell);
                    // 'None' cells are usually converted to columns
                    bool isColumn    = ConvertColumn(map, conversion_cell);
                    bool isPerimeter = ConvertPerimeterColumn(map, conversion_cell);
                    ConvertFixedWallOrientation(map, conversion_cell);                          // Also columns need to be orientated correctly

                    // If not a column, check what this is
                    if (!isColumn && !isPerimeter)
                    {
                        // Usually a rock
                        ConvertRock(map, conversion_cell);
                    }

                    bool isActuallyFloor = false;
                    // Also, an inside-room tile may be transformed into a floor
                    if (!isPerimeter)
                    {
                        if (conversion_cell.IsFloor()) //CheckRoom(map,conversion_cell.location)){
                        //Debug.Log("INSIDE!");
                        {
                            AddToCorrectRoom(map, conversion_cell.location);
                            conversion_cell.Type = VirtualCell.CellType.RoomFloor;
                            ConvertFloor(map, conversion_cell);
                            isActuallyFloor = true;
                        }
                    }

                    if (!isActuallyFloor)
                    {
                        AddFillingFloors(map, conversion_cell);
                    }
                }
                else if (conversion_cell.IsRock())
                {
                    // We may draw rocks
                    ConvertRock(map, conversion_cell);

                    AddFillingFloors(map, conversion_cell);
                }


                // Final pass on orientation randomization
                CheckOrientationRandomization(map, conversion_cell);

                // We save it in the initial map
                output_cells[i, j] = conversion_cell;
            }
        }

        // We can now override the initial map!
        for (int i = 0; i < map.Width; i++)
        {
            for (int j = 0; j < map.Height; j++)
            {
                map.SetCell(i, j, output_cells[i, j]);
            }
        }
    }