コード例 #1
0
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
ファイル: Coord3.cs プロジェクト: funnbot/VoxelEngine
 public Coord3(Coord2 c, int z)
 {
     x      = c.x;
     y      = c.y;
     this.z = z;
 }