Search in sources :

Example 11 with EngineEntityManager

use of org.terasology.entitySystem.entity.internal.EngineEntityManager in project Terasology by MovingBlocks.

the class StorageManagerTest method testChunkSurvivesStorageSaveAndRestore.

@Test
public void testChunkSurvivesStorageSaveAndRestore() throws Exception {
    Chunk chunk = new ChunkImpl(CHUNK_POS, blockManager, biomeManager);
    chunk.setBlock(0, 0, 0, testBlock);
    chunk.setBlock(0, 4, 2, testBlock2);
    chunk.markReady();
    ChunkProvider chunkProvider = mock(ChunkProvider.class);
    when(chunkProvider.getAllChunks()).thenReturn(Arrays.asList(chunk));
    when(chunkProvider.getChunk(Matchers.any(Vector3i.class))).thenReturn(chunk);
    CoreRegistry.put(ChunkProvider.class, chunkProvider);
    boolean storeChunkInZips = true;
    esm.setStoreChunksInZips(storeChunkInZips);
    esm.waitForCompletionOfPreviousSaveAndStartSaving();
    esm.finishSavingAndShutdown();
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    EngineEntityManager newEntityManager = context.get(EngineEntityManager.class);
    StorageManager newSM = new ReadWriteStorageManager(savePath, moduleEnvironment, newEntityManager, blockManager, biomeManager, storeChunkInZips);
    newSM.loadGlobalStore();
    ChunkStore restored = newSM.loadChunkStore(CHUNK_POS);
    assertNotNull(restored);
    assertEquals(CHUNK_POS, restored.getChunkPosition());
    assertNotNull(restored.getChunk());
    assertEquals(testBlock, restored.getChunk().getBlock(0, 0, 0));
    assertEquals(testBlock2, restored.getChunk().getBlock(0, 4, 2));
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Vector3i(org.terasology.math.geom.Vector3i) StorageManager(org.terasology.persistence.StorageManager) Chunk(org.terasology.world.chunks.Chunk) ChunkProvider(org.terasology.world.chunks.ChunkProvider) ChunkStore(org.terasology.persistence.ChunkStore) Test(org.junit.Test)

Example 12 with EngineEntityManager

use of org.terasology.entitySystem.entity.internal.EngineEntityManager in project Terasology by MovingBlocks.

the class HeadlessEnvironment method setupStorageManager.

@Override
protected void setupStorageManager() throws IOException {
    ModuleManager moduleManager = context.get(ModuleManager.class);
    EngineEntityManager engineEntityManager = context.get(EngineEntityManager.class);
    BlockManager blockManager = context.get(BlockManager.class);
    BiomeManager biomeManager = context.get(BiomeManager.class);
    Path savePath = PathManager.getInstance().getSavePath("world1");
    context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, blockManager, biomeManager));
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) BiomeManager(org.terasology.world.biomes.BiomeManager) Path(java.nio.file.Path) BlockManager(org.terasology.world.block.BlockManager) ReadWriteStorageManager(org.terasology.persistence.internal.ReadWriteStorageManager) ModuleManager(org.terasology.engine.module.ModuleManager)

Example 13 with EngineEntityManager

use of org.terasology.entitySystem.entity.internal.EngineEntityManager in project Terasology by MovingBlocks.

the class TerasologyTestingEnvironment method setup.

@Before
public void setup() throws Exception {
    context.put(ModuleManager.class, moduleManager);
    mockTime = mock(EngineTime.class);
    context.put(Time.class, mockTime);
    NetworkSystemImpl networkSystem = new NetworkSystemImpl(mockTime, context);
    context.put(Game.class, new Game());
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    engineEntityManager = context.get(EngineEntityManager.class);
    // 'mock' added to avoid hiding a field
    BlockManager mockBlockManager = context.get(BlockManager.class);
    BiomeManager biomeManager = context.get(BiomeManager.class);
    Path savePath = PathManager.getInstance().getSavePath("world1");
    context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, mockBlockManager, biomeManager));
    componentSystemManager = new ComponentSystemManager(context);
    context.put(ComponentSystemManager.class, componentSystemManager);
    LoadPrefabs prefabLoadStep = new LoadPrefabs(context);
    boolean complete = false;
    prefabLoadStep.begin();
    while (!complete) {
        complete = prefabLoadStep.step();
    }
    context.get(ComponentSystemManager.class).initialise();
    context.put(Console.class, new ConsoleImpl(context));
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) BiomeManager(org.terasology.world.biomes.BiomeManager) Path(java.nio.file.Path) Game(org.terasology.game.Game) LoadPrefabs(org.terasology.engine.modes.loadProcesses.LoadPrefabs) ConsoleImpl(org.terasology.logic.console.ConsoleImpl) BlockManager(org.terasology.world.block.BlockManager) EngineTime(org.terasology.engine.EngineTime) ReadWriteStorageManager(org.terasology.persistence.internal.ReadWriteStorageManager) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) Before(org.junit.Before)

Aggregations

EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)13 Test (org.junit.Test)7 EntityRef (org.terasology.entitySystem.entity.EntityRef)5 StorageManager (org.terasology.persistence.StorageManager)5 Path (java.nio.file.Path)3 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)3 EngineTime (org.terasology.engine.EngineTime)3 EventLibrary (org.terasology.entitySystem.metadata.EventLibrary)3 NetworkSystemImpl (org.terasology.network.internal.NetworkSystemImpl)3 ReadWriteStorageManager (org.terasology.persistence.internal.ReadWriteStorageManager)3 Before (org.junit.Before)2 ModuleManager (org.terasology.engine.module.ModuleManager)2 EntityManager (org.terasology.entitySystem.entity.EntityManager)2 NetworkSystem (org.terasology.network.NetworkSystem)2 ChunkStore (org.terasology.persistence.ChunkStore)2 PrefabSerializer (org.terasology.persistence.serializers.PrefabSerializer)2 BiomeManager (org.terasology.world.biomes.BiomeManager)2 BlockManager (org.terasology.world.block.BlockManager)2 IOException (java.io.IOException)1 ContextImpl (org.terasology.context.internal.ContextImpl)1