public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight) { int hellIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Underworld")); int hellForgeIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Hellforge")); int guideIndex = tasks.FindIndex(genpass => genpass.Name.Equals("Guide")); tasks[hellIndex] = new PassLegacy("Underworld", progress => { if (WorldGen.crimson) { Wasteland = true; WastelandGeneration(progress); NPC.NewNPC((Main.maxTilesX / 2) * 16, (Main.maxTilesY - 100) * 16 - 444, mod.NPCType("HeartOfTheWasteland"), 0, 0f, 0f, 0f, 0f, 255); } else { Wasteland = false; VanillaHell(progress); } }); tasks[hellForgeIndex] = new PassLegacy("Hellforge", progress => { if (!Wasteland) { AddForges(progress); } }); }
private void CancelClick(UIMouseEvent evt, UIElement listeningElement) { // This approach left the world gen continuing in the other thread, corrupting subsequent world gen attempts //throw new Exception("WorldGenPreviewer: User canceled World Gen\n"); // This didn't work because the enumerator is used in the foreach. //FieldInfo passesFieldInfo = typeof(WorldGenerator).GetField("_passes", BindingFlags.Instance | BindingFlags.NonPublic); //FieldInfo generatorFieldInfo = typeof(WorldGen).GetField("_generator", BindingFlags.Static | BindingFlags.NonPublic); //WorldGenerator _generator = (WorldGenerator)generatorFieldInfo.GetValue(null); //passesFieldInfo.SetValue(_generator, null); // saveLock prevents save, but needs to be restored to false. WorldGenPreviewerModWorld.saveLockForced = true; Main.skipMenu = true; FieldInfo methodFieldInfo = typeof(PassLegacy).GetField("_method", BindingFlags.Instance | BindingFlags.NonPublic); // This method still can't cancel infinite loops in passes. This can't be avoided. We could try forcing an exception on the world gen thread like `Main.tile = null`, but we'd have to restore the reference somehow. foreach (var item in passesList._items) { UIPassItem passitem = item as UIPassItem; PassLegacy passLegacy = passitem.pass as PassLegacy; if (passLegacy != null) { methodFieldInfo.SetValue(passLegacy, (WorldGenLegacyMethod) delegate(GenerationProgress progress, GameConfiguration config) { }); } } WorldGenPreviewerModWorld.continueWorldGen = true; WorldGenPreviewerModWorld.pauseAfterContinue = false; statusLabel.SetText("Status: Canceling..."); }
public override void ModifyHardmodeTasks(List <GenPass> list) { int goodIndex = list.FindIndex(i => i.Name == "Hardmode Good"); int badIndex = list.FindIndex(i => i.Name == "Hardmode Evil"); Main.hardMode = true; list[goodIndex] = (new PassLegacy("Hardmode Good", (progress) => GenerateGoodBiome(progress))); list[badIndex] = new PassLegacy("Hardmode Evil", (progress) => GenerateBadBiome(progress)); }
public override void ModifyHardmodeTasks(List <GenPass> list) { int hardmodeGood = list.FindIndex(g => g.Name.Equals(HARDMODE_GOOD)), hardmodeBad = list.FindIndex(g => g.Name.Equals(HARDMODE_BAD)); list[hardmodeGood] = new PassLegacy(HARDMODE_GOOD, p => GenerateGoodHardmodeBiome(p)); list[hardmodeBad] = new PassLegacy(HARDMODE_BAD, p => GenerateBadHardmodeBiome(p)); }
private void RemoveThisPass(UIMouseEvent evt, UIElement listeningElement) { PassLegacy passLegacy = pass as PassLegacy; if (passLegacy != null) { //private WorldGenLegacyMethod _method; FieldInfo methodFieldInfo = typeof(PassLegacy).GetField("_method", BindingFlags.Instance | BindingFlags.NonPublic); methodFieldInfo.SetValue(passLegacy, (WorldGenLegacyMethod) delegate(GenerationProgress progress) { }); } UIWorldLoadSpecial.instance.passesList.Remove(this); }
public void GenerateEvilBiome(GenerationProgress progress, PassLegacy pass) { if (PendingEvil.Equals("Corruption", StringComparison.InvariantCultureIgnoreCase) || PendingEvil.Equals("Crimson", StringComparison.InvariantCultureIgnoreCase)) { GenerateVanillaEvilBiome(progress); } else { BiomeLoader.loadedBiomes.Values.Single(b => b.BiomeName.Equals(PendingEvil, StringComparison.InvariantCultureIgnoreCase)).BiomeAlternativeWorldGeneration(progress, pass); } }
public void GenerateEvil(GenerationProgress progress, PassLegacy pass) { if (BiomeWorld.PendingEvil == "Corruption" || BiomeWorld.PendingEvil == "Crimson") { GenerateVanillaEvil(progress, pass); } else { BiomeLibs.Biomes.Values.Single(i => i.BiomeName == BiomeWorld.PendingEvil) .BiomeAltWorldGeneration(progress, pass); } }
private static void RemoveGeneration(string type, List <GenPass> tasks) { int jungleGen = tasks.FindIndex(genpass => genpass.Name.Equals(type)); if (jungleGen != null) { tasks[jungleGen] = new PassLegacy(type + " (removed) ", delegate(GenerationProgress progress) { //nothing to see here WorldGen.TileRunner(Main.spawnTileX, Main.spawnTileY + 12, 6, Main.rand.Next(1, 3), TileID.Dirt, true, 0f, 0f, true, true); }); } }
public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight) { int dungeonIndex = tasks.FindIndex(genPass => genPass.Name.Equals("Dungeon")); //detect whether the config says that randomization will be enabled, if so, randomize if it will swap the dungeon side int swaprand = WorldGen.genRand.Next(2); bool willSwap = GetInstance <swapDungeonConfig>().randomizeSide ? swaprand == 0 : true; if (dungeonIndex != -1 && willSwap) { tasks[dungeonIndex] = new PassLegacy("Dungeon", altDungeonGen); //replace the default dungeon pass with our own } }
public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight) { int resetIndex = tasks.FindIndex(i => i.Name == "Reset"); int terrainIndex = tasks.FindIndex(i => i.Name == "Terrain"); if (terrainIndex != -1) { tasks.Insert(resetIndex + 1, new PassLegacy("Deciding World Evil", (progress) => DecideEvil(progress))); } int evilIndex = tasks.FindIndex(i => i.Name == "Corruption"); if (evilIndex != -1) { vanillaEvilPass = tasks[evilIndex]; tasks[evilIndex] = new PassLegacy("Corruption", (progress) => GenerateEvil(progress, tasks[resetIndex] as PassLegacy)); } }
public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight) { int resetIndex = tasks.FindIndex(t => t.Name.Equals("Reset")), terrainIndex = tasks.FindIndex(t => t.Name.Equals("Terrain")), evilIndex = tasks.FindIndex(t => t.Name.Equals("Corruption")); if (terrainIndex != -1) { tasks.Insert(resetIndex + 1, new PassLegacy("Deciding World Evil Biome", p => DecideEvilBiome(p))); } if (evilIndex != -1) { VanillaEvilPass = tasks[evilIndex]; tasks[evilIndex] = new PassLegacy("Corruption", p => GenerateEvilBiome(p, tasks[resetIndex] as PassLegacy)); } }
public virtual void BiomeAlternativeWorldGeneration(GenerationProgress progress, PassLegacy pass) { }
public void GenerateVanillaEvil(GenerationProgress progress, PassLegacy evilPass) { vanillaEvilPass.Apply(progress); }
public override void ModifyWorldGenTasks(List <GenPass> tasks, ref float totalWeight) { int pots = tasks.FindIndex(i => i.Name == "pots"); if (pots != -1) { tasks[pots] = new PassLegacy("pots", delegate(GenerationProgress progress) { Main.tileSolid[137] = true; Main.tileSolid[130] = true; progress.Message = Lang.gen[35].Value; for (int num262 = 0; num262 < (int)((double)(Main.maxTilesX * Main.maxTilesY) * 0.0008); num262++) { float num263 = (float)((double)num262 / ((double)(Main.maxTilesX * Main.maxTilesY) * 0.0008)); progress.Set(num263); bool flag18 = false; int num264 = 0; while (!flag18) { int num265 = WorldGen.genRand.Next((int)WorldGen.worldSurfaceHigh, Main.maxTilesY - 10); if ((double)num263 > 0.93) { num265 = Main.maxTilesY - 150; } else if ((double)num263 > 0.75) { num265 = (int)WorldGen.worldSurfaceLow; } int num266 = WorldGen.genRand.Next(1, Main.maxTilesX); bool flag19 = false; for (int num267 = num265; num267 < Main.maxTilesY; num267++) { if (!flag19) { if (Main.tile[num266, num267].active() && Main.tileSolid[Main.tile[num266, num267].type] && !Main.tile[num266, num267 - 1].lava()) { flag19 = true; } } else { int style = WorldGen.genRand.Next(0, 4); int tileType = 0; if (num267 < Main.maxTilesY - 5) { tileType = Main.tile[num266, num267 + 1].type; } if (tileType == 147 || tileType == 161 || tileType == 162) { style = WorldGen.genRand.Next(4, 7); } if (tileType == 60) { style = WorldGen.genRand.Next(7, 10); } if (Main.wallDungeon[Main.tile[num266, num267].wall]) { style = WorldGen.genRand.Next(10, 13); } if (tileType == 41 || tileType == 43 || tileType == 44) { style = WorldGen.genRand.Next(10, 13); } if (tileType == 22 || tileType == 23 || tileType == 25) { style = WorldGen.genRand.Next(16, 19); } if (tileType == 199 || tileType == 203 || tileType == 204 || tileType == 200) { style = WorldGen.genRand.Next(22, 25); } if (tileType == 367) { style = WorldGen.genRand.Next(31, 34); } if (tileType == 226) { style = WorldGen.genRand.Next(28, 31); } if (num267 > Main.maxTilesY - 200) { style = WorldGen.genRand.Next(13, 16); } if (WorldGen.PlacePot(num266, num267, 28, style)) { flag18 = true; break; } num264++; if (num264 >= 10000) { flag18 = true; break; } } } } } }); } preChunkGeneration = true; specialPostChunkGenPasses.Clear(); if (worldGenType == "default") { tasks.Add(new PassLegacy("Creating Chunk", p => CreateChunk(p))); tasks.Add(new PassLegacy("ModChunk World Generation", p => GenerateChunk(p))); return; } tasks.Clear(); WorldGenLoader.CreatePassList(tasks, totalWeight); tasks.Add(new PassLegacy("Creating Chunk", p => CreateChunk(p))); foreach (GenPass specialPostChunkGenPass in specialPostChunkGenPasses) { tasks.Add(specialPostChunkGenPass); } tasks.Add(new PassLegacy("ModChunk World Generation", p => GenerateChunk(p))); }
public override void ModifyHardmodeTasks(List <GenPass> list) { if (Config.dontGenerateHardmodeV) { int hardmodeVIndexCorruption = list.FindIndex(genpass => genpass.Name.Equals("Hardmode Evil")); int hardmodeVIndexHallowed = list.FindIndex(genpass => genpass.Name.Equals("Hardmode Good")); if (hardmodeVIndexCorruption != -1 && hardmodeVIndexHallowed != -1) { list[hardmodeVIndexCorruption] = new PassLegacy("Doing Nothing", delegate { }); list[hardmodeVIndexHallowed] = new PassLegacy("Doing Nothing", delegate { }); } } else { int hardmodeIndex = list.FindIndex(genpass => genpass.Name.Equals("Hardmode Walls")); int runs = 0; int worldChunkSize = Config.worldChunkSize; if (hardmodeIndex != -1) { list.Insert(hardmodeIndex + 1, new PassLegacy("Hardmode Clay Clumps", delegate { while (runs < Main.maxTilesX / worldChunkSize) { makeClayClumps(runs * worldChunkSize, (runs + 1) * worldChunkSize); runs++; } })); } } int hardmodeAnnouncementIndex = list.FindIndex(genpass => genpass.Name.Equals("Hardmode Announcment")); int numberOfAltarsToSmash = Config.timesToRunHardmodeOreGen; int runs2 = 0; int somethingIDKWhat = 0; int oreToSpawn = 0; double height = 0; float k = 0; int oreTier1 = Config.hardmodeOreTier1; int oreTier2 = Config.hardmodeOreTier2; int oreTier3 = Config.hardmodeOreTier3; if (hardmodeAnnouncementIndex != -1) { list.Insert(hardmodeAnnouncementIndex + 1, new PassLegacy("Hardmode Ores", delegate { if (!Config.disableAutoHardmodeOreGen) { runs2 = 0; while (runs2 < numberOfAltarsToSmash) { int num = runs2 % 3; int num2 = runs2 / 3 + 1; float num3 = (float)(Main.maxTilesX / 4200); int num4 = 1 - num; num3 = num3 * 310f - (float)(85 * num); num3 *= 0.85f; num3 /= (float)num2; switch (num) { case 0: { if (oreTier1 == 221) { num3 *= 0.9f; } num = oreTier1; num3 *= 1.05f; break; } case 1: { if (oreTier2 == 222) { num3 *= 0.9f; } num = oreTier2; break; } default: { if (oreTier3 == 223) { num3 *= 0.9f; } num = oreTier3; break; } } for (int whatever = 0; (float)whatever < num3; whatever++) { int i2 = WorldGen.genRand.Next(100, Main.maxTilesX - 100); double num8 = Main.worldSurface; if (num == 108 || num == 222) { num8 = Main.rockLayer; } if (num == 111 || num == 223) { num8 = (Main.rockLayer + Main.rockLayer + (double)Main.maxTilesY) / 3.0; } int j2 = WorldGen.genRand.Next((int)num8, Main.maxTilesY - 150); WorldGen.OreRunner(i2, j2, (double)WorldGen.genRand.Next(5, 9 + num4), WorldGen.genRand.Next(5, 9 + num4), (ushort)num); } runs2++; } Main.NewText("Your world has been blessed with hardmode ores equivalent to " + Config.timesToRunHardmodeOreGen + " altars smashed!", 200, 200, 55); } else { } })); } }