use of org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.
the class LwjglGraphicsManager method registerCoreAssetTypes.
public void registerCoreAssetTypes(ModuleAwareAssetTypeManager assetTypeManager) {
// cast lambdas explicitly to avoid inconsistent compiler behavior wrt. type inference
assetTypeManager.createAssetType(Font.class, FontImpl::new, "fonts");
AssetType<Texture, TextureData> texture = assetTypeManager.createAssetType(Texture.class, (urn, assetType, data) -> (OpenGLTexture.create(urn, assetType, data, this)), "textures", "fonts");
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> {
if (path.getPath().get(0).equals(ModuleAssetScanner.OVERRIDE_FOLDER)) {
return path.getPath().get(2).equals("textures");
} else {
return path.getPath().get(1).equals("textures");
}
}));
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> {
if (path.getPath().get(0).equals(ModuleAssetScanner.OVERRIDE_FOLDER)) {
return path.getPath().get(2).equals("fonts");
} else {
return path.getPath().get(1).equals("fonts");
}
}));
assetTypeManager.createAssetType(Shader.class, (urn, assetType, data) -> GLSLShader.create(urn, assetType, data, this), "shaders");
assetTypeManager.createAssetType(Material.class, (urn, assetType, data) -> GLSLMaterial.create(urn, this, assetType, data), "materials");
assetTypeManager.createAssetType(Mesh.class, (urn, assetType, data) -> OpenGLMesh.create(urn, assetType, data, this), "mesh");
assetTypeManager.createAssetType(SkeletalMesh.class, (urn, assetType, data) -> OpenGLSkeletalMesh.create(urn, assetType, data, this), "skeletalMesh");
assetTypeManager.createAssetType(MeshAnimation.class, MeshAnimationImpl::new, "animations", "skeletalMesh");
assetTypeManager.createAssetType(Atlas.class, Atlas::new, "atlas");
assetTypeManager.createAssetType(MeshAnimationBundle.class, MeshAnimationBundle::new, "skeletalMesh", "animations");
assetTypeManager.createAssetType(Subtexture.class, Subtexture::new);
}
use of org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.
the class HeadlessGraphics method registerCoreAssetTypes.
@Override
public void registerCoreAssetTypes(ModuleAwareAssetTypeManager assetTypeManager) {
assetTypeManager.createAssetType(Font.class, FontImpl::new, "fonts");
AssetType<Texture, TextureData> texture = assetTypeManager.createAssetType(Texture.class, (urn, assetType, data) -> new HeadlessTexture(urn, assetType, data, new HeadlessTexture.DisposalAction()), "textures", "fonts");
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getPath().get(1).equals("textures")));
assetTypeManager.getAssetFileDataProducer(texture).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getPath().get(1).equals("fonts")));
assetTypeManager.createAssetType(Shader.class, HeadlessShader::new, "shaders");
assetTypeManager.createAssetType(Material.class, HeadlessMaterial::new, "materials");
assetTypeManager.createAssetType(Mesh.class, HeadlessMesh::new, "mesh");
assetTypeManager.createAssetType(SkeletalMesh.class, HeadlessSkeletalMesh::new, "skeletalMesh");
assetTypeManager.createAssetType(MeshAnimation.class, MeshAnimationImpl::new, "animations");
assetTypeManager.createAssetType(Atlas.class, Atlas::new, "atlas");
assetTypeManager.createAssetType(Subtexture.class, Subtexture::new);
}
use of org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.
the class EntitySerializerTest method setupClass.
@BeforeAll
public static void setupClass() throws Exception {
context = new ContextImpl();
CoreRegistry.setContext(context);
context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
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());
}
use of org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.
the class BaseEntityRefTest 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);
}
use of org.terasology.gestalt.assets.module.ModuleAwareAssetTypeManager in project Terasology by MovingBlocks.
the class HeadlessEnvironment method setupAssetManager.
@Override
protected AssetManager setupAssetManager() {
ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
// cast lambdas explicitly to avoid inconsistent compiler behavior wrt. type inference
assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
assetTypeManager.createAssetType(BlockShape.class, BlockShapeImpl::new, "shapes");
assetTypeManager.createAssetType(BlockSounds.class, BlockSounds::new, "blockSounds");
assetTypeManager.createAssetType(BlockTile.class, BlockTile::new, "blockTiles");
AssetType<BlockFamilyDefinition, BlockFamilyDefinitionData> blockFamilyDefinitionDataAssetType = assetTypeManager.createAssetType(BlockFamilyDefinition.class, BlockFamilyDefinition::new, "blocks");
assetTypeManager.getAssetFileDataProducer(blockFamilyDefinitionDataAssetType).addAssetFormat(new BlockFamilyDefinitionFormat(assetTypeManager.getAssetManager()));
assetTypeManager.createAssetType(StaticSound.class, NullSound::new, "sounds");
assetTypeManager.createAssetType(StreamingSound.class, NullStreamingSound::new, "music");
assetTypeManager.createAssetType(UISkinAsset.class, UISkinAsset::new, "skins");
assetTypeManager.createAssetType(BehaviorTree.class, BehaviorTree::new, "behaviors");
assetTypeManager.createAssetType(UIElement.class, UIElement::new, "ui");
assetTypeManager.createAssetType(Font.class, FontImpl::new, "fonts");
AssetType<Texture, TextureData> textureDataAssetType = assetTypeManager.createAssetType(Texture.class, HeadlessTexture::create, "textures", "fonts");
assetTypeManager.getAssetFileDataProducer(textureDataAssetType).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.NEAREST, path -> path.getPath().get(1).equals("textures")));
assetTypeManager.getAssetFileDataProducer(textureDataAssetType).addAssetFormat(new PNGTextureFormat(Texture.FilterMode.LINEAR, path -> path.getPath().get(1).equals("fonts")));
assetTypeManager.createAssetType(Shader.class, HeadlessShader::new, "shaders");
assetTypeManager.createAssetType(Material.class, HeadlessMaterial::new, "materials");
assetTypeManager.createAssetType(Mesh.class, HeadlessMesh::new, "mesh");
assetTypeManager.createAssetType(SkeletalMesh.class, HeadlessSkeletalMesh::new, "skeletalMesh");
assetTypeManager.createAssetType(MeshAnimation.class, MeshAnimationImpl::new, "animations");
assetTypeManager.createAssetType(Atlas.class, Atlas::new, "atlas");
assetTypeManager.createAssetType(Subtexture.class, Subtexture::new);
assetTypeManager.switchEnvironment(context.get(ModuleManager.class).getEnvironment());
context.put(ModuleAwareAssetTypeManager.class, assetTypeManager);
context.put(AssetManager.class, assetTypeManager.getAssetManager());
return assetTypeManager.getAssetManager();
}
Aggregations