/** * * @param entitiesToSave all persistent entities within the given chunk * @param chunkUnloaded if true the chunk data will be used directly. If deactivate is false then the chunk will be * but in snapshot mode so that concurrent modifications (and possibly future unload) is * possible. */ public CompressedChunkBuilder(EngineEntityManager entityManager, ChunkImpl chunk, Collection<EntityRef> entitiesToSave, boolean chunkUnloaded) { EntityStorer storer = new EntityStorer(entityManager); entitiesToSave.stream().filter(EntityRef::isPersistent).forEach(storer::store); storedEntities = storer.getStoredEntities(); this.entityStore = storer.finaliseStore(); this.chunk = chunk; this.viaSnapshot = !chunkUnloaded; if (viaSnapshot) { this.chunk.createSnapshot(); } }