Package org.terasology.persistence.serializers

Examples of org.terasology.persistence.serializers.EntitySerializer


    private TIntSet storedEntityIds = new TIntHashSet();

    public EntityStorer(EngineEntityManager entityManager) {
        this.entityManager = entityManager;
        this.entityStoreBuilder = EntityData.EntityStore.newBuilder();
        this.serializer = new EntitySerializer(entityManager);
        this.helper = new OwnershipHelper(entityManager.getComponentLibrary());

        Map<Class<? extends Component>, Integer> componentIds = Maps.newHashMap();
        for (ComponentMetadata<?> componentMetadata : entityManager.getComponentLibrary().iterateComponentMetadata()) {
            entityStoreBuilder.addComponentClass(componentMetadata.getUri().toString());
View Full Code Here


    /**
     * @return A full, json style description of the entity.
     */
    public String toFullDescription() {
        EntitySerializer serializer = new EntitySerializer((EngineEntityManager) CoreRegistry.get(EntityManager.class));
        serializer.setUsingFieldIds(false);
        return EntityDataJSONFormat.write(serializer.serialize(this));
    }
View Full Code Here

    public GlobalStoreLoader(ModuleEnvironment environment, EngineEntityManager entityManager, PrefabSerializer prefabSerializer) {
        this.entityManager = entityManager;
        this.prefabManager = entityManager.getPrefabManager();
        this.environment = environment;
        this.componentLibrary = entityManager.getComponentLibrary();
        this.entitySerializer = new EntitySerializer(entityManager);
        this.prefabSerializer = prefabSerializer;
    }
View Full Code Here

        EntitySystemBuilder builder = new EntitySystemBuilder();
        entityManager = builder.build(moduleManager.getEnvironment(), mock(NetworkSystem.class), new ReflectionReflectFactory());
        entityManager.getComponentLibrary().register(new SimpleUri("test", "gettersetter"), GetterSetterComponent.class);
        entityManager.getComponentLibrary().register(new SimpleUri("test", "string"), StringComponent.class);
        entityManager.getComponentLibrary().register(new SimpleUri("test", "integer"), IntegerComponent.class);
        entitySerializer = new EntitySerializer(entityManager);
        componentLibrary = entityManager.getComponentLibrary();

        PrefabData prefabData = new PrefabData();
        prefabData.addComponent(new StringComponent("Value"));
        prefab = Assets.generateAsset(new AssetUri(AssetType.PREFAB, "test:Test"), prefabData, Prefab.class);
View Full Code Here

    private TIntSet nonPersistentIds = new TIntHashSet();

    public GlobalStoreSaver(EngineEntityManager entityManager, PrefabSerializer prefabSerializer) {
        this.entityManager = entityManager;
        this.store = EntityData.GlobalStore.newBuilder();
        this.entitySerializer = new EntitySerializer(entityManager);

        Map<Class<? extends Component>, Integer> componentIdTable = Maps.newHashMap();
        for (ComponentMetadata<?> componentMetadata : entityManager.getComponentLibrary().iterateComponentMetadata()) {
            store.addComponentClass(componentMetadata.getUri().toString());
            componentIdTable.put(componentMetadata.getType(), componentIdTable.size());
View Full Code Here

        }
        for (EntityData.Entity entity : store.getEntityList()) {
            validRefs.add(entity.getId());
        }

        EntitySerializer serializer = new EntitySerializer(entityManager);
        EntityRefTypeHandler.setReferenceInterceptor(this);
        Map<Class<? extends Component>, Integer> idMap = Maps.newHashMap();
        for (int i = 0; i < store.getComponentClassCount(); ++i) {
            ComponentMetadata<?> metadata = entityManager.getComponentLibrary().resolve(store.getComponentClass(i));
            if (metadata != null) {
                idMap.put(metadata.getType(), i);
            }
        }
        serializer.setComponentIdMapping(idMap);
        for (EntityData.Entity entity : store.getEntityList()) {
            serializer.deserialize(entity);
        }
        EntityRefTypeHandler.setReferenceInterceptor(null);

        Map<String, EntityRef> namedEntities = Maps.newHashMap();
        for (int i = 0; i < store.getEntityNameCount() && i < store.getEntityNamedCount(); ++i) {
View Full Code Here

TOP

Related Classes of org.terasology.persistence.serializers.EntitySerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.