Ejemplo n.º 1
0
        /// <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();
            }
        }
Ejemplo n.º 2
0
        /// <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;
            }
        }
Ejemplo n.º 3
0
        /// <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;
        }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public void RemoveChunk(ChunkCoordinates position, bool dispose = true)
        {
            BlockLightCalculations.Remove(position);
            UpdateQueue.Remove(position);
            UpdateBorderQueue.Remove(position);
            FastUpdateQueue.Remove(position);
            Scheduled.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));
                }

                if (dispose)
                {
                    column.Dispose();
                }
            }
        }