Search in sources :

Example 11 with BlockManager

use of org.terasology.world.block.BlockManager 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 12 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class InitialiseBlockTypeEntities method step.

@Override
public boolean step() {
    BlockManagerImpl blockManager = (BlockManagerImpl) context.get(BlockManager.class);
    blockManager.subscribe(new BlockTypeEntityGenerator(context.get(EntityManager.class), blockManager));
    return true;
}
Also used : BlockManager(org.terasology.world.block.BlockManager) BlockTypeEntityGenerator(org.terasology.world.block.typeEntity.BlockTypeEntityGenerator) BlockManagerImpl(org.terasology.world.block.internal.BlockManagerImpl)

Example 13 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class EntityAwareWorldProviderTest method setup.

@Before
public void setup() throws Exception {
    super.setup();
    GameThread.setToCurrentThread();
    this.entityManager = context.get(EngineEntityManager.class);
    AssetManager assetManager = context.get(AssetManager.class);
    BlockManager blockManager = context.get(BlockManager.class);
    airBlock = blockManager.getBlock(BlockManager.AIR_ID);
    worldStub = new WorldProviderCoreStub(airBlock, null);
    worldProvider = new EntityAwareWorldProvider(worldStub, context);
    plainBlock = createBlock("test:plainblock", assetManager, blockManager);
    prefabWithString = createPrefabWithString("test:prefabWithString", "Test", assetManager);
    blockWithString = createBlockWithPrefab("test:blockWithString", prefabWithString, false, assetManager, blockManager);
    keepActiveBlock = createBlockWithPrefab("test:keepActiveBlock", prefabWithString, true, assetManager, blockManager);
    Prefab prefabWithDifferentString = createPrefabWithString("test:prefabWithDifferentString", "Test2", assetManager);
    blockWithDifferentString = createBlockWithPrefab("test:prefabWithDifferentString", prefabWithDifferentString, false, assetManager, blockManager);
    BlockFamily blockFamily = createBlockFamily("test:blockFamily", prefabWithString, assetManager, blockManager);
    Iterator<Block> iterator = blockFamily.getBlocks().iterator();
    blockInFamilyOne = iterator.next();
    blockInFamilyTwo = iterator.next();
    PrefabData retainedPrefabData = new PrefabData();
    retainedPrefabData.addComponent(new RetainedOnBlockChangeComponent(3));
    Prefab retainedPrefab = assetManager.loadAsset(new ResourceUrn("test:retainedPrefab"), retainedPrefabData, Prefab.class);
    blockWithRetainedComponent = createBlockWithPrefab("test:blockWithRetainedComponent", retainedPrefab, false, assetManager, blockManager);
    worldProvider.initialise();
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) AssetManager(org.terasology.assets.management.AssetManager) PrefabData(org.terasology.entitySystem.prefab.PrefabData) RetainedOnBlockChangeComponent(org.terasology.entitySystem.stubs.RetainedOnBlockChangeComponent) BlockManager(org.terasology.world.block.BlockManager) Block(org.terasology.world.block.Block) BlockFamily(org.terasology.world.block.family.BlockFamily) EntityAwareWorldProvider(org.terasology.world.internal.EntityAwareWorldProvider) ResourceUrn(org.terasology.assets.ResourceUrn) Prefab(org.terasology.entitySystem.prefab.Prefab) WorldProviderCoreStub(org.terasology.testUtil.WorldProviderCoreStub) Before(org.junit.Before)

Example 14 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class HeadlessEnvironment method setupStorageManager.

@Override
protected void setupStorageManager() throws IOException {
    ModuleManager moduleManager = context.get(ModuleManager.class);
    EngineEntityManager engineEntityManager = context.get(EngineEntityManager.class);
    BlockManager blockManager = context.get(BlockManager.class);
    BiomeManager biomeManager = context.get(BiomeManager.class);
    Path savePath = PathManager.getInstance().getSavePath("world1");
    context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, blockManager, biomeManager));
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) BiomeManager(org.terasology.world.biomes.BiomeManager) Path(java.nio.file.Path) BlockManager(org.terasology.world.block.BlockManager) ReadWriteStorageManager(org.terasology.persistence.internal.ReadWriteStorageManager) ModuleManager(org.terasology.engine.module.ModuleManager)

Example 15 with BlockManager

use of org.terasology.world.block.BlockManager in project Terasology by MovingBlocks.

the class TerasologyTestingEnvironment method setup.

@Before
public void setup() throws Exception {
    context.put(ModuleManager.class, moduleManager);
    mockTime = mock(EngineTime.class);
    context.put(Time.class, mockTime);
    NetworkSystemImpl networkSystem = new NetworkSystemImpl(mockTime, context);
    context.put(Game.class, new Game());
    context.put(NetworkSystem.class, networkSystem);
    EntitySystemSetupUtil.addReflectionBasedLibraries(context);
    EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
    engineEntityManager = context.get(EngineEntityManager.class);
    // 'mock' added to avoid hiding a field
    BlockManager mockBlockManager = context.get(BlockManager.class);
    BiomeManager biomeManager = context.get(BiomeManager.class);
    Path savePath = PathManager.getInstance().getSavePath("world1");
    context.put(StorageManager.class, new ReadWriteStorageManager(savePath, moduleManager.getEnvironment(), engineEntityManager, mockBlockManager, biomeManager));
    componentSystemManager = new ComponentSystemManager(context);
    context.put(ComponentSystemManager.class, componentSystemManager);
    LoadPrefabs prefabLoadStep = new LoadPrefabs(context);
    boolean complete = false;
    prefabLoadStep.begin();
    while (!complete) {
        complete = prefabLoadStep.step();
    }
    context.get(ComponentSystemManager.class).initialise();
    context.put(Console.class, new ConsoleImpl(context));
}
Also used : EngineEntityManager(org.terasology.entitySystem.entity.internal.EngineEntityManager) BiomeManager(org.terasology.world.biomes.BiomeManager) Path(java.nio.file.Path) Game(org.terasology.game.Game) LoadPrefabs(org.terasology.engine.modes.loadProcesses.LoadPrefabs) ConsoleImpl(org.terasology.logic.console.ConsoleImpl) BlockManager(org.terasology.world.block.BlockManager) EngineTime(org.terasology.engine.EngineTime) ReadWriteStorageManager(org.terasology.persistence.internal.ReadWriteStorageManager) NetworkSystemImpl(org.terasology.network.internal.NetworkSystemImpl) ComponentSystemManager(org.terasology.engine.ComponentSystemManager) Before(org.junit.Before)

Aggregations

BlockManager (org.terasology.world.block.BlockManager)16 BiomeManager (org.terasology.world.biomes.BiomeManager)6 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)5 Before (org.junit.Before)4 ModuleManager (org.terasology.engine.module.ModuleManager)4 WorldProvider (org.terasology.world.WorldProvider)4 Block (org.terasology.world.block.Block)4 Path (java.nio.file.Path)3 AssetManager (org.terasology.assets.management.AssetManager)3 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)3 EntityAwareWorldProvider (org.terasology.world.internal.EntityAwareWorldProvider)3 FileSystem (java.nio.file.FileSystem)2 JavaArchive (org.jboss.shrinkwrap.api.spec.JavaArchive)2 ResourceUrn (org.terasology.assets.ResourceUrn)2 Config (org.terasology.config.Config)2 RenderingSubsystemFactory (org.terasology.engine.subsystem.RenderingSubsystemFactory)2 Game (org.terasology.game.Game)2 LocalPlayer (org.terasology.logic.players.LocalPlayer)2 ModuleEnvironment (org.terasology.module.ModuleEnvironment)2 NetworkSystem (org.terasology.network.NetworkSystem)2