(long seed)
| 289 | } |
| 290 | |
| 291 | public boolean generateNew(long seed) { |
| 292 | try { |
| 293 | if (GuiBase.isAndroid()) |
| 294 | GuiBase.getInterface().preventSystemSleep(true); |
| 295 | final long[] currentTime = {System.currentTimeMillis()}; |
| 296 | long startTime = System.currentTimeMillis(); |
| 297 | |
| 298 | loadWorldData(); |
| 299 | ////////////////// |
| 300 | ///////// initialize |
| 301 | ////////////////// |
| 302 | |
| 303 | if (seed == 0) { |
| 304 | seed = random.nextLong(); |
| 305 | } |
| 306 | this.seed = seed; |
| 307 | random.setSeed(seed); |
| 308 | OpenSimplexNoise noise = new OpenSimplexNoise(seed); |
| 309 | |
| 310 | float noiseZoom = data.noiseZoomBiome; |
| 311 | width = data.width; |
| 312 | height = data.height; |
| 313 | //save at all data |
| 314 | biomeMap = new long[width][height]; |
| 315 | terrainMap = new int[width][height]; |
| 316 | |
| 317 | for (int x = 0; x < width; x++) { |
| 318 | for (int y = 0; y < height; y++) { |
| 319 | biomeMap[x][y] = 0; |
| 320 | terrainMap[x][y] = 0; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | final int[] biomeIndex = {-1}; |
| 325 | currentTime[0] = measureGenerationTime("loading data", currentTime[0]); |
| 326 | Map<BiomeStructureData, BiomeStructure> structureDataMap = new ConcurrentHashMap<>(); |
| 327 | |
| 328 | ////////////////// |
| 329 | ///////// calculation structure position with wavefunctioncollapse |
| 330 | ////////////////// |
| 331 | List<CompletableFuture<Long>> futures = new ArrayList<>(); |
| 332 | for (BiomeData biome : data.GetBiomes()) { |
| 333 | if (biome.structures != null) { |
| 334 | int biomeWidth = (int) Math.round(biome.width * (double) width); |
| 335 | int biomeHeight = (int) Math.round(biome.height * (double) height); |
| 336 | for (BiomeStructureData data : biome.structures) { |
| 337 | long localSeed = seed; |
| 338 | futures.add(CompletableFuture.supplyAsync(()-> { |
| 339 | long threadStartTime = System.currentTimeMillis(); |
| 340 | BiomeStructure structure = new BiomeStructure(data, localSeed, biomeWidth, biomeHeight); |
| 341 | structure.initialize(); |
| 342 | structureDataMap.put(data, structure); |
| 343 | return measureGenerationTime("wavefunctioncollapse " + data.sourcePath, threadStartTime); |
| 344 | }).exceptionally(ex -> { |
| 345 | ex.printStackTrace(); |
| 346 | return 0L; |
| 347 | })); |
| 348 | } |
no test coverage detected