Package org.terasology.entitySystem.prefab

Examples of org.terasology.entitySystem.prefab.PrefabData


        }
        return result;
    }

    private Prefab createPrefab(EntityData.Prefab prefabData) {
        PrefabData protoPrefab = prefabSerializer.deserialize(prefabData);
        Prefab prefab = Assets.generateAsset(new AssetUri(AssetType.PREFAB, prefabData.getName()), protoPrefab, Prefab.class);
        return prefab;
    }
View Full Code Here


        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

     * @param
     * @return The deserialized prefab
     */
    public PrefabData deserialize(EntityData.Prefab prefabData, List<EntityData.Prefab> deltas) {
        Module context = ModuleContext.getContext();
        PrefabData result = new PrefabData();
        deserializeCommonData(prefabData, result);
        for (EntityData.Prefab delta : deltas) {
            applyCommonDataDelta(delta, result);
        }

View Full Code Here


    private void createPrefab(EntityData.Prefab prefabData) {
        SimpleUri uri = new SimpleUri(prefabData.getName());
        try (ModuleContext.ContextSpan ignored = ModuleContext.setContext(moduleManager.getEnvironment().get(uri.getModuleName()))) {
            PrefabData protoPrefab = prefabSerializer.deserialize(prefabData);
            Assets.generateAsset(new AssetUri(AssetType.PREFAB, prefabData.getName()), protoPrefab, Prefab.class);
        } catch (Exception e) {
            logger.error("Failed to create prefab {}", prefabData.getName());
        }
View Full Code Here

        plainBlock = new Block();
        blockManager.addBlockFamily(new SymmetricFamily(new BlockUri("test:plainBlock"), plainBlock), true);

        blockWithString = new Block();
        PrefabData prefabData = new PrefabData();
        prefabData.addComponent(new StringComponent("Test"));
        Assets.generateAsset(new AssetUri(AssetType.PREFAB, "test:prefabWithString"), prefabData, Prefab.class);
        blockWithString.setPrefab("test:prefabWithString");
        blockManager.addBlockFamily(new SymmetricFamily(new BlockUri("test:blockWithString"), blockWithString), true);

        blockWithDifferentString = new Block();
        prefabData = new PrefabData();
        prefabData.addComponent(new StringComponent("Test2"));
        Assets.generateAsset(
                new AssetUri(AssetType.PREFAB, "test:prefabWithDifferentString"), prefabData, Prefab.class);
        blockWithDifferentString.setPrefab("test:prefabWithDifferentString");
        blockManager.addBlockFamily(new SymmetricFamily(new BlockUri("test:blockWithDifferentString"), blockWithDifferentString), true);

        blockWithRetainedComponent = new Block();
        prefabData = new PrefabData();
        prefabData.addComponent(new RetainedOnBlockChangeComponent(3));
        Assets.generateAsset(
                new AssetUri(AssetType.PREFAB, "test:prefabWithRetainedComponent"), prefabData, Prefab.class);
        blockWithRetainedComponent.setPrefab("test:prefabWithRetainedComponent");
        blockManager.addBlockFamily(new SymmetricFamily(new BlockUri("test:blockWithRetainedComponent"), blockWithRetainedComponent), true);
View Full Code Here

    public void setup() {
        EntitySystemBuilder builder = new EntitySystemBuilder();

        entityManager = (PojoEntityManager) builder.build(moduleManager.getEnvironment(), mock(NetworkSystem.class), new ReflectionReflectFactory());

        PrefabData protoPrefab = new PrefabData();
        protoPrefab.addComponent(new StringComponent("Test"));
        prefab = Assets.generateAsset(new AssetUri(AssetType.PREFAB, "unittest:myprefab"), protoPrefab, Prefab.class);
    }
View Full Code Here

        assertFalse(test1.getComponent(StringComponent.class) == (test2.getComponent(StringComponent.class)));
    }

    @Test
    public void prefabPersistedRetainedCorrectly() {
        PrefabData protoPrefab = new PrefabData();
        protoPrefab.setPersisted(false);
        prefab = Assets.generateAsset(new AssetUri(AssetType.PREFAB, "unittest:nonpersistentPrefab"), protoPrefab, Prefab.class);

        EntityRef entity1 = entityManager.create(prefab);
        assertFalse(entity1.isPersistent());
    }
View Full Code Here

        assertNull(prefabManager.getPrefab(PREFAB_NAME));
    }

    @Test
    public void retrievePrefab() {
        PrefabData data = new PrefabData();
        data.addComponent(new StringComponent("Test"));
        Prefab prefab = Assets.generateAsset(new AssetUri(AssetType.PREFAB, PREFAB_NAME), data, Prefab.class);
        Prefab ref = prefabManager.getPrefab(PREFAB_NAME);
        assertNotNull(ref);
        assertEquals(PREFAB_NAME, ref.getName());
    }
View Full Code Here

TOP

Related Classes of org.terasology.entitySystem.prefab.PrefabData

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.