Search in sources :

Example 11 with ModuleAwareAssetTypeManager

use of org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.

the class PojoEntityPoolTest method setupClass.

@BeforeAll
public static void setupClass() throws Exception {
    context = new ContextImpl();
    ModuleManager moduleManager = ModuleManagerFactory.create();
    context.put(ModuleManager.class, moduleManager);
    ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
    assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
    assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
    context.put(AssetManager.class, assetTypeManager.getAssetManager());
    context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
    CoreRegistry.setContext(context);
}
Also used : PojoPrefab(org.terasology.engine.entitySystem.prefab.internal.PojoPrefab) ModuleAwareAssetTypeManager(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager) ModuleAwareAssetTypeManagerImpl(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManagerImpl) RecordAndReplayCurrentStatus(org.terasology.engine.recording.RecordAndReplayCurrentStatus) ContextImpl(org.terasology.engine.context.internal.ContextImpl) ModuleManager(org.terasology.engine.core.module.ModuleManager) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 12 with ModuleAwareAssetTypeManager

use of org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.

the class EnvironmentSwitchHandler method cheapAssetManagerUpdate.

/**
 * Switches the environment of the asset manager to the specified one. It does not register the prefab formats
 * as they require a proper ComponentLibrary.
 *
 * The existence of this method call is questionable. It has only be introduced to make sure that
 * the asset type manager has never prefab formats that reference an old ComponentLibrary.
 */
private void cheapAssetManagerUpdate(Context context, ModuleEnvironment environment) {
    ModuleAwareAssetTypeManager moduleAwareAssetTypeManager = context.get(ModuleAwareAssetTypeManager.class);
    unregisterPrefabFormats(moduleAwareAssetTypeManager);
    moduleAwareAssetTypeManager.switchEnvironment(environment);
}
Also used : ModuleAwareAssetTypeManager(org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager)

Aggregations

ModuleAwareAssetTypeManager (org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager)12 ModuleAwareAssetTypeManagerImpl (org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManagerImpl)8 ModuleManager (org.terasology.engine.core.module.ModuleManager)7 PojoPrefab (org.terasology.engine.entitySystem.prefab.internal.PojoPrefab)7 ContextImpl (org.terasology.engine.context.internal.ContextImpl)6 RecordAndReplayCurrentStatus (org.terasology.engine.recording.RecordAndReplayCurrentStatus)6 BeforeAll (org.junit.jupiter.api.BeforeAll)4 Context (org.terasology.engine.context.Context)3 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 RenderingSubsystemFactory (org.terasology.engine.core.subsystem.RenderingSubsystemFactory)2 ComponentLibrary (org.terasology.engine.entitySystem.metadata.ComponentLibrary)2 PojoPrefabManager (org.terasology.engine.entitySystem.prefab.internal.PojoPrefabManager)2 PrefabFormat (org.terasology.engine.entitySystem.prefab.internal.PrefabFormat)2 MeshAnimation (org.terasology.engine.rendering.assets.animation.MeshAnimation)2 MeshAnimationImpl (org.terasology.engine.rendering.assets.animation.MeshAnimationImpl)2 Atlas (org.terasology.engine.rendering.assets.atlas.Atlas)2 Font (org.terasology.engine.rendering.assets.font.Font)2 FontImpl (org.terasology.engine.rendering.assets.font.FontImpl)2 Material (org.terasology.engine.rendering.assets.material.Material)2