Examples of GameManifest


Examples of org.terasology.game.GameManifest

     * Constructor for client of multiplayer game
     *
     * @param joinStatus
     */
    public StateLoading(JoinStatus joinStatus) {
        this.gameManifest = new GameManifest();
        this.nuiManager = CoreRegistry.get(NUIManager.class);
        this.netMode = NetworkMode.CLIENT;
        this.joinStatus = joinStatus;
    }
View Full Code Here

Examples of org.terasology.game.GameManifest

        BlockManager blockManager = CoreRegistry.get(BlockManager.class);
        BiomeManager biomeManager = CoreRegistry.get(BiomeManager.class);
        WorldProvider worldProvider = CoreRegistry.get(WorldProvider.class);
        Game game = CoreRegistry.get(Game.class);

        GameManifest gameManifest = new GameManifest(game.getName(), game.getSeed(), game.getTime().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<Biome> biomes = biomeManager.getBiomes();
        Map<String, Short> biomeIdMap = new HashMap<>(biomes.size());
        for (Biome biome : biomes) {
            short shortId = biomeManager.getBiomeShortId(biome);
            String id = biomeManager.getBiomeId(biome);
            biomeIdMap.put(id, shortId);
        }
        gameManifest.setBiomeIdMap(biomeIdMap);
        gameManifest.addWorld(worldProvider.getWorldInfo());
        saveTransactionBuilder.setGameManifest(gameManifest);
    }
View Full Code Here

Examples of org.terasology.game.GameManifest

        return false;
    }

    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());
        }
View Full Code Here

Examples of org.terasology.game.GameManifest

                    MessagePopup errorMessagePopup = getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
                    if (errorMessagePopup != null) {
                        errorMessagePopup.setMessage("No World Generator Selected", "Select a world generator (you may need to activate a mod with a generator first).");
                    }
                } else {
                    GameManifest gameManifest = new GameManifest();

                    gameManifest.setTitle(worldName.getText());
                    gameManifest.setSeed(seed.getText());
                    DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
                    ResolutionResult result = resolver.resolve(config.getDefaultModSelection().listModules());
                    if (!result.isSuccess()) {
                        MessagePopup errorMessagePopup = getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class);
                        if (errorMessagePopup != null) {
                            errorMessagePopup.setMessage("Invalid Module Selection", "Please review your module seleciton and try again");
                        }
                        return;
                    }
                    for (Module module : result.getModules()) {
                        gameManifest.addModule(module.getId(), module.getVersion());
                    }

                    float timeOffset = 0.25f + 0.025f// Time at dawn + little offset to spawn in a brighter env.
                    WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, gameManifest.getSeed(),
                            (long) (WorldTime.DAY_LENGTH * timeOffset), worldGenerator.getSelection().getUri());
                    gameManifest.addWorld(worldInfo);

                    gameEngine.changeState(new StateLoading(gameManifest, (loadingAsServer) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
                }
            }
        });
View Full Code Here

Examples of org.terasology.game.GameManifest

                } else {
                    if (loadLastGame) {
                        engine.submitTask("loadGame", new Runnable() {
                            @Override
                            public void run() {
                                GameManifest gameManifest = getLatestGameManifest();
                                if (gameManifest != null) {
                                    engine.changeState(new StateLoading(gameManifest, NetworkMode.NONE));
                                }
                            }
                        });
View Full Code Here

Examples of org.terasology.game.GameManifest

    @Override
    public void init(GameEngine gameEngine) {
        super.init(gameEngine);

        GameManifest gameManifest = null;
        List<GameInfo> savedGames = GameProvider.getSavedGames();
        if (savedGames.size() > 0) {
            gameManifest = savedGames.get(0).getManifest();
        } else {
            gameManifest = createGameManifest();
View Full Code Here

Examples of org.terasology.game.GameManifest

        }
        gameEngine.changeState(new StateLoading(gameManifest, NetworkMode.LISTEN_SERVER));
    }

    private GameManifest createGameManifest() {
        GameManifest gameManifest = new GameManifest();

        Config config = CoreRegistry.get(Config.class);
        ModuleManager moduleManager = CoreRegistry.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 (moduleManager.isGameplayModule(module)) {
                    String defaultWorldGenerator = module.getMetadata().getExtension(ModuleManager.DEFAULT_WORLD_GENERATOR_EXT, String.class);
                    worldGenConfig.setDefaultGenerator(new SimpleUri(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;
    }
View Full Code Here

Examples of org.terasology.game.GameManifest

            if (!Files.isRegularFile(gameManifest)) {
                continue;
            }
            try {
                GameManifest info = GameManifest.load(gameManifest);
                if (!info.getTitle().isEmpty()) {
                    Date date = new Date(world.getKey().toMillis());
                    result.add(new GameInfo(info, date));
                }
            } catch (IOException e) {
                logger.error("Failed reading world data object.", e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.