コード例 #1
0
    CaveMeshes[,] GenerateCaveChunks(Map[,] mapChunks, ThreeTierCaveType type, int scale,
                                     IHeightMap floor, IHeightMap ceiling, CaveWallModule walls)
    {
        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, walls);

                caveChunks[index.x, index.y] = new CaveMeshes(floorMesh, wallMesh, ceilingMesh);
            });
        });
        Execute(actions);
        return(caveChunks);
    }