// 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;
        }
        internal Cave(CollisionTester collisionTester, IEnumerable <CaveMeshes> caveMeshes, CaveConfiguration caveConfiguration)
        {
            Assert.IsNotNull(collisionTester);
            Assert.IsNotNull(caveMeshes);
            Assert.IsNotNull(caveConfiguration);

            Configuration   = caveConfiguration.Clone();
            GameObject      = new GameObject("Cave");
            CollisionTester = collisionTester;
            BuildSectors(caveMeshes);
        }