Package org.terasology.world.generator.internal

Examples of org.terasology.world.generator.internal.WorldGeneratorInfo


        PropertyLayout properties = find("properties", PropertyLayout.class);
        properties.setOrdering(PropertyOrdering.byLabel());
        properties.clear();

        SimpleUri generatorUri = config.getWorldGeneration().getDefaultGenerator();
        WorldGeneratorInfo info = worldGeneratorManager.getWorldGeneratorInfo(generatorUri);

        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();
                    Component comp = config.getModuleConfig(generatorUri, key, clazz);
                    if (comp != null) {
                        params.put(key, comp);       // use the data from the config instead of defaults
                    }
                }

                for (String label : params.keySet()) {
                    PropertyProvider<?> provider = new PropertyProvider<>(params.get(label));
                    properties.addPropertyProvider(label, provider);
                }
            } else {
                logger.info(info.getUri().toString() + " does not support configuration");
            }
        } catch (UnresolvedWorldGeneratorException e) {
            logger.error("Requested unavailable world generator", e);
        }
    }
View Full Code Here


            });
            worldGenerator.bindSelection(new Binding<WorldGeneratorInfo>() {
                @Override
                public WorldGeneratorInfo get() {
                    // get the default generator from the config.  This is likely to have  a user triggered selection.
                    WorldGeneratorInfo info = worldGeneratorManager.getWorldGeneratorInfo(config.getWorldGeneration().getDefaultGenerator());
                    if (info != null && getAllEnabledModuleNames().contains(info.getUri().getModuleName())) {
                        return info;
                    }

                    // get the default generator from the selected gameplay module
                    Module selectedGameplayModule = gameplay.getSelection();
View Full Code Here

    @Override
    public void onOpened() {
        super.onOpened();

        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 {
                logger.info(info.getUri().toString() + " does not support a 2d preview");
            }
        } catch (Exception e) {
            // if errors happen, don't enable this feature
            seedBinding = new SeedBinding();
            previewGenerator = null;
            logger.error("Unable to load world generator: " + info.getUri().toString() + " for a 2d preview");
        }
    }
View Full Code Here

TOP

Related Classes of org.terasology.world.generator.internal.WorldGeneratorInfo

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.