Search in sources :

Example 1 with UniverseConfig

use of org.terasology.engine.config.UniverseConfig in project Terasology by MovingBlocks.

the class ReadWriteStorageManager method addGameManifestToSaveTransaction.

private void addGameManifestToSaveTransaction(SaveTransactionBuilder saveTransactionBuilder) {
    BlockManager blockManager = CoreRegistry.get(BlockManager.class);
    UniverseConfig universeConfig = config.getUniverseConfig();
    Time time = CoreRegistry.get(Time.class);
    Game game = CoreRegistry.get(Game.class);
    GameManifest gameManifest = new GameManifest(game.getName(), game.getSeed(), time.getGameTimeInMs());
    for (Module module : CoreRegistry.get(ModuleManager.class).getEnvironment()) {
        gameManifest.addModule(module.getId(), module.getVersion());
    }
    List<String> registeredBlockFamilies = Lists.newArrayList();
    for (BlockFamily family : blockManager.listRegisteredBlockFamilies()) {
        registeredBlockFamilies.add(family.getURI().toString());
    }
    gameManifest.setRegisteredBlockFamilies(registeredBlockFamilies);
    gameManifest.setBlockIdMap(blockManager.getBlockIdMap());
    List<WorldInfo> worlds = universeConfig.getWorlds();
    for (WorldInfo worldInfo : worlds) {
        gameManifest.addWorld(worldInfo);
    }
    WorldGenerator worldGenerator = CoreRegistry.get(WorldGenerator.class);
    if (worldGenerator != null) {
        WorldConfigurator worldConfigurator = worldGenerator.getConfigurator();
        Map<String, Component> params = worldConfigurator.getProperties();
        gameManifest.setModuleConfigs(worldGenerator.getUri(), params);
    }
    saveTransactionBuilder.setGameManifest(gameManifest);
}
Also used : WorldGenerator(org.terasology.engine.world.generator.WorldGenerator) WorldConfigurator(org.terasology.engine.world.generator.WorldConfigurator) Time(org.terasology.engine.core.Time) UniverseConfig(org.terasology.engine.config.UniverseConfig) ModuleManager(org.terasology.engine.core.module.ModuleManager) Game(org.terasology.engine.game.Game) GameManifest(org.terasology.engine.game.GameManifest) BlockManager(org.terasology.engine.world.block.BlockManager) WorldInfo(org.terasology.engine.world.internal.WorldInfo) BlockFamily(org.terasology.engine.world.block.family.BlockFamily) Module(org.terasology.gestalt.module.Module) Component(org.terasology.gestalt.entitysystem.component.Component) LocationComponent(org.terasology.engine.logic.location.LocationComponent) ClientComponent(org.terasology.engine.network.ClientComponent)

Aggregations

UniverseConfig (org.terasology.engine.config.UniverseConfig)1 Time (org.terasology.engine.core.Time)1 ModuleManager (org.terasology.engine.core.module.ModuleManager)1 Game (org.terasology.engine.game.Game)1 GameManifest (org.terasology.engine.game.GameManifest)1 LocationComponent (org.terasology.engine.logic.location.LocationComponent)1 ClientComponent (org.terasology.engine.network.ClientComponent)1 BlockManager (org.terasology.engine.world.block.BlockManager)1 BlockFamily (org.terasology.engine.world.block.family.BlockFamily)1 WorldConfigurator (org.terasology.engine.world.generator.WorldConfigurator)1 WorldGenerator (org.terasology.engine.world.generator.WorldGenerator)1 WorldInfo (org.terasology.engine.world.internal.WorldInfo)1 Component (org.terasology.gestalt.entitysystem.component.Component)1 Module (org.terasology.gestalt.module.Module)1