GameObject GenerateRockCave() { if (randomize) { rockCaveConfig.SetSeed(GetRandomSeed()); } CaveGenerator caveGenerator = caveGeneratorFactory.BuildOutlineCaveGen(rockCaveConfig); return(GenerateCave(caveGenerator)); }
public GameObject Generate(RockCaveConfiguration config, bool randomizeSeeds) { if (config == null) { throw new ArgumentNullException("config"); } string message = config.Validate(); if (message.Length > 0) { throw new ArgumentException(message, "config"); } if (randomizeSeeds) { config.SetSeed(GetRandomSeed()); } int scale = config.Scale; Map map = config.MapGenerator.Generate(); Material floorMaterial = config.Material; IHeightMap heightMap = config.HeightMapModule.GetHeightMap(); IOutlinePrefabber outlinePrefabber = config.OutlineModule.GetOutlinePrefabber(); GameObject cave = new GameObject("Cave"); Map[,] mapChunks = MapSplitter.Subdivide(map); mapChunks.ForEach((x, y) => { Coord index = new Coord(x, y); WallGrid grid = MapConverter.MapToWallGrid(mapChunks[x, y], scale, index); List <Vector3[]> outlines = MeshGenerator.BuildOutlines(grid); CaveMeshes caveMeshes = BuildCaveMesh(grid, heightMap); Sector sector = BuildSector(caveMeshes, index, cave, floorMaterial); GameObject rockAnchor = BuildRockAnchor(sector.GameObject, index); PlaceRocks(outlines, outlinePrefabber, rockAnchor.transform); }); return(cave); }