void GenerateMap()
    {
        Map map = new Map(mapWidth, mapHeight);

        RandomFillMap(map);

        for (int i = 0; i < smoothingIterations; i++)
        {
            SmoothMap(map);
        }

        if (fillThreshold > 0)
        {
            RemoveSmallRegions(map, 1, 0);
        }


        MeshGenerator meshGen      = GetComponent <MeshGenerator>();
        Map           tileMap      = meshGen.GenerateMap(map);
        Map           tileSheetMap = new Map(tileMap.Width, tileMap.Height);
        Map           edgeMap      = GenerateEdgeMap(tileMap, 0, 15);

        List <List <Coord> > landRegions = GetRegions(tileMap, 0);

        foreach (List <Coord> region in landRegions)
        {
            foreach (Coord coord in region)
            {
                byte tileByteAddress = edgeMap.ActiveNeighborByte(coord.X, coord.Y, 1);
                if (edgeMap.IsInRange(coord.X, coord.Y) && edgeMap.ActiveNeighborCount(coord.X, coord.Y, 1) > 0)
                {
                    tileMap[coord.X, coord.Y]      = tileByteAddress;
                    tileSheetMap[coord.X, coord.Y] = 1;
                }
            }
        }

        gizmoMap = edgeMap;
        meshGen.ApplyTileMap(tileSheetMap, tileMap);
        meshGen.ApplyMesh();
    }