use of org.terasology.game.GameManifest in project Terasology by MovingBlocks.
the class SelectGameScreen method loadGame.
private void loadGame(GameInfo item) {
try {
GameManifest manifest = item.getManifest();
config.getWorldGeneration().setDefaultSeed(manifest.getSeed());
config.getWorldGeneration().setWorldTitle(manifest.getTitle());
CoreRegistry.get(GameEngine.class).changeState(new StateLoading(manifest, (loadingAsServer) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
} catch (Exception e) {
logger.error("Failed to load saved game", e);
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error Loading Game", e.getMessage());
}
}
use of org.terasology.game.GameManifest in project Terasology by MovingBlocks.
the class StateHeadlessSetup method createGameManifest.
public GameManifest createGameManifest() {
GameManifest gameManifest = new GameManifest();
Config config = context.get(Config.class);
ModuleManager moduleManager = context.get(ModuleManager.class);
for (Name moduleName : config.getDefaultModSelection().listModules()) {
Module module = moduleManager.getRegistry().getLatestModuleVersion(moduleName);
if (module != null) {
gameManifest.addModule(module.getId(), module.getVersion());
}
}
WorldGenerationConfig worldGenConfig = config.getWorldGeneration();
// If no valid default world generator set then try to find one - no option to pick one manually in headless
if (!worldGenConfig.getDefaultGenerator().isValid()) {
// find the first gameplay module that is available, it should have a preferred world gen
for (Name moduleName : config.getDefaultModSelection().listModules()) {
Module module = moduleManager.getRegistry().getLatestModuleVersion(moduleName);
if (StandardModuleExtension.isGameplayModule(module)) {
SimpleUri defaultWorldGenerator = StandardModuleExtension.getDefaultWorldGenerator(module);
worldGenConfig.setDefaultGenerator(defaultWorldGenerator);
break;
}
}
}
SimpleUri worldGeneratorUri = worldGenConfig.getDefaultGenerator();
gameManifest.setTitle(worldGenConfig.getWorldTitle());
gameManifest.setSeed(worldGenConfig.getDefaultSeed());
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, gameManifest.getSeed(), (long) (WorldTime.DAY_LENGTH * 0.025f), worldGeneratorUri);
gameManifest.addWorld(worldInfo);
return gameManifest;
}
Aggregations