Search in sources :

Example 1 with PurgeWorldEvent

use of org.terasology.world.chunks.event.PurgeWorldEvent in project Terasology by MovingBlocks.

the class LocalChunkProvider method purgeWorld.

@Override
public void purgeWorld() {
    ChunkMonitor.fireChunkProviderDisposed(this);
    pipeline.shutdown();
    unloadRequestTaskMaster.shutdown(new ChunkUnloadRequest(), true);
    chunkFinalizer.shutdown();
    chunkCache.getAllChunks().stream().filter(ManagedChunk::isReady).forEach(chunk -> {
        worldEntity.send(new BeforeChunkUnload(chunk.getPosition()));
        storageManager.deactivateChunk(chunk);
        chunk.dispose();
    });
    chunkCache.clear();
    readyChunks.clear();
    sortedReadyChunks.clear();
    storageManager.deleteWorld();
    preparingChunks.clear();
    worldEntity.send(new PurgeWorldEvent());
    pipeline = new ChunkGenerationPipeline(new ChunkTaskRelevanceComparator());
    unloadRequestTaskMaster = TaskMaster.createFIFOTaskMaster("Chunk-Unloader", 8);
    chunkFinalizer = chunkFinalizerSupplier.get();
    chunkFinalizer.initialize(this);
    chunkFinalizer.restart();
    ChunkMonitor.fireChunkProviderInitialized(this);
    for (ChunkRelevanceRegion chunkRelevanceRegion : regions.values()) {
        for (Vector3i pos : chunkRelevanceRegion.getCurrentRegion()) {
            createOrLoadChunk(pos);
        }
        chunkRelevanceRegion.setUpToDate();
    }
}
Also used : BeforeChunkUnload(org.terasology.world.chunks.event.BeforeChunkUnload) ChunkGenerationPipeline(org.terasology.world.chunks.pipeline.ChunkGenerationPipeline) ChunkRelevanceRegion(org.terasology.world.chunks.internal.ChunkRelevanceRegion) PurgeWorldEvent(org.terasology.world.chunks.event.PurgeWorldEvent) Vector3i(org.terasology.math.geom.Vector3i)

Aggregations

Vector3i (org.terasology.math.geom.Vector3i)1 BeforeChunkUnload (org.terasology.world.chunks.event.BeforeChunkUnload)1 PurgeWorldEvent (org.terasology.world.chunks.event.PurgeWorldEvent)1 ChunkRelevanceRegion (org.terasology.world.chunks.internal.ChunkRelevanceRegion)1 ChunkGenerationPipeline (org.terasology.world.chunks.pipeline.ChunkGenerationPipeline)1