MeshGenerator PrepareMeshGenerator(MeshGenerator meshGenerator, Map map)
        {
            WallGrid wallGrid = MapConverter.ToWallGrid(map, config.Scale);

            meshGenerator.Generate(wallGrid, config.CaveType, floorHeightMap, ceilingHeightMap);
            return(meshGenerator);
        }
        // This method packages the functionality that can be executed in a secondary thread,
        // which includes generating most of the data necessary to build a cave. BuildCave uses the generated data to
        // build the cave, something that has to be excuted on the main thread as most of Unity's API
        // is off-limits on secondary threads.
        void GenerateCoreData()
        {
            Map map = MapGenerator.GenerateMap(config.MapParameters);

            Map[]           submaps         = MapSplitter.Subdivide(map);
            MeshGenerator[] meshGenerators  = PrepareMeshGenerators(submaps);
            CollisionTester collisionTester = MapConverter.ToCollisionTester(map, config.Scale);

            this.collisionTester = collisionTester;
            this.meshGenerators  = meshGenerators;
        }