Search in sources :

Example 11 with TypeSerializationLibrary

use of org.terasology.persistence.typeHandling.TypeSerializationLibrary in project Terasology by MovingBlocks.

the class PojoPrefabManagerTest method setup.

@Before
public void setup() throws Exception {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ModuleManager moduleManager = ModuleManagerFactory.create();
    ReflectFactory reflectFactory = new ReflectionReflectFactory();
    CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
    TypeSerializationLibrary lib = new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary);
    lib.add(Vector3f.class, new Vector3fTypeHandler());
    lib.add(Quat4f.class, new Quat4fTypeHandler());
    entitySystemLibrary = new EntitySystemLibrary(context, lib);
    componentLibrary = entitySystemLibrary.getComponentLibrary();
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    prefabManager = new PojoPrefabManager(context);
}
Also used : PojoPrefabManager(org.terasology.entitySystem.prefab.internal.PojoPrefabManager) PrefabData(org.terasology.entitySystem.prefab.PrefabData) ModuleAwareAssetTypeManager(org.terasology.assets.module.ModuleAwareAssetTypeManager) CopyStrategyLibrary(org.terasology.reflection.copy.CopyStrategyLibrary) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectionReflectFactory(org.terasology.reflection.reflect.ReflectionReflectFactory) ReflectFactory(org.terasology.reflection.reflect.ReflectFactory) Vector3fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Vector3fTypeHandler) EntitySystemLibrary(org.terasology.entitySystem.metadata.EntitySystemLibrary) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) Quat4fTypeHandler(org.terasology.persistence.typeHandling.mathTypes.Quat4fTypeHandler) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Before(org.junit.Before)

Example 12 with TypeSerializationLibrary

use of org.terasology.persistence.typeHandling.TypeSerializationLibrary in project Terasology by MovingBlocks.

the class ComponentMetadataTest method testStaticFieldsIgnored.

@Test
public void testStaticFieldsIgnored() {
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeSerializationLibrary(reflectFactory, copyStrategies));
    ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
    lib.register(new SimpleUri("unittest:string"), StringComponent.class);
    ComponentMetadata<StringComponent> metadata = lib.getMetadata(StringComponent.class);
    assertNull(metadata.getField("STATIC_VALUE"));
}
Also used : StringComponent(org.terasology.entitySystem.stubs.StringComponent) SimpleUri(org.terasology.engine.SimpleUri) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) Test(org.junit.Test)

Example 13 with TypeSerializationLibrary

use of org.terasology.persistence.typeHandling.TypeSerializationLibrary in project Terasology by MovingBlocks.

the class ComponentMetadataTest method testOwnsReferencesPopulated.

@Test
public void testOwnsReferencesPopulated() {
    EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(context, new TypeSerializationLibrary(reflectFactory, copyStrategies));
    ComponentLibrary lib = entitySystemLibrary.getComponentLibrary();
    lib.register(new SimpleUri("unittest:owner"), OwnerComponent.class);
    ComponentMetadata<OwnerComponent> metadata = lib.getMetadata(OwnerComponent.class);
    assertTrue(metadata.isReferenceOwner());
}
Also used : OwnerComponent(org.terasology.entitySystem.stubs.OwnerComponent) SimpleUri(org.terasology.engine.SimpleUri) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) Test(org.junit.Test)

Aggregations

TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)13 ModuleManager (org.terasology.engine.module.ModuleManager)5 EntitySystemLibrary (org.terasology.entitySystem.metadata.EntitySystemLibrary)5 CopyStrategyLibrary (org.terasology.reflection.copy.CopyStrategyLibrary)5 Before (org.junit.Before)4 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)4 ContextImpl (org.terasology.context.internal.ContextImpl)4 PojoPrefabManager (org.terasology.entitySystem.prefab.internal.PojoPrefabManager)4 NetworkSystem (org.terasology.network.NetworkSystem)4 ReflectFactory (org.terasology.reflection.reflect.ReflectFactory)4 ReflectionReflectFactory (org.terasology.reflection.reflect.ReflectionReflectFactory)4 SimpleUri (org.terasology.engine.SimpleUri)3 ComponentLibrary (org.terasology.entitySystem.metadata.ComponentLibrary)3 Test (org.junit.Test)2 PojoEntityManager (org.terasology.entitySystem.entity.internal.PojoEntityManager)2 EventSystemImpl (org.terasology.entitySystem.event.internal.EventSystemImpl)2 Prefab (org.terasology.entitySystem.prefab.Prefab)2 PrefabData (org.terasology.entitySystem.prefab.PrefabData)2 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)2 PrefabFormat (org.terasology.entitySystem.prefab.internal.PrefabFormat)2