Search in sources :

Example 6 with PlayerStore

use of org.terasology.engine.persistence.PlayerStore in project Terasology by MovingBlocks.

the class StorageManagerTest method testReferenceRemainsValidOverStorageRestoral.

@Test
public void testReferenceRemainsValidOverStorageRestoral() throws Exception {
    EntityRef someEntity = entityManager.create();
    character.addComponent(new EntityRefComponent(someEntity));
    esm.waitForCompletionOfPreviousSaveAndStartSaving();
    esm.finishSavingAndShutdown();
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    EngineEntityManager newEntityManager = context.get(EngineEntityManager.class);
    StorageManager newSM = new ReadWriteStorageManager(savePath, moduleEnvironment, newEntityManager, blockManager, extraDataManager, false, recordAndReplaySerializer, recordAndReplayUtils, recordAndReplayCurrentStatus);
    newSM.loadGlobalStore();
    PlayerStore restored = newSM.loadPlayerStore(PLAYER_ID);
    restored.restoreEntities();
    assertTrue(restored.getCharacter().getComponent(EntityRefComponent.class).entityRef.exists());
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) EntityRefComponent(org.terasology.unittest.stubs.EntityRefComponent) PlayerStore(org.terasology.engine.persistence.PlayerStore) StorageManager(org.terasology.engine.persistence.StorageManager) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) Test(org.junit.jupiter.api.Test)

Example 7 with PlayerStore

use of org.terasology.engine.persistence.PlayerStore in project Terasology by MovingBlocks.

the class StorageManagerTest method testStoreAndRestoreOfPlayerWithoutCharacter.

@Test
public void testStoreAndRestoreOfPlayerWithoutCharacter() {
    // remove character from player:
    character.destroy();
    esm.waitForCompletionOfPreviousSaveAndStartSaving();
    esm.finishSavingAndShutdown();
    PlayerStore restoredStore = esm.loadPlayerStore(PLAYER_ID);
    assertNotNull(restoredStore);
    assertFalse(restoredStore.hasCharacter());
    assertEquals(new Vector3f(), restoredStore.getRelevanceLocation());
}
Also used : PlayerStore(org.terasology.engine.persistence.PlayerStore) Vector3f(org.joml.Vector3f) Test(org.junit.jupiter.api.Test)

Example 8 with PlayerStore

use of org.terasology.engine.persistence.PlayerStore in project Terasology by MovingBlocks.

the class NetworkSystemImpl method connectClient.

private void connectClient(Client client) {
    PlayerStore entityStore = storageManager.loadPlayerStore(client.getId());
    client.getEntity().send(new ConnectedEvent(entityStore));
}
Also used : PlayerStore(org.terasology.engine.persistence.PlayerStore) ConnectedEvent(org.terasology.engine.network.events.ConnectedEvent)

Aggregations

PlayerStore (org.terasology.engine.persistence.PlayerStore)8 Test (org.junit.jupiter.api.Test)5 Vector3f (org.joml.Vector3f)3 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)3 LocationComponent (org.terasology.engine.logic.location.LocationComponent)2 Vector3fc (org.joml.Vector3fc)1 Vector3ic (org.joml.Vector3ic)1 Order (org.junit.jupiter.api.Order)1 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)1 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)1 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)1 Client (org.terasology.engine.network.Client)1 ConnectedEvent (org.terasology.engine.network.events.ConnectedEvent)1 StorageManager (org.terasology.engine.persistence.StorageManager)1 EntityRefComponent (org.terasology.unittest.stubs.EntityRefComponent)1