public void GenerateCave()
    {
        bool[,] caveMap = CaveGenerator.GenerateCave(caveSize, simulationSteps);

        for (int y = 0; y < caveSize; y++)
        {
            for (int x = 0; x < caveSize; x++)
            {
                if (x == 0 || y == 0 || x == caveSize - 1 || y == caveSize - 1)
                {
                    // creates a wall around the border of the cave
                    caveMap[x, y] = true;
                }
                if (caveMap[x, y])
                {
                    tilemap.SetTile(new Vector3Int(x, y, 0), blackTile);
                }
                else
                {
                    tilemap.SetTile(new Vector3Int(x, y, 0), regions[2].tile);
                }
            }
        }

        caveMap = CaveGenerator.FloodFill(caveMap, caveSize);
        int totalCaveSize = 0;

        for (int y = 0; y < caveSize; y++)
        {
            for (int x = 0; x < caveSize; x++)
            {
                if (caveMap[x, y])
                {
                    tilemap.SetTile(new Vector3Int(x, y, 0), regions[2].tile);
                    totalCaveSize++;
                }
                else
                {
                    tilemap.SetTile(new Vector3Int(x, y, 0), blackTile);
                }
            }
        }

        int minCaveSize = (caveSize * caveSize) / 2;

        if (totalCaveSize <= minCaveSize)
        {
            GenerateCave();
        }
        else
        {
            for (int y = 1; y < caveSize - 1; y++)
            {
                for (int x = 1; x < caveSize - 1; x++)
                {
                    if (tilemap.GetTile(new Vector3Int(x, y, 0)) == blackTile)
                    {
                        //Checks 8 coords around current x and y to see if it's wall or black

                        if (caveMap[x + 1, y] == regions[2].tile || caveMap[x - 1, y] == regions[2].tile ||
                            caveMap[x, y + 1] == regions[2].tile || caveMap[x, y - 1] == regions[2].tile ||
                            caveMap[x + 1, y + 1] == regions[2].tile || caveMap[x - 1, y + 1] == regions[2].tile ||
                            caveMap[x + 1, y - 1] == regions[2].tile || caveMap[x - 1, y - 1] == regions[2].tile)
                        {
                            tilemap.SetTile(new Vector3Int(x, y, 0), regions[6].tile);
                        }
                    }
                }
            }
        }
    }