Search in sources :

Example 6 with ChunkProvider

use of org.terasology.engine.world.chunks.ChunkProvider in project Terasology by MovingBlocks.

the class ReadWriteStorageManager method isSavingNecessary.

private boolean isSavingNecessary() {
    ChunkProvider chunkProvider = CoreRegistry.get(ChunkProvider.class);
    int unloadedChunkCount = unloadedAndUnsavedChunkMap.size();
    int loadedChunkCount = chunkProvider.getAllChunks().size();
    double totalChunkCount = unloadedChunkCount + loadedChunkCount;
    double percentageUnloaded = 100.0 * unloadedChunkCount / totalChunkCount;
    if (percentageUnloaded >= systemConfig.maxUnloadedChunksPercentageTillSave.get()) {
        return true;
    }
    long currentTime = System.currentTimeMillis();
    if (nextAutoSave == null) {
        scheduleNextAutoSave();
        return false;
    }
    return currentTime >= nextAutoSave;
}
Also used : ChunkProvider(org.terasology.engine.world.chunks.ChunkProvider)

Aggregations

ChunkProvider (org.terasology.engine.world.chunks.ChunkProvider)6 Test (org.junit.jupiter.api.Test)3 ChunkStore (org.terasology.engine.persistence.ChunkStore)3 Chunk (org.terasology.engine.world.chunks.Chunk)3 ChunkImpl (org.terasology.engine.world.chunks.internal.ChunkImpl)3 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)2 StorageManager (org.terasology.engine.persistence.StorageManager)2 Vector3f (org.joml.Vector3f)1 Vector3ic (org.joml.Vector3ic)1 AudioManager (org.terasology.engine.audio.AudioManager)1 EnvironmentSwitchHandler (org.terasology.engine.core.bootstrap.EnvironmentSwitchHandler)1 ModuleManager (org.terasology.engine.core.module.ModuleManager)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)1 LocationComponent (org.terasology.engine.logic.location.LocationComponent)1 NetworkSystem (org.terasology.engine.network.NetworkSystem)1 PhysicsEngine (org.terasology.engine.physics.engine.PhysicsEngine)1 BlockFamilyDefinition (org.terasology.engine.world.block.loader.BlockFamilyDefinition)1 Asset (org.terasology.gestalt.assets.Asset)1 AssetType (org.terasology.gestalt.assets.AssetType)1