MCPcopy Create free account
hub / github.com/Card-Forge/forge / generateNew

Method generateNew

forge-gui-mobile/src/forge/adventure/world/World.java:291–816  ·  view source on GitHub ↗
(long seed)

Source from the content-addressed store, hash-verified

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 }

Callers 3

loadSaveMethod · 0.80
loadMethod · 0.80
generateNewWorldMethod · 0.80

Calls 15

isAndroidMethod · 0.95
getInterfaceMethod · 0.95
loadWorldDataMethod · 0.95
measureGenerationTimeMethod · 0.95
initializeMethod · 0.95
evalMethod · 0.95
GetColorMethod · 0.95
objectIDMethod · 0.95
collisionMethod · 0.95
structureObjectCountMethod · 0.95
instanceMethod · 0.95
clearTerrainMethod · 0.95

Tested by

no test coverage detected