Search in sources :

Example 1 with WorldSerializerImpl

use of org.terasology.persistence.serializers.WorldSerializerImpl 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.entitySystem.entity.internal.EngineEntityManager) EntityData(org.terasology.protobuf.EntityData) EntityBuilder(org.terasology.entitySystem.entity.EntityBuilder) WorldSerializerImpl(org.terasology.persistence.serializers.WorldSerializerImpl) WorldSerializer(org.terasology.persistence.serializers.WorldSerializer) EntityRef(org.terasology.entitySystem.entity.EntityRef) PrefabSerializer(org.terasology.persistence.serializers.PrefabSerializer) Test(org.junit.Test)

Aggregations

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