/// <inheritdoc /> public void ClearChunks() { UpdateQueue.Clear(); FastUpdateQueue.Clear(); UpdateBorderQueue.Clear(); var chunks = Chunks.ToArray(); Chunks.Clear(); Scheduled.Clear(); _renderedChunks = new ChunkData[0]; foreach (var chunk in chunks) { chunk.Value.Dispose(); } }
/// <inheritdoc /> public void Dispose() { if (_disposed) { return; } try { //Graphics?.Dispose(); BlockLightCalculations?.Dispose(); BlockLightCalculations = null; SkyLightCalculator?.Dispose(); SkyLightCalculator = null; _renderSampler.Dispose(); CancellationToken.Cancel(); UpdateQueue.Clear(); FastUpdateQueue.Clear(); UpdateBorderQueue.Clear(); foreach (var chunk in Chunks) { chunk.Value.Dispose(); } Chunks.Clear(); foreach (var rendered in _renderedChunks) { rendered.Dispose(); } _renderedChunks = null; } finally { _disposed = true; } }
/// <inheritdoc /> public void RemoveChunk(ChunkCoordinates position, bool dispose = true) { BlockLightCalculations.Remove(position); if (Chunks.TryRemove(position, out var column)) { foreach (var blockEntity in column.GetBlockEntities) { World.EntityManager.RemoveBlockEntity( new BlockCoordinates((column.X << 4) + blockEntity.X, blockEntity.Y, (column.Z << 4) + blockEntity.Z)); } UpdateQueue.Remove(position); UpdateBorderQueue.Remove(position); if (dispose) { column.Dispose(); } } }
/// <inheritdoc /> public void Dispose() { //Graphics?.Dispose(); CancellationToken.Cancel(); UpdateQueue.Clear(); FastUpdateQueue.Clear(); UpdateBorderQueue.Clear(); foreach (var chunk in Chunks) { chunk.Value.Dispose(); } Chunks.Clear(); foreach (var rendered in _renderedChunks) { rendered.Dispose(); } _renderedChunks = null; }