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); }
public OutlineCaveGenerator(MeshGenerator meshGenerator, RockCaveConfiguration configuration) { if (meshGenerator == null) { throw new ArgumentNullException("meshGenerator"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } string message = configuration.Validate(); if (message.Length > 0) { throw new ArgumentException(message, "configuration"); } this.meshGenerator = meshGenerator; this.configuration = configuration; }
public CaveGenerator BuildOutlineCaveGen(RockCaveConfiguration config) { return(new OutlineCaveGenerator(meshGenerator, config)); }
void Reset() { threeTierCaveConfig = new ThreeTierCaveConfiguration(); rockCaveConfig = new RockCaveConfiguration(); }
/// <summary> /// Generates a cave where the walls consist of rock prefabs instantiated along the outlines. Does not /// produce a ceiling. /// </summary> /// <param name="randomizeSeeds">Will reroll the random seeds on each randomizable component.</param> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentException"></exception> public static GameObject GenerateRockCave(RockCaveConfiguration config, bool randomizeSeeds) { var generator = new RockCaveGenerator(); return(generator.Generate(config, randomizeSeeds)); }