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));
}
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));
}
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));
}
Aggregations