Search in sources :

Example 6 with ComponentLibrary

use of org.terasology.entitySystem.metadata.ComponentLibrary in project Terasology by MovingBlocks.

the class PrefabTest method setup.

@Before
public void setup() throws Exception {
    ContextImpl context = new ContextImpl();
    CoreRegistry.setContext(context);
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManager();
    assetTypeManager.registerCoreAssetType(Prefab.class, (AssetFactory<Prefab, PrefabData>) PojoPrefab::new, "prefabs");
    ComponentLibrary componentLibrary = context.get(ComponentLibrary.class);
    TypeSerializationLibrary typeSerializationLibrary = context.get(TypeSerializationLibrary.class);
    PrefabFormat prefabFormat = new PrefabFormat(componentLibrary, typeSerializationLibrary);
    assetTypeManager.registerCoreFormat(Prefab.class, prefabFormat);
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    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) NetworkSystem(org.terasology.network.NetworkSystem) ComponentLibrary(org.terasology.entitySystem.metadata.ComponentLibrary) PrefabFormat(org.terasology.entitySystem.prefab.internal.PrefabFormat) TypeSerializationLibrary(org.terasology.persistence.typeHandling.TypeSerializationLibrary) ContextImpl(org.terasology.context.internal.ContextImpl) ModuleManager(org.terasology.engine.module.ModuleManager) Prefab(org.terasology.entitySystem.prefab.Prefab) PojoPrefab(org.terasology.entitySystem.prefab.internal.PojoPrefab) Before(org.junit.Before)

Aggregations

ComponentLibrary (org.terasology.entitySystem.metadata.ComponentLibrary)6 TypeSerializationLibrary (org.terasology.persistence.typeHandling.TypeSerializationLibrary)3 Before (org.junit.Before)2 ModuleAwareAssetTypeManager (org.terasology.assets.module.ModuleAwareAssetTypeManager)2 ContextImpl (org.terasology.context.internal.ContextImpl)2 ModuleManager (org.terasology.engine.module.ModuleManager)2 Component (org.terasology.entitySystem.Component)2 EntitySystemLibrary (org.terasology.entitySystem.metadata.EntitySystemLibrary)2 PrefabFormat (org.terasology.entitySystem.prefab.internal.PrefabFormat)2 NetworkSystem (org.terasology.network.NetworkSystem)2 Field (java.lang.reflect.Field)1 SimpleUri (org.terasology.engine.SimpleUri)1 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)1 Prefab (org.terasology.entitySystem.prefab.Prefab)1 PrefabData (org.terasology.entitySystem.prefab.PrefabData)1 PojoPrefab (org.terasology.entitySystem.prefab.internal.PojoPrefab)1 PojoPrefabManager (org.terasology.entitySystem.prefab.internal.PojoPrefabManager)1 PrefabDeltaFormat (org.terasology.entitySystem.prefab.internal.PrefabDeltaFormat)1 ComponentSerializer (org.terasology.persistence.serializers.ComponentSerializer)1 CollisionGroupTypeHandler (org.terasology.persistence.typeHandling.extensionTypes.CollisionGroupTypeHandler)1