Func <WallGrid, IHeightMap, MeshData> SelectCeilingBuilder(ThreeTierCaveType caveType) { switch (caveType) { case ThreeTierCaveType.Isometric: return(meshGenerator.BuildCeiling); case ThreeTierCaveType.Enclosed: return(meshGenerator.BuildEnclosure); default: throw new System.ComponentModel.InvalidEnumArgumentException(); } }
static CaveMeshes[,] GenerateCaveChunks(Map[,] mapChunks, ThreeTierCaveType type, int scale, IHeightMap floor, IHeightMap ceiling) { int xNumChunks = mapChunks.GetLength(0); int yNumChunks = mapChunks.GetLength(1); var caveChunks = new CaveMeshes[xNumChunks, yNumChunks]; var actions = new Action[mapChunks.Length]; mapChunks.ForEach((x, y) => { Coord index = new Coord(x, y); actions[y * xNumChunks + x] = new Action(() => { WallGrid grid = MapConverter.MapToWallGrid(mapChunks[x, y], scale, index); MeshData floorMesh = MeshGenerator.BuildFloor(grid, floor); MeshData ceilingMesh = SelectCeilingBuilder(type)(grid, ceiling); MeshData wallMesh = MeshGenerator.BuildWalls(grid, floor, ceiling); caveChunks[index.x, index.y] = new CaveMeshes(floorMesh, wallMesh, ceilingMesh); }); }); Execute(actions); return(caveChunks); }