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);
}
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"));
}
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());
}
Aggregations