Search in sources :

Example 1 with WorldSerializer

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

the class WorldSerializerTest method testNotPersistedIfFlagedOtherwise.

@Test
public void testNotPersistedIfFlagedOtherwise() throws Exception {
    EngineEntityManager entityManager = context.get(EngineEntityManager.class);
    EntityBuilder entityBuilder = entityManager.newBuilder();
    PrefabSerializer prefabSerializer = new PrefabSerializer(entityManager.getComponentLibrary(), entityManager.getTypeSerializerLibrary());
    WorldSerializer worldSerializer = new WorldSerializerImpl(entityManager, prefabSerializer);
    entityBuilder.setPersistent(false);
    // just used to express that an entity got created
    @SuppressWarnings("unused") EntityRef entity = entityBuilder.build();
    EntityData.GlobalStore worldData = worldSerializer.serializeWorld(false);
    assertEquals(0, worldData.getEntityCount());
}
Also used : EngineEntityManager(org.terasology.engine.entitySystem.entity.internal.EngineEntityManager) EntityData(org.terasology.protobuf.EntityData) EntityBuilder(org.terasology.engine.entitySystem.entity.EntityBuilder) WorldSerializerImpl(org.terasology.engine.persistence.serializers.WorldSerializerImpl) WorldSerializer(org.terasology.engine.persistence.serializers.WorldSerializer) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) PrefabSerializer(org.terasology.engine.persistence.serializers.PrefabSerializer) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 EntityBuilder (org.terasology.engine.entitySystem.entity.EntityBuilder)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 EngineEntityManager (org.terasology.engine.entitySystem.entity.internal.EngineEntityManager)1 PrefabSerializer (org.terasology.engine.persistence.serializers.PrefabSerializer)1 WorldSerializer (org.terasology.engine.persistence.serializers.WorldSerializer)1 WorldSerializerImpl (org.terasology.engine.persistence.serializers.WorldSerializerImpl)1 EntityData (org.terasology.protobuf.EntityData)1