private void TryToDeleteQueuedChunks() { var chunksToRemove = ChunksToRemove.ToList(); foreach (var chunkPosition in chunksToRemove) { if (RequestedChunks.ContainsKey(chunkPosition)) { RequestedChunks.Remove(chunkPosition); ChunksToRemove.Remove(chunkPosition); } else if (LoadedChunks.ContainsKey(chunkPosition)) { var chunk = LoadedChunks[chunkPosition]; chunk.Remove(); LoadedChunks.Remove(chunkPosition); ChunksToRemove.Remove(chunkPosition); } else if (!ChunksBeingGenerated.ContainsKey(chunkPosition)) { ChunksToRemove.Remove(chunkPosition); } } }
public bool ChunkCanBeRemoved(int x, int z) { var key = new Vector2i(x, z); return RequestedChunks.ContainsKey(key) || ChunksBeingGenerated.ContainsKey(key) || LoadedChunks.ContainsKey(key); }
/// <summary> /// Chunks the can be added. /// </summary> /// <returns><c>true</c>, if can be added was chunked, <c>false</c> otherwise.</returns> /// <param name="x">The x coordinate.</param> /// <param name="z">The z coordinate.</param> public bool ChunkCanBeAdded(int x, int z) { var key = new XVec2I(x, z); return (!(RequestedChunks.ContainsKey(key) || ChunksBeingGenerated.ContainsKey(key) || LoadedChunks.ContainsKey(key))); }