private void initManagers() { SplashScreen.getInstance().post("Loading modules ..."); ModuleManager moduleManager = CoreRegistry.putPermanently(ModuleManager.class, new ModuleManagerImpl()); SplashScreen.getInstance().post("Loading reflections ..."); ReflectFactory reflectFactory = CoreRegistry.putPermanently(ReflectFactory.class, new ReflectionReflectFactory()); CopyStrategyLibrary copyStrategyLibrary = CoreRegistry.putPermanently( CopyStrategyLibrary.class, new CopyStrategyLibrary(reflectFactory)); CoreRegistry.putPermanently( TypeSerializationLibrary.class, new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary)); SplashScreen.getInstance().post("Loading assets ..."); AssetManager assetManager = CoreRegistry.putPermanently( AssetManager.class, new AssetManagerImpl(moduleManager.getEnvironment())); assetManager.setEnvironment(moduleManager.getEnvironment()); CoreRegistry.putPermanently(CollisionGroupManager.class, new CollisionGroupManager()); CoreRegistry.putPermanently(WorldGeneratorManager.class, new WorldGeneratorManager()); CoreRegistry.putPermanently(ComponentSystemManager.class, new ComponentSystemManager()); CoreRegistry.putPermanently( ParameterAdapterManager.class, ParameterAdapterManager.createCore()); CoreRegistry.putPermanently(NetworkSystem.class, new NetworkSystemImpl(time)); CoreRegistry.putPermanently(Game.class, new Game(this, time)); assetManager.setEnvironment(moduleManager.getEnvironment()); AssetType.registerAssetTypes(assetManager); ApplyModulesUtil.applyModules(); }
@Override protected void setupAssetManager() { setupEmptyAssetManager(); AssetManager assetManager = CoreRegistry.get(AssetManager.class); AudioManager audioManager = CoreRegistry.get(AudioManager.class); AssetType.registerAssetTypes(assetManager); CodeSource tsCodeSource = TerasologyEngine.class.getProtectionDomain().getCodeSource(); assetManager.addAssetSource( new ClasspathSource( TerasologyConstants.ENGINE_MODULE, tsCodeSource, TerasologyConstants.ASSETS_SUBDIRECTORY, TerasologyConstants.OVERRIDES_SUBDIRECTORY)); CodeSource thisCodeSource = HeadlessEnvironment.class.getProtectionDomain().getCodeSource(); assetManager.addAssetSource( new ClasspathSource( "unittest", thisCodeSource, TerasologyConstants.ASSETS_SUBDIRECTORY, TerasologyConstants.OVERRIDES_SUBDIRECTORY)); assetManager.setAssetFactory( AssetType.PREFAB, new AssetFactory<PrefabData, Prefab>() { @Override public Prefab buildAsset(AssetUri uri, PrefabData data) { return new PojoPrefab(uri, data); } }); assetManager.setAssetFactory( AssetType.SHAPE, new AssetFactory<BlockShapeData, BlockShape>() { @Override public BlockShape buildAsset(AssetUri uri, BlockShapeData data) { return new BlockShapeImpl(uri, data); } }); assetManager.setAssetFactory( AssetType.UI_SKIN, new AssetFactory<UISkinData, UISkin>() { @Override public UISkin buildAsset(AssetUri uri, UISkinData data) { return new UISkin(uri, data); } }); assetManager.setAssetFactory(AssetType.SOUND, audioManager.getStaticSoundFactory()); assetManager.setAssetFactory(AssetType.MUSIC, audioManager.getStreamingSoundFactory()); }
@Override protected void setupEmptyAssetManager() { ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class); AssetManager assetManager = new AssetManager(moduleManager); // mock an empy asset factory for all asset types for (AssetType type : AssetType.values()) { assetManager.setAssetFactory(type, mock(AssetFactory.class)); } CoreRegistry.put(AssetManager.class, assetManager); }