use of org.terasology.engine.entitySystem.prefab.internal.PojoPrefab in project Terasology by MovingBlocks.
the class PojoPrefabManagerTest method setup.
@BeforeEach
public void setup() throws Exception {
ContextImpl context = new ContextImpl();
CoreRegistry.setContext(context);
ModuleManager moduleManager = ModuleManagerFactory.create();
ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
context.put(AssetManager.class, assetTypeManager.getAssetManager());
prefabManager = new PojoPrefabManager(context);
}
use of org.terasology.engine.entitySystem.prefab.internal.PojoPrefab in project Terasology by MovingBlocks.
the class PrefabTest method setup.
@BeforeEach
public void setup() throws Exception {
ContextImpl context = new ContextImpl();
context.put(RecordAndReplayCurrentStatus.class, new RecordAndReplayCurrentStatus());
CoreRegistry.setContext(context);
ModuleManager moduleManager = ModuleManagerFactory.create();
context.put(ModuleManager.class, moduleManager);
EntitySystemSetupUtil.addReflectionBasedLibraries(context);
ModuleAwareAssetTypeManager assetTypeManager = new ModuleAwareAssetTypeManagerImpl();
AssetType<Prefab, PrefabData> prefabDataAssetType = assetTypeManager.createAssetType(Prefab.class, PojoPrefab::new, "prefabs");
ComponentLibrary componentLibrary = context.get(ComponentLibrary.class);
TypeHandlerLibrary typeHandlerLibrary = context.get(TypeHandlerLibrary.class);
PrefabFormat prefabFormat = new PrefabFormat(componentLibrary, typeHandlerLibrary);
assetTypeManager.getAssetFileDataProducer(prefabDataAssetType).addAssetFormat(prefabFormat);
assetTypeManager.switchEnvironment(moduleManager.getEnvironment());
context.put(AssetManager.class, assetTypeManager.getAssetManager());
NetworkSystem networkSystem = mock(NetworkSystem.class);
when(networkSystem.getMode()).thenReturn(NetworkMode.NONE);
context.put(NetworkSystem.class, networkSystem);
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context);
prefabManager = new PojoPrefabManager(context);
}
use of org.terasology.engine.entitySystem.prefab.internal.PojoPrefab in project Terasology by MovingBlocks.
the class PojoEntityManagerTest 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.engine.entitySystem.prefab.internal.PojoPrefab in project Terasology by MovingBlocks.
the class TerasologyEngine method initAssets.
private void initAssets() {
// 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> blockFamilyDefinitionAssetType = assetTypeManager.createAssetType(BlockFamilyDefinition.class, BlockFamilyDefinition::new, "blocks");
assetTypeManager.getAssetFileDataProducer(blockFamilyDefinitionAssetType).addAssetFormat(new BlockFamilyDefinitionFormat(assetTypeManager.getAssetManager()));
assetTypeManager.createAssetType(UISkinAsset.class, UISkinAsset::new, "skins");
assetTypeManager.createAssetType(BehaviorTree.class, BehaviorTree::new, "behaviors");
assetTypeManager.createAssetType(UIElement.class, UIElement::new, "ui");
assetTypeManager.createAssetType(ByteBufferAsset.class, ByteBufferAsset::new, "mesh");
for (EngineSubsystem subsystem : allSubsystems) {
subsystem.registerCoreAssetTypes(assetTypeManager);
}
}
use of org.terasology.engine.entitySystem.prefab.internal.PojoPrefab in project Terasology by MovingBlocks.
the class UniverseSetupScreen method initAssets.
private void initAssets() {
ModuleEnvironment environment = context.get(ModuleManager.class).getEnvironment();
BlockFamilyLibrary library = new BlockFamilyLibrary(environment, context);
// 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(UISkinAsset.class, UISkinAsset::new, "skins");
assetTypeManager.createAssetType(BehaviorTree.class, BehaviorTree::new, "behaviors");
assetTypeManager.createAssetType(UIElement.class, UIElement::new, "ui");
}
Aggregations