Package org.terasology.world.generator

Examples of org.terasology.world.generator.WorldGenerator


    }

    @Override
    public boolean step() {

        WorldGenerator worldGenerator = CoreRegistry.get(WorldGenerator.class);
        worldGenerator.initialize();

        return true;
    }
View Full Code Here


        if (info == null) {
            return;
        }

        try {
            WorldGenerator wg = worldGeneratorManager.createGenerator(info.getUri());
            // set the world seed so that partial initialization happens and the facet system has all facet providers
            wg.setWorldSeed("");
            if (wg.getConfigurator().isPresent()) {
                WorldConfigurator worldConfig = wg.getConfigurator().get();

                params = Maps.newHashMap(worldConfig.getProperties());

                for (String key : params.keySet()) {
                    Class<? extends Component> clazz = params.get(key).getClass();
View Full Code Here

        CoreRegistry.put(WorldGeneratorPluginLibrary.class, new TempWorldGeneratorPluginLibrary());
        WorldGeneratorInfo info = worldGeneratorManager.getWorldGeneratorInfo(config.getWorldGeneration().getDefaultGenerator());

        try {
            WorldGenerator worldGenerator = worldGeneratorManager.createGenerator(info.getUri());
            seedBinding.setWorldGenerator(worldGenerator);

            if (worldGenerator instanceof WorldGenerator2DPreview) {
                previewGenerator = (WorldGenerator2DPreview) worldGenerator;
            } else {
View Full Code Here

            EntityRef worldEntity = worldEntityIterator.next();
            worldRenderer.getChunkProvider().setWorldEntity(worldEntity);

            // get the world generator config from the world entity
            // replace the world generator values from the components in the world entity
            WorldGenerator worldGenerator = CoreRegistry.get(WorldGenerator.class);
            Optional<WorldConfigurator> ocf = worldGenerator.getConfigurator();

            if (ocf.isPresent()) {
                Map<String, Component> params = ocf.get().getProperties();
                for (Map.Entry<String, Component> entry : params.entrySet()) {
                    Class<? extends Component> clazz = entry.getValue().getClass();
                    Component comp = worldEntity.getComponent(clazz);
                    if (comp != null) {
                        entry.setValue(comp);
                    }
                }
                // save the world config back to the world generator
                worldGenerator.setConfigurator(ocf.get());
            }
        } else {
            EntityRef worldEntity = entityManager.create();
            worldEntity.addComponent(new WorldComponent());
            worldRenderer.getChunkProvider().setWorldEntity(worldEntity);

            // transfer all world generation parameters from Config to WorldEntity
            WorldGenerator worldGenerator = CoreRegistry.get(WorldGenerator.class);
            Optional<WorldConfigurator> ocf = worldGenerator.getConfigurator();

            if (ocf.isPresent()) {
                SimpleUri generatorUri = worldGenerator.getUri();
                Config config = CoreRegistry.get(Config.class);

                // get the map of properties from the world generator.  Replace its values with values from the config set by the UI.
                // Also set all the components to the world entity.
                Map<String, Component> params = ocf.get().getProperties();
                for (Map.Entry<String, Component> entry : params.entrySet()) {
                    Class<? extends Component> clazz = entry.getValue().getClass();
                    Component comp = config.getModuleConfig(generatorUri, entry.getKey(), clazz);
                    if (comp != null) {
                        worldEntity.addComponent(comp);
                        entry.setValue(comp);
                    } else {
                        worldEntity.addComponent(entry.getValue());
                    }
                }

                // save the world config back to the world generator
                worldGenerator.setConfigurator(ocf.get());
            }

        }

View Full Code Here

        logger.info("World seed: \"{}\"", worldInfo.getSeed());

        // TODO: Separate WorldRenderer from world handling in general
        WorldGeneratorManager worldGeneratorManager = CoreRegistry.get(WorldGeneratorManager.class);
        WorldGenerator worldGenerator;
        try {
            worldGenerator = worldGeneratorManager.createGenerator(worldInfo.getWorldGenerator());
            // setting the world seed will create the world builder
            worldGenerator.setWorldSeed(worldInfo.getSeed());
            CoreRegistry.put(WorldGenerator.class, worldGenerator);
        } catch (UnresolvedWorldGeneratorException e) {
            logger.error("Unable to load world generator {}. Available world generators: {}",
                    worldInfo.getWorldGenerator(), worldGeneratorManager.getWorldGenerators());
            CoreRegistry.get(GameEngine.class).changeState(new StateMainMenu("Failed to resolve world generator."));
View Full Code Here

TOP

Related Classes of org.terasology.world.generator.WorldGenerator

Copyright © 2018 www.massapicom. 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.