@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof WorldGeneratorInfo) { WorldGeneratorInfo other = (WorldGeneratorInfo) obj; return Objects.equals(uri, other.getUri()) && Objects.equals(other.displayName, displayName); } return false; }
public WorldGeneratorInfo getWorldGeneratorInfo(SimpleUri uri) { for (WorldGeneratorInfo info : generatorInfo) { if (info.getUri().equals(uri)) { return info; } } return null; }
@Override public List<WorldGeneratorInfo> get() { // grab all the module names and their dependencies // This grabs modules from `config.getDefaultModSelection()` which is updated in AdvancedGameSetupScreen final Set<Name> enabledModuleNames = new HashSet<>(getAllEnabledModuleNames()); final List<WorldGeneratorInfo> result = Lists.newArrayList(); for (WorldGeneratorInfo option : worldGeneratorManager.getWorldGenerators()) { if (enabledModuleNames.contains(option.getUri().getModuleName())) { result.add(option); } } return result; } });
@Override public void set(WorldGeneratorInfo value) { if (value != null) { config.getWorldGeneration().setDefaultGenerator(value.getUri()); } } });
private void setDefaultGeneratorOfGameplayModule(Module module) { // Set the default generator of the selected gameplay module SimpleUri defaultWorldGenerator = StandardModuleExtension.getDefaultWorldGenerator(module); if (defaultWorldGenerator != null) { for (WorldGeneratorInfo worldGenInfo : worldGeneratorManager.getWorldGenerators()) { if (worldGenInfo.getUri().equals(defaultWorldGenerator)) { config.getWorldGeneration().setDefaultGenerator(worldGenInfo.getUri()); } } } config.save(); }
@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; } // just use the first available generator for (WorldGeneratorInfo worldGenInfo : worldGeneratorManager.getWorldGenerators()) { if (getAllEnabledModuleNames().contains(worldGenInfo.getUri().getModuleName())) { set(worldGenInfo); return worldGenInfo; } } return null; }
@Override public void set(String value) { selectedWorld = value; try { if (findWorldByName(selectedWorld).getWorldGenerator() == null) { worldGenerator = WorldGeneratorManager.createWorldGenerator(findWorldByName(selectedWorld).getWorldGeneratorInfo().getUri(), context, environment); findWorldByName(selectedWorld).setWorldGenerator(worldGenerator); } else { worldGenerator = findWorldByName(selectedWorld).getWorldGenerator(); } if (worldGenerator.getWorldSeed() == null) { worldGenerator.setWorldSeed(createSeed(selectedWorld)); } previewGen = new FacetLayerPreview(environment, worldGenerator); updatePreview(); } catch (UnresolvedWorldGeneratorException e) { e.printStackTrace(); } } });
/** * This method sets the world whose properties are to be changed. This function is called before the screen comes * to the forefront. * @param subContext the new environment created in {@link UniverseSetupScreen} * @param worldSelected the world whose configurations are to be changed. * @throws UnresolvedWorldGeneratorException */ public void setWorld(Context subContext, WorldSetupWrapper worldSelected) throws UnresolvedWorldGeneratorException { world = worldSelected; context = subContext; SimpleUri worldGenUri = worldSelected.getWorldGeneratorInfo().getUri(); environment = context.get(ModuleEnvironment.class); context.put(WorldGeneratorPluginLibrary.class, new TempWorldGeneratorPluginLibrary(environment, context)); if (world.getWorldGenerator() == null) { worldGenerator = WorldGeneratorManager.createWorldGenerator(worldGenUri, context, environment); world.setWorldGenerator(worldGenerator); } else { worldGenerator = world.getWorldGenerator(); } configureProperties(); }
@Override public void onOpened() { try { if (findWorldByName(selectedWorld).getWorldGenerator() == null) { worldGenerator = WorldGeneratorManager.createWorldGenerator(findWorldByName(selectedWorld).getWorldGeneratorInfo().getUri(), context, environment); findWorldByName(selectedWorld).setWorldGenerator(worldGenerator); } else { worldGenerator = findWorldByName(selectedWorld).getWorldGenerator(); } if (worldGenerator.getWorldSeed().isEmpty()) { worldGenerator.setWorldSeed(createSeed(selectedWorld)); } previewGen = new FacetLayerPreview(environment, worldGenerator); updatePreview(); } catch (UnresolvedWorldGeneratorException e) { e.printStackTrace(); } }
private void setWorldGenerators() { for (WorldSetupWrapper worldSetupWrapper : worldList) { if (worldSetupWrapper.getWorldGenerator() == null) { try { worldSetupWrapper.setWorldGenerator(WorldGeneratorManager.createWorldGenerator(findWorldByName(worldSetupWrapper.getWorldName().toString()).getWorldGeneratorInfo().getUri(), context, environment)); } catch (UnresolvedWorldGeneratorException e) { e.printStackTrace(); } } worldSetupWrapper.getWorldGenerator().setWorldSeed(createSeed(worldSetupWrapper.getWorldName().toString())); } }
if (world != targetWorld) { i++; uri = world.getWorldGeneratorInfo().getUri(); worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD + i, world.getWorldName().toString(), world.getWorldGenerator().getWorldSeed(), (long) (WorldTime.DAY_LENGTH * WorldTime.NOON_OFFSET), uri);
if (worldGenerator.getSelection().getUri().toString().equals("Core:heightMap")) { getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("HeightMap not supported", "HeightMap is not supported for advanced setup right now, a game template will be introduced soon.");