コード例 #1
0
 static void LoadChunksBlocking(HashSet <Vector3Int> chunksToLoad)
 {
     try {
         currentlyUsedChunksLock.EnterWriteLock();
         currentlyUsedChunks = new HashSet <Vector3Int> (chunksToLoad);
     } finally {
         if (currentlyUsedChunksLock.IsWriteLockHeld)
         {
             currentlyUsedChunksLock.ExitWriteLock();
         }
     }
     foreach (Vector3Int chunkPosition in chunksToLoad)
     {
         ChunkQueue.QueuePlayerSurrounding(chunkPosition);
     }
     ChunkQueue.PokeThread();
     while (chunksToLoad.Count > 0)
     {
         chunksToLoad.RemoveWhere(chunkPosition => {
             Chunk chunk = World.GetChunk(chunkPosition);
             return(chunk != null && chunk.DataState == Chunk.ChunkDataState.DataFull);
         });
         Thread.Sleep(10);
     }
 }