Search in sources :

Example 6 with CopyStrategyLibrary

use of org.terasology.reflection.copy.CopyStrategyLibrary 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)

Aggregations

CopyStrategyLibrary (org.terasology.reflection.copy.CopyStrategyLibrary)6 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)5 ReflectFactory (org.terasology.reflection.reflect.ReflectFactory)5 EntitySystemLibrary (org.terasology.entitySystem.metadata.EntitySystemLibrary)4 ReflectionReflectFactory (org.terasology.reflection.reflect.ReflectionReflectFactory)4 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)3 ModuleManager (org.terasology.engine.module.ModuleManager)3 Before (org.junit.Before)2 ContextImpl (org.terasology.context.internal.ContextImpl)2 PojoPrefabManager (org.terasology.entitySystem.prefab.internal.PojoPrefabManager)2 Annotation (java.lang.annotation.Annotation)1 Field (java.lang.reflect.Field)1 Config (org.terasology.config.Config)1 SimpleUri (org.terasology.engine.SimpleUri)1 ModuleManagerImpl (org.terasology.engine.module.ModuleManagerImpl)1 PojoEntityManager (org.terasology.entitySystem.entity.internal.PojoEntityManager)1 EventSystemImpl (org.terasology.entitySystem.event.internal.EventSystemImpl)1 ComponentLibrary (org.terasology.entitySystem.metadata.ComponentLibrary)1 Prefab (org.terasology.entitySystem.prefab.Prefab)1 PrefabData (org.terasology.entitySystem.prefab.PrefabData)1