use of org.terasology.engine.entitySystem.prefab.PrefabData in project Terasology by MovingBlocks.
the class PojoEntityManagerTest method testPrefabPersistedRetainedCorrectly.
@Test
public void testPrefabPersistedRetainedCorrectly() {
PrefabData protoPrefab = new PrefabData();
protoPrefab.setPersisted(false);
prefab = Assets.generateAsset(new ResourceUrn("unittest:nonpersistentPrefab"), protoPrefab, Prefab.class);
EntityRef entity1 = entityManager.create(prefab);
assertFalse(entity1.isPersistent());
}
use of org.terasology.engine.entitySystem.prefab.PrefabData in project Terasology by MovingBlocks.
the class PojoPrefabManagerTest method testRetrievePrefab.
@Test
public void testRetrievePrefab() {
PrefabData data = new PrefabData();
data.addComponent(new StringComponent("Test"));
Assets.generateAsset(new ResourceUrn(PREFAB_NAME), data, Prefab.class);
Prefab ref = prefabManager.getPrefab(PREFAB_NAME);
assertNotNull(ref);
assertEquals(PREFAB_NAME, ref.getName());
}
use of org.terasology.engine.entitySystem.prefab.PrefabData in project Terasology by MovingBlocks.
the class EntityAwareWorldProviderTest method createPrefabWithString.
private Prefab createPrefabWithString(String urn, String text, AssetManager assetManager) {
PrefabData prefabData = new PrefabData();
prefabData.addComponent(new StringComponent(text));
return assetManager.loadAsset(new ResourceUrn(urn), prefabData, Prefab.class);
}
use of org.terasology.engine.entitySystem.prefab.PrefabData in project Terasology by MovingBlocks.
the class PrefabSerializer method deserialize.
/**
* Deserializes a prefab
*
* @param prefabData
* @param deltas
* @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);
}
addInheritedComponents(result);
applyComponentChanges(context, prefabData, result);
for (EntityData.Prefab delta : deltas) {
applyComponentChanges(context, delta, result);
}
return result;
}
Aggregations