IEnumerator LoadSpawnRoutine() { int loadSize = spawnSize + 1; for (int x = -loadSize; x <= loadSize; x++) { for (int z = -loadSize; z <= loadSize; z++) { var pos = new Coord2(x, z); var chunk = chunks.CreateChunk(pos); } } var task = Task.Run(() => { for (int x = -spawnSize; x <= spawnSize; x++) { for (int z = -spawnSize; z <= spawnSize; z++) { var pos = new Coord2(x, z); var chunk = chunks.GetChunk(pos); chunk.Build(); } } }); yield return(task.WaitTillComplete()); Parallel.For(-spawnSize, spawnSize + 1, x => { for (int z = -spawnSize; z <= spawnSize; z++) { var pos = new Coord2(x, z); var chunk = chunks.GetChunk(pos); chunk.GenerateMesh(); } }); for (int x = -spawnSize; x <= spawnSize; x++) { for (int z = -spawnSize; z <= spawnSize; z++) { var pos = new Coord2(x, z); var chunk = chunks.GetChunk(pos); chunk.ApplyMesh(); } yield return(null); } OnSpawnLoad?.Invoke(); }
void LoadSpawn() { int loadSize = spawnSize + 1; for (int x = -loadSize; x <= loadSize; x++) { for (int z = -loadSize; z <= loadSize; z++) { var pos = new Coord2(x, z); var chunk = chunks.CreateChunk(pos); } } for (int x = -spawnSize; x <= spawnSize; x++) { for (int z = -spawnSize; z <= spawnSize; z++) { var pos = new Coord2(x, z); var chunk = chunks.GetChunk(pos); chunk.Build(); } } for (int x = -spawnSize; x <= spawnSize; x++) { for (int z = -spawnSize; z <= spawnSize; z++) { var pos = new Coord2(x, z); var chunk = chunks.GetChunk(pos); chunk.GenerateMesh(); chunk.ApplyMesh(); } } OnSpawnLoad?.Invoke(); }
public Coord3(Coord2 c, int z) { x = c.x; y = c.y; this.z = z; }