public static Task AsyncGenerateRandStatues(short amount) { WorldRefill.isTaskRunning = true; int realcount = 0; return(Task.Run(() => { for (int trycount = 0; trycount < WorldRefill.config.GenerationMaxTries; trycount++) { int tryX = WorldGen.genRand.Next(20, Main.maxTilesX - 20); int tryY = WorldGen.genRand.Next((int)Main.rockLayer, Main.UnderworldLayer); int tryType = WorldGen.genRand.Next(0, WorldGen.statueList.Count() - 1); Point16 randstatue = WorldGen.statueList[tryType]; if (!WorldRefill.IsProtected(tryX, tryY)) { while (!TileValidation.StatueTileValidation(tryX, tryY)) { tryY++; if (tryY >= Main.UnderworldLayer) { break; } } if (tryY < Main.UnderworldLayer && (!TileValidation.isinNonNaturalStatuePlace(Main.tile[tryX, tryY + 1].type))) { WorldGen.PlaceTile(tryX, tryY, randstatue.X, true, true, -1, randstatue.Y); if (Main.tile[tryX, tryY].type == randstatue.X) { realcount++; if (realcount == amount) { break; } } } } } WorldRefill.realcount = realcount; }).ContinueWith((d) => FinishGen())); }
public static Task AsyncGenerateStatues(short amount, short tileid = 0, short style = 0, int maxtries = Config.GenerationMaxTries) { WorldRefill.isTaskRunning = true; int realcount = 0; return(Task.Run(() => { TryInitWorldGen(); for (int trycount = 0; trycount <= maxtries; trycount++) { int tryX = WorldGen.genRand.Next(20, Main.maxTilesX - 20); int tryY = WorldGen.genRand.Next((int)Main.rockLayer, MainExt.UnderworldLayer); int tryType = WorldGen.genRand.Next(0, WorldGen.statueList.Count() - 1); while (!TileValidation.StatueTileValidation(tryX, tryY)) { tryY++; if (tryY >= MainExt.UnderworldLayer) { break; } } if (tryY < MainExt.UnderworldLayer && (!TileValidation.isinNonNaturalStatuePlace(Main.tile[tryX, tryY + 1].type))) { WorldGen.PlaceTile(tryX, tryY, tileid, true, true, -1, style); if (Main.tile[tryX, tryY].type == tileid) { realcount++; if (realcount == amount) { break; } } } } WorldRefill.realcount = realcount; }).ContinueWith((d) => { WorldRefill.isTaskRunning = false; })); }