Search in sources :

Example 1 with AssetManager

use of org.terasology.assets.management.AssetManager in project Terasology by MovingBlocks.

the class ShaderManagerLwjgl method recompileAllShaders.

@Override
public void recompileAllShaders() {
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    assetManager.getLoadedAssets(Shader.class).forEach(Shader::recompile);
    assetManager.getLoadedAssets(Material.class).forEach(Material::recompile);
    activeMaterial = null;
}
Also used : AssetManager(org.terasology.assets.management.AssetManager) Material(org.terasology.rendering.assets.material.Material) GLSLMaterial(org.terasology.rendering.opengl.GLSLMaterial) Shader(org.terasology.rendering.assets.shader.Shader)

Example 2 with AssetManager

use of org.terasology.assets.management.AssetManager in project Terasology by MovingBlocks.

the class BlockShapeTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager);
    CoreRegistry.put(BlockManager.class, blockManager);
    this.assetManager = assetManager;
}
Also used : AssetManager(org.terasology.assets.management.AssetManager) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) Before(org.junit.Before)

Example 3 with AssetManager

use of org.terasology.assets.management.AssetManager in project Terasology by MovingBlocks.

the class BulkLightPropagationTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    lightRules = new LightPropagationRules();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    BlockFamilyDefinitionData fullLightData = new BlockFamilyDefinitionData();
    fullLightData.getBaseSection().setDisplayName("Torch");
    fullLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    fullLightData.getBaseSection().setLuminance(ChunkConstants.MAX_LIGHT);
    fullLightData.getBaseSection().setTranslucent(true);
    fullLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:torch"), fullLightData, BlockFamilyDefinition.class);
    fullLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:torch")));
    BlockFamilyDefinitionData weakLightData = new BlockFamilyDefinitionData();
    weakLightData.getBaseSection().setDisplayName("PartLight");
    weakLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    weakLightData.getBaseSection().setLuminance((byte) 2);
    weakLightData.getBaseSection().setTranslucent(true);
    weakLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:weakLight"), weakLightData, BlockFamilyDefinition.class);
    weakLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:weakLight")));
    BlockFamilyDefinitionData mediumLightData = new BlockFamilyDefinitionData();
    mediumLightData.getBaseSection().setDisplayName("MediumLight");
    mediumLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    mediumLightData.getBaseSection().setLuminance((byte) 5);
    mediumLightData.getBaseSection().setTranslucent(true);
    mediumLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:mediumLight"), mediumLightData, BlockFamilyDefinition.class);
    mediumLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:mediumLight")));
    BlockFamilyDefinitionData solidData = new BlockFamilyDefinitionData();
    solidData.getBaseSection().setDisplayName("Stone");
    solidData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidData.getBaseSection().setTranslucent(false);
    solidData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:stone"), solidData, BlockFamilyDefinition.class);
    solid = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
    BlockFamilyDefinitionData solidMediumLightData = new BlockFamilyDefinitionData();
    solidMediumLightData.getBaseSection().setDisplayName("SolidMediumLight");
    solidMediumLightData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidMediumLightData.getBaseSection().setTranslucent(false);
    solidMediumLightData.getBaseSection().setLuminance((byte) 5);
    solidMediumLightData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:solidMediumLight"), solidMediumLightData, BlockFamilyDefinition.class);
    solidMediumLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:solidMediumLight")));
    air = blockManager.getBlock(BlockManager.AIR_ID);
}
Also used : LightPropagationRules(org.terasology.world.propagation.light.LightPropagationRules) BlockUri(org.terasology.world.block.BlockUri) AssetManager(org.terasology.assets.management.AssetManager) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) ResourceUrn(org.terasology.assets.ResourceUrn) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) Before(org.junit.Before)

Example 4 with AssetManager

use of org.terasology.assets.management.AssetManager in project Terasology by MovingBlocks.

the class BulkSunlightPropagationTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    regenRules = new SunlightRegenPropagationRules();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    CoreRegistry.put(BlockManager.class, blockManager);
    BlockFamilyDefinitionData solidData = new BlockFamilyDefinitionData();
    solidData.getBaseSection().setDisplayName("Stone");
    solidData.getBaseSection().setShape(assetManager.getAsset("engine:cube", BlockShape.class).get());
    solidData.getBaseSection().setTranslucent(false);
    solidData.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:stone"), solidData, BlockFamilyDefinition.class);
    solid = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
    air = blockManager.getBlock(BlockManager.AIR_ID);
    Map<Vector3i, Block> blockData = Maps.newHashMap();
    regenWorldView = new StubPropagatorWorldView(ChunkConstants.CHUNK_REGION, air, blockData);
    lightWorldView = new StubPropagatorWorldView(ChunkConstants.CHUNK_REGION, air, blockData);
    lightRules = new SunlightPropagationRules(regenWorldView);
    sunlightPropagator = new StandardBatchPropagator(lightRules, lightWorldView);
    propagator = new SunlightRegenBatchPropagator(regenRules, regenWorldView, sunlightPropagator, lightWorldView);
}
Also used : BlockUri(org.terasology.world.block.BlockUri) AssetManager(org.terasology.assets.management.AssetManager) SunlightPropagationRules(org.terasology.world.propagation.light.SunlightPropagationRules) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) Vector3i(org.terasology.math.geom.Vector3i) Block(org.terasology.world.block.Block) NullWorldAtlas(org.terasology.world.block.tiles.NullWorldAtlas) ResourceUrn(org.terasology.assets.ResourceUrn) SunlightRegenPropagationRules(org.terasology.world.propagation.light.SunlightRegenPropagationRules) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl) Before(org.junit.Before)

Example 5 with AssetManager

use of org.terasology.assets.management.AssetManager in project Terasology by MovingBlocks.

the class BehaviorTreeBuilder method initGson.

private void initGson() {
    if (gson == null) {
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.registerTypeHierarchyAdapter(BehaviorNode.class, this);
        gsonBuilder.registerTypeAdapterFactory(new UriTypeAdapterFactory());
        gsonBuilder.registerTypeAdapter(BehaviorTree.class, new TypeAdapter<BehaviorTree>() {

            @Override
            public void write(JsonWriter out, BehaviorTree value) throws IOException {
                if (value != null) {
                    // TODO doublecheck URN
                    out.value(value.getUrn().toString());
                } else {
                    out.value("");
                }
            }

            @Override
            public BehaviorTree read(JsonReader in) throws IOException {
                String uri = in.nextString();
                AssetManager assetManager = CoreRegistry.get(AssetManager.class);
                return assetManager.getAsset(new ResourceUrn(uri), BehaviorTree.class).orElse(assetManager.getAsset(new ResourceUrn("Behaviors:fallback"), BehaviorTree.class).get());
            }
        });
        gson = gsonBuilder.create();
    }
}
Also used : AssetManager(org.terasology.assets.management.AssetManager) GsonBuilder(com.google.gson.GsonBuilder) UriTypeAdapterFactory(org.terasology.utilities.gson.UriTypeAdapterFactory) JsonReader(com.google.gson.stream.JsonReader) IOException(java.io.IOException) BehaviorTree(org.terasology.logic.behavior.asset.BehaviorTree) ResourceUrn(org.terasology.assets.ResourceUrn) JsonWriter(com.google.gson.stream.JsonWriter)

Aggregations

AssetManager (org.terasology.assets.management.AssetManager)14 Before (org.junit.Before)9 ResourceUrn (org.terasology.assets.ResourceUrn)9 BlockManagerImpl (org.terasology.world.block.internal.BlockManagerImpl)8 BlockFamilyDefinitionData (org.terasology.world.block.loader.BlockFamilyDefinitionData)8 NullWorldAtlas (org.terasology.world.block.tiles.NullWorldAtlas)8 SymmetricBlockFamilyFactory (org.terasology.world.block.family.SymmetricBlockFamilyFactory)7 BiomeManager (org.terasology.world.biomes.BiomeManager)6 BlockUri (org.terasology.world.block.BlockUri)6 BlockManager (org.terasology.world.block.BlockManager)4 FileSystem (java.nio.file.FileSystem)3 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)3 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)3 Block (org.terasology.world.block.Block)3 IOException (java.io.IOException)2 AudioManager (org.terasology.audio.AudioManager)2 Config (org.terasology.config.Config)2 Prefab (org.terasology.entitySystem.prefab.Prefab)2 PrefabData (org.terasology.entitySystem.prefab.PrefabData)2 BlockFamily (org.terasology.world.block.family.BlockFamily)2