Search in sources :

Example 6 with AssetManager

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

the class StorageManagerTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class);
    FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive);
    PathManager.getInstance().useOverrideHomePath(temporaryFolder.getRoot().toPath());
    savePath = PathManager.getInstance().getSavePath("testSave");
    assert !Files.isRegularFile(vfs.getPath("global.dat"));
    entityManager = context.get(EngineEntityManager.class);
    moduleEnvironment = context.get(ModuleEnvironment.class);
    blockManager = context.get(BlockManager.class);
    biomeManager = context.get(BiomeManager.class);
    esm = new ReadWriteStorageManager(savePath, moduleEnvironment, entityManager, blockManager, biomeManager, false);
    context.put(StorageManager.class, esm);
    this.character = entityManager.create();
    Client client = createClientMock(PLAYER_ID, character);
    NetworkSystem networkSystem = mock(NetworkSystem.class);
    when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
    when(networkSystem.getPlayers()).thenReturn(Arrays.asList(client));
    context.put(NetworkSystem.class, networkSystem);
    AssetManager assetManager = context.get(AssetManager.class);
    BlockFamilyDefinitionData data = new BlockFamilyDefinitionData();
    data.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("test:testblock"), data, BlockFamilyDefinition.class);
    assetManager.loadAsset(new ResourceUrn("test:testblock2"), data, BlockFamilyDefinition.class);
    testBlock = context.get(BlockManager.class).getBlock("test:testblock");
    testBlock2 = context.get(BlockManager.class).getBlock("test:testblock2");
    context.put(ChunkProvider.class, mock(ChunkProvider.class));
    BiomeManager mockBiomeManager = mock(BiomeManager.class);
    when(mockBiomeManager.getBiomes()).thenReturn(Collections.<Biome>emptyList());
    context.put(BiomeManager.class, mockBiomeManager);
    WorldProvider worldProvider = mock(WorldProvider.class);
    when(worldProvider.getWorldInfo()).thenReturn(new WorldInfo());
    context.put(WorldProvider.class, worldProvider);
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) BiomeManager(org.terasology.world.biomes.BiomeManager) AssetManager(org.terasology.assets.management.AssetManager) NetworkSystem(org.terasology.network.NetworkSystem) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) ModuleEnvironment(org.terasology.module.ModuleEnvironment) BlockManager(org.terasology.world.block.BlockManager) FileSystem(java.nio.file.FileSystem) WorldProvider(org.terasology.world.WorldProvider) WorldInfo(org.terasology.world.internal.WorldInfo) Client(org.terasology.network.Client) ResourceUrn(org.terasology.assets.ResourceUrn) ChunkProvider(org.terasology.world.chunks.ChunkProvider) SymmetricBlockFamilyFactory(org.terasology.world.block.family.SymmetricBlockFamilyFactory) Before(org.junit.Before)

Example 7 with AssetManager

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

the class TerasologyTestingEnvironment method setupEnvironment.

@BeforeClass
public static void setupEnvironment() throws Exception {
    final JavaArchive homeArchive = ShrinkWrap.create(JavaArchive.class);
    final FileSystem vfs = ShrinkWrapFileSystems.newFileSystem(homeArchive);
    PathManager.getInstance().useOverrideHomePath(vfs.getPath(""));
    /*
         * Create at least for each class a new headless environemnt as it is fast and prevents side effects
         * (Reusing a headless environment after other tests have modified the core registry isn't really clean)
         */
    env = new HeadlessEnvironment(new Name("engine"));
    context = env.getContext();
    assetManager = context.get(AssetManager.class);
    blockManager = context.get(BlockManager.class);
    config = context.get(Config.class);
    audioManager = context.get(AudioManager.class);
    collisionGroupManager = context.get(CollisionGroupManager.class);
    moduleManager = context.get(ModuleManager.class);
}
Also used : AudioManager(org.terasology.audio.AudioManager) AssetManager(org.terasology.assets.management.AssetManager) BlockManager(org.terasology.world.block.BlockManager) Config(org.terasology.config.Config) FileSystem(java.nio.file.FileSystem) CollisionGroupManager(org.terasology.physics.CollisionGroupManager) ModuleManager(org.terasology.engine.module.ModuleManager) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) Name(org.terasology.naming.Name) BeforeClass(org.junit.BeforeClass)

Example 8 with AssetManager

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

the class InternalLightGeneratorTest 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);
    airBlock = blockManager.getBlock(BlockManager.AIR_ID);
    biomeManager = Mockito.mock(BiomeManager.class);
    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);
    solidBlock = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:stone")));
    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.setFamilyFactory(new SymmetricBlockFamilyFactory());
    assetManager.loadAsset(new ResourceUrn("engine:torch"), fullLightData, BlockFamilyDefinition.class);
    fullLight = blockManager.getBlock(new BlockUri(new ResourceUrn("engine:torch")));
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) 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 9 with AssetManager

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

the class BetweenChunkPropagationTest method setup.

@Before
@Override
public void setup() throws Exception {
    super.setup();
    AssetManager assetManager = CoreRegistry.get(AssetManager.class);
    regenRules = new SunlightRegenPropagationRules();
    blockManager = new BlockManagerImpl(new NullWorldAtlas(), assetManager, true);
    biomeManager = Mockito.mock(BiomeManager.class);
    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")));
    regenWorldView = new SunlightRegenWorldView(provider);
    lightWorldView = new SunlightWorldView(provider);
    lightRules = new SunlightPropagationRules(regenWorldView);
    sunlightPropagator = new StandardBatchPropagator(lightRules, lightWorldView);
    propagator = new SunlightRegenBatchPropagator(regenRules, regenWorldView, sunlightPropagator, lightWorldView);
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) BlockUri(org.terasology.world.block.BlockUri) AssetManager(org.terasology.assets.management.AssetManager) SunlightRegenWorldView(org.terasology.world.propagation.light.SunlightRegenWorldView) SunlightPropagationRules(org.terasology.world.propagation.light.SunlightPropagationRules) SunlightWorldView(org.terasology.world.propagation.light.SunlightWorldView) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) 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 10 with AssetManager

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

the class ChunkTest 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);
    BiomeManager biomeManager = Mockito.mock(BiomeManager.class);
    chunk = new ChunkImpl(new Vector3i(0, 0, 0), blockManager, biomeManager);
    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")));
}
Also used : BiomeManager(org.terasology.world.biomes.BiomeManager) BlockUri(org.terasology.world.block.BlockUri) AssetManager(org.terasology.assets.management.AssetManager) BlockFamilyDefinitionData(org.terasology.world.block.loader.BlockFamilyDefinitionData) ChunkImpl(org.terasology.world.chunks.internal.ChunkImpl) Vector3i(org.terasology.math.geom.Vector3i) 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)

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