private void Test(World level, BlockCoordinates sourceBlock, BlockCoordinates target, ConcurrentQueue <BlockCoordinates> lightBfsQueue, int lightLevel) { var chunkCoord = new ChunkCoordinates(sourceBlock); //Interlocked.Add(ref touches, 1); bool isOtherChunk = false; var newChunkCoord = (ChunkCoordinates)target; if (chunkCoord.X != newChunkCoord.X || chunkCoord.Z != newChunkCoord.Z) { //chunk = GetChunk(level, newCoord); lightBfsQueue = ChunkQueues.GetOrAdd(newChunkCoord, coordinates => new ConcurrentQueue <BlockCoordinates>()); isOtherChunk = true; } if (isOtherChunk && !World.TryGetBlockLight(target, out _)) { lightBfsQueue.Enqueue(target); /*Queue.Enqueue((newCoord, () => * { * if (ChunkQueues.TryGetValue((ChunkCoordinates) newCoord, out var queue)) * { * if (!level.TryGetBlockLight(coord, out var ll)) * { * return false; * } * //var cc = GetChunk(level, newCoord); * //if (cc == null) * // return false; * //var ll = level.GetBlockLight(coord); * * DoPass(level, newCoord, queue, ll); * * Enqueue(coord); * Enqueue(newCoord); * return true; * } * return false; * }));*/ return; } DoPass(level, target, lightBfsQueue, lightLevel); }