re-roll the world seed
private String selectedWorld;
private List<String> worldNames;
private UISlider zoomSlider;
+ private int seedNumber = 0;
public WorldPreGenerationScreen() {
@@ -91,7 +92,7 @@ public void setEnvironment(Context subContext) throws UnresolvedWorldGeneratorEx
}
//worldGenerator = WorldGeneratorManager.createWorldGenerator(findWorldByName().getWorldGeneratorInfo().getUri(), context, environment);
- worldGenerator.setWorldSeed("thisisjustrandom");
+ worldGenerator.setWorldSeed(createSeed(selectedWorld));
final UIDropdownScrollable worldsDropdown = find("worlds", UIDropdownScrollable.class);
worldsDropdown.setOptions(worldNames);
genTexture();
@@ -139,6 +140,11 @@ public void set(String value) {
}
});
+ WidgetUtil.trySubscribe(this, "reRoll", button -> {
+ worldGenerator.setWorldSeed(createSeed(selectedWorld));
+ getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Ready to roll!", "World seed for " + selectedWorld + " has been changed");
+ });
+
StartPlayingScreen startPlayingScreen = getManager().createScreen(StartPlayingScreen.ASSET_URI, StartPlayingScreen.class);
WidgetUtil.trySubscribe(this, "continue", button ->
updatePreview()
@@ -200,7 +206,7 @@ private void updatePreview() {
popup.startOperation(operation, true);
}
- public World findWorldByName() {
+ private World findWorldByName() {
for (World world: worldList) {
if (world.getWorldName().toString().equals(selectedWorld)) {
return world;
@@ -209,4 +215,8 @@ public World findWorldByName() {
return null;
}
+ private String createSeed(String world) {
+ return world + seedNumber++;
+ }
+
}
