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