Decompiled source of Definite Seeds v1.0.2

BepInEx/plugins/com.binbin.definiteseeds.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.binbin.definiteseeds")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+21db484f0d444cdf432a3a2b3fcb1d682e8e91f8")]
[assembly: AssemblyProduct("SeedSearcher")]
[assembly: AssemblyTitle("com.binbin.definiteseeds")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SeedSearcher
{
	[BepInPlugin("com.binbin.definiteseeds", "SeedSearcher", "1.0.2")]
	[BepInProcess("AcrossTheObelisk.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal int ModDate = int.Parse(DateTime.Today.ToString("yyyyMMdd"));

		private readonly Harmony harmony = new Harmony("com.binbin.definiteseeds");

		internal static ManualLogSource Log;

		public static string debugBase = "com.binbin.definiteseeds ";

		public static ConfigEntry<bool> RunSeedSearcher { get; set; }

		public static ConfigEntry<bool> SearchCaravansForEpicPairs { get; set; }

		public static ConfigEntry<int> NumberOfSeeds { get; set; }

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0047: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_0078: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00ad: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"com.binbin.definiteseeds 1.0.2 has loaded!");
			RunSeedSearcher = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("SeedSearcher", "RunSeedSearcher"), true, new ConfigDescription("If false, disables the mod. Restart the game upon changing this setting.", (AcceptableValueBase)null, Array.Empty<object>()));
			SearchCaravansForEpicPairs = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("SeedSearcher", "SearchCaravansForEpicPairs"), false, new ConfigDescription("Has the game search through seeds on startup for a predefined list of epic pairs. Pairs are stored in the LogOutput.log file. Do not reload the game. To run this, set this value to true and then restart your game. ", (AcceptableValueBase)null, Array.Empty<object>()));
			NumberOfSeeds = ((BaseUnityPlugin)this).Config.Bind<int>(new ConfigDefinition("SeedSearcher", "Seeds to Search"), 2000000, new ConfigDescription("Number of seeds to search through (I believe it takes around 10 minutes to search through 1 millions seeds)", (AcceptableValueBase)null, Array.Empty<object>()));
			LogDebug($"Pre-Log Items {RunSeedSearcher.Value}");
			if (RunSeedSearcher.Value)
			{
				LogDebug("Patching");
				harmony.PatchAll();
			}
			LogDebug($"Post-Log Items {RunSeedSearcher.Value}");
		}

		internal static void LogDebug(string msg)
		{
			Log.LogDebug((object)(debugBase + msg));
		}

		internal static void LogInfo(string msg)
		{
			Log.LogInfo((object)(debugBase + msg));
		}

		internal static void LogError(string msg)
		{
			Log.LogError((object)(debugBase + msg));
		}

		public static string DictToString(Dictionary<string, List<string>> dict)
		{
			if (dict == null)
			{
				throw new ArgumentNullException("dict");
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append('{');
			List<string> list = dict.Keys.OrderBy((string k) => k).ToList();
			for (int i = 0; i < list.Count; i++)
			{
				string text = list[i];
				List<string> list2 = dict[text];
				stringBuilder.Append("\"" + text + "\":[");
				for (int j = 0; j < list2.Count; j++)
				{
					stringBuilder.Append("\"" + list2[j] + "\"");
					if (j < list2.Count - 1)
					{
						stringBuilder.Append(',');
					}
				}
				stringBuilder.Append(']');
				if (i < list.Count - 1)
				{
					stringBuilder.Append(',');
				}
			}
			stringBuilder.Append('}');
			return stringBuilder.ToString();
		}
	}
	[HarmonyPatch]
	public class SeedSearcher
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(AtOManager), "BeginAdventure")]
		public static void BeginAdventurePrefix(ref AtOManager __instance, out string __state)
		{
			Plugin.LogInfo("BeginAdventurePrefix - Start");
			__state = __instance.GetGameId();
			Plugin.LogInfo("BeginAdventurePrefix - GameID - " + __state);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(AtOManager), "BeginAdventure")]
		public static void BeginAdventurePostfix(ref AtOManager __instance, string __state)
		{
			Plugin.LogInfo("BeginAdventurePostfix - Start");
			__instance.SetGameId(__state);
			Plugin.LogInfo("BeginAdventurePostfix - GameID - " + __instance.GetGameId());
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Globals), "CreateGameContent")]
		public static void CreateGameContentPostfix(ref Globals __instance)
		{
			Plugin.LogInfo("CreateGameContentPostfix - Start");
			Dictionary<string, string> itemsAndShops = new Dictionary<string, string>
			{
				{ "lightningspear", "caravanshop" },
				{ "chargedtridentrare", "rubychest" }
			};
			Dictionary<string, string> dictionary = new Dictionary<string, string>
			{
				{ "paladingauntletsrare", "elvenarmoryplus" },
				{ "lightbringerrare", "voidtwins" }
			};
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>
			{
				{ "mjolnirrare", "sahtikrakenmjolmir" },
				{ "strawhatrare", "voidtreasurejade" }
			};
			Plugin.LogDebug(Plugin.SearchCaravansForEpicPairs.Value.ToString());
			if (Plugin.SearchCaravansForEpicPairs.Value)
			{
				List<(string, string)> listOfPairs = new List<(string, string)>(9)
				{
					("destroyergauntlet", "shacklesofwar"),
					("glacialhammer", "frostfirering"),
					("theporcupine", "spikedshoulderpads"),
					("curseddagger", "yinyangbadge"),
					("terrorring", "yinyangbadge"),
					("terrorring", "singingsword"),
					("darkhood", "assassintools"),
					("fountainpen", "cloackofspeed"),
					("fountainpen", "steadfastboots")
				};
				int value = Plugin.NumberOfSeeds.Value;
				string text = DoubleCaravanEpics(listOfPairs, value);
				Plugin.LogDebug("Seed meeting conditions: " + text);
			}
			if (false)
			{
				int value2 = Plugin.NumberOfSeeds.Value;
				string text2 = CheckSeeds(itemsAndShops, value2);
				Plugin.LogDebug("List of Seeds with good things: \n " + text2);
			}
			Plugin.LogInfo("CreateGameContentPostfix - END ");
		}

		internal static void ListInfoFromSeed(string seed, string shop, string node)
		{
			List<string> itemsFromSeed = GetItemsFromSeed(seed, shop, node, 0, _obeliskChallenge: false, 1);
			Plugin.LogDebug(seed);
			Plugin.LogDebug(string.Join(", ", itemsFromSeed));
		}

		internal static string DoubleCaravanEpics(List<(string, string)> listOfPairs, int nSeeds)
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < nSeeds; i++)
			{
				string text = Functions.RandomStringSafe(10f, 0f).ToUpper();
				if (i % 100000 == 0)
				{
					Plugin.LogDebug($"On Seed {i}: {text}");
				}
				List<string> itemsFromSeed = GetItemsFromSeed(text, "caravanshop", "sen_44", 0, _obeliskChallenge: false, 1);
				if (ItemListContains(itemsFromSeed, "darkhood") && ItemListContains(itemsFromSeed, "assassintools") && (ItemListContains(itemsFromSeed, "longbow") || ItemListContains(itemsFromSeed, "twinblades")) && ItemListContains(itemsFromSeed, "brassamulet"))
				{
					Plugin.LogDebug("FOUND THE PERFECT DARKHOOD/ASSASSIN TOOL SEED + " + text);
				}
				foreach (var listOfPair in listOfPairs)
				{
					if ((itemsFromSeed.Contains(listOfPair.Item1) || itemsFromSeed.Contains(listOfPair.Item1 + "rare")) && (itemsFromSeed.Contains(listOfPair.Item2) || itemsFromSeed.Contains(listOfPair.Item2 + "rare")))
					{
						stringBuilder.Append(text + " - " + listOfPair.Item1 + " and " + listOfPair.Item2 + " \n");
						Plugin.LogDebug(text + " - " + listOfPair.Item1 + " and " + listOfPair.Item2);
					}
				}
			}
			return stringBuilder.ToString();
		}

		public static bool ItemListContains(List<string> itemList, string item)
		{
			return itemList.Contains(item) || itemList.Contains(item + "rare");
		}

		internal static bool CheckSingleSeed(string seed, Dictionary<string, string> itemsAndShops, int madness = 1, int corruptorCount = 0)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>
			{
				{ "rubychest", "aqua_20" },
				{ "rubyrefuges", "aqua_20" },
				{ "caravanshop", "sen_44" },
				{ "Basthet", "pyr_7" },
				{ "Dryad_a", "sen_31" },
				{ "Dryad_b", "sen_32" },
				{ "Faeborg", "faen_38" },
				{ "Hydra", "aqua_35" },
				{ "Ignidoh", "velka_32" },
				{ "Mansionright", "faen_35" },
				{ "Mortis", "ulmin_56" },
				{ "Tulah", "spider_8" },
				{ "Ylmer", "sen_33" },
				{ "belphyor", "secta_5" },
				{ "belphyorquest", "velka_8" },
				{ "burninghand", "velka_25" },
				{ "dreadhalfman", "dread_11" },
				{ "elvenarmory", "faen_29" },
				{ "elvenarmoryplus", "faen_29" },
				{ "goblintown", "velka_6" },
				{ "harpychest", "velka_27" },
				{ "harpyfight", "velka_27" },
				{ "khazakdhum", "velka_29" },
				{ "kingrat", "sewers_8" },
				{ "minotaurcave", "velka_9" },
				{ "sahtikraken", "sahti_65" },
				{ "sahtikrakenmjolmir", "sahti_65" },
				{ "sahtirustkingtreasure", "sahti_62" },
				{ "spiderqueen", "sen_1" },
				{ "tyrant", "faen_25" },
				{ "tyrantbeavers", "faen_25" },
				{ "tyrantchampy", "faen_25" },
				{ "tyrantchompy", "faen_25" },
				{ "tyrantchumpy", "faen_25" },
				{ "upripreboss", "uprising_13" },
				{ "yogger", "sen_27" },
				{ "voidtwins", "voidlow_25" },
				{ "voidtreasurejade", "voidlow_16" }
			};
			foreach (KeyValuePair<string, string> itemsAndShop in itemsAndShops)
			{
				string key = itemsAndShop.Key;
				string value = itemsAndShop.Value;
				string text = (dictionary.ContainsKey(value) ? dictionary[value] : "");
				if (text == "")
				{
					Plugin.LogDebug("improper LootLocation - " + value);
					return false;
				}
				List<string> itemsFromSeed = GetItemsFromSeed(seed, value, text, 0, _obeliskChallenge: false, madness, corruptorCount);
				if (itemsFromSeed.Contains("") && !itemsFromSeed.Contains(key))
				{
					return false;
				}
			}
			return true;
		}

		internal static string CheckSeeds(Dictionary<string, string> itemsAndShops, int nSeeds, int madness = 1, int corruptorCount = 0)
		{
			Plugin.LogDebug("CheckSeeds - Begin");
			string result = "";
			for (int i = 0; i < nSeeds; i++)
			{
				string text = Functions.RandomStringSafe(7f, 0f).ToUpper();
				if (i % 10000 == 0)
				{
					Plugin.LogDebug($"On Seed {i}: {text}");
				}
				if (CheckSingleSeed(text, itemsAndShops, madness, corruptorCount))
				{
					result = text;
					break;
				}
			}
			return result;
		}

		internal static void FindSeedWithItems()
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>
			{
				{ "towntier3", "voidlow_1" },
				{ "towntier3_a", "voidlow_1" },
				{ "towntier3_b", "voidlow_1" },
				{ "ruinedplaza", "voidlow_5" },
				{ "ruinedplaza_crit", "voidlow_5" },
				{ "voidasmody", "voidhigh_6" },
				{ "voidshop", "voidlow_8" },
				{ "voidtreasure", "voidlow_16" },
				{ "voidtreasurejade", "voidlow_16" },
				{ "voidtsnemo", "voidlow_24" },
				{ "voidtwins", "voidlow_25" },
				{ "wareacc1", "voidlow_4" },
				{ "wareacc2", "voidlow_4" },
				{ "warearm1", "voidlow_4" },
				{ "warearm2", "voidlow_4" },
				{ "warejew1", "voidlow_4" },
				{ "warejew2", "voidlow_4" },
				{ "warenavalea", "voidlow_4" },
				{ "wareweap1", "voidlow_4" },
				{ "wareweap2", "voidlow_4" },
				{ "aquarvendor", "aqua_26" },
				{ "elvenemporium", "faen_23" },
				{ "felineshop", "ulmin_29" },
				{ "firebazaar", "velka_20" },
				{ "heronshop", "ulmin_27" },
				{ "Merchantwares", "velka_7" },
				{ "voidshop", "voidlow_8" },
				{ "voidtsnemo", "voidlow_24" },
				{ "voodooshop", "aqua_23" },
				{ "Jeweler", "sen_35" },
				{ "gobletsmerchant", "sewers_4" },
				{ "werewolfstall_a", "sen_30" },
				{ "werewolfstall_b", "sen_30" },
				{ "FrozenSewersElves", "sewers_11" },
				{ "FrozenSewersMix", "sewers_11" },
				{ "FrozenSewersRatmen", "sewers_11" },
				{ "Jewelerrings", "sen_35" },
				{ "Mansionleft", "faen_35" },
				{ "Mansionleftplus", "faen_35" },
				{ "Sailor", "faen_4" },
				{ "Stolenitems", "faen_10" },
				{ "apprentince", "sen_24" },
				{ "balanceblack", "ulmin_52" },
				{ "balanceboth", "ulmin_52" },
				{ "balancewhite", "ulmin_52" },
				{ "battlefield", "aqua_6" },
				{ "bridge", "sen_17" },
				{ "chappel", "sen_21" },
				{ "crane", "velka_21" },
				{ "crocoloot", "aqua_7" },
				{ "crocosmugglers", "aqua_48" },
				{ "desertreliquary", "ulmin_58" },
				{ "dreadcosme", "dread_2" },
				{ "dreadcuthbert", "dread_2" },
				{ "dreadfrancis", "dread_2" },
				{ "dreadhoratio", "dread_2" },
				{ "dreadjack", "dread_2" },
				{ "dreadmimic", "dread_10" },
				{ "dreadrhodogor", "dread_2" },
				{ "eeriechest_a", "sen_6" },
				{ "eeriechest_b", "sen_6" },
				{ "lavacascade", "velka_22" },
				{ "lootedarmory", "pyr_10" },
				{ "obsidianall", "forge_3" },
				{ "obsidiananvil", "forge_3" },
				{ "obsidianboots", "forge_3" },
				{ "obsidianrings", "forge_3" },
				{ "obsidianrods", "forge_3" },
				{ "rift", "velka_40" },
				{ "riftsen", "sen_48" },
				{ "sahtibernardstash", "sahti_52" },
				{ "sahtidomedesert", "sahti_49" },
				{ "sahtidomeice", "sahti_49" },
				{ "sahtidomemain", "sahti_49" },
				{ "sahtidomemountain", "sahti_49" },
				{ "sahtidomeswamp", "sahti_49" },
				{ "sahtipiratearsenal", "sahti_25" },
				{ "sahtipiratewarehouse", "sahti_25" },
				{ "sahtiplaguecot", "sahti_11" },
				{ "sahtisurgeonarsenal", "sahti_13" },
				{ "sahtisurgeonstash", "sahti_13" },
				{ "sahtitreasurechamber", "sahti_25" },
				{ "sahtivalkyriestash", "sahti_19" },
				{ "thorimsrod", "forge_8" },
				{ "treasureaquarfall", "aqua_28" },
				{ "uprienergy", "uprising_5" },
				{ "uprimagma", "uprising_4" },
				{ "voidcraftemerald", "voidlow_14" },
				{ "voidcraftgolden", "voidlow_14" },
				{ "voidcraftobsidian", "voidlow_14" },
				{ "voidcraftpearl", "voidlow_14" },
				{ "voidcraftring", "voidlow_14" },
				{ "voidcraftruby", "voidlow_14" },
				{ "voidcraftsapphire", "voidlow_14" },
				{ "voidcrafttopaz", "voidlow_14" },
				{ "voidtreasurejade", "voidlow_16" },
				{ "watermill", "sen_15" },
				{ "Jelly", "aqua_41" },
				{ "betty", "sen_39" },
				{ "blobbleed", "sen_29" },
				{ "blobcold", "sewers_13" },
				{ "blobdire", "velka_37" },
				{ "blobholy", "pyr_12" },
				{ "bloblightning", "sahti_30" },
				{ "blobmetal", "velka_38" },
				{ "blobmind", "dread_7" },
				{ "blobpoison", "aqua_44" },
				{ "blobselem", "voidlow_28" },
				{ "blobshadow", "ulmin_59" },
				{ "blobsmyst", "voidlow_28" },
				{ "blobsphys", "voidlow_28" },
				{ "blobwater", "aqua_45" },
				{ "cuby", "pyr_9" },
				{ "cubyd", "pyr_9" },
				{ "daley", "faen_7" },
				{ "fenny", "ulmin_6" },
				{ "fishlava", "forge_8" },
				{ "inky", "aqua_41" },
				{ "liante", "spider_5" },
				{ "matey", "sahti_20" },
				{ "mimy", "dread_10" },
				{ "oculy", "aqua_41" },
				{ "sharpy", "aqua_18" },
				{ "slimy", "spider_7" },
				{ "stormy", "aqua_24" },
				{ "wolfy", "sen_46" },
				{ "Basthet", "pyr_7" },
				{ "Dryad_a", "sen_31" },
				{ "Dryad_b", "sen_32" },
				{ "Faeborg", "faen_38" },
				{ "Hydra", "aqua_35" },
				{ "Ignidoh", "velka_32" },
				{ "Mansionright", "faen_35" },
				{ "Mortis", "ulmin_56" },
				{ "Tulah", "spider_8" },
				{ "Ylmer", "sen_33" },
				{ "belphyor", "secta_5" },
				{ "belphyorquest", "velka_8" },
				{ "burninghand", "velka_25" },
				{ "dreadhalfman", "dread_11" },
				{ "elvenarmory", "faen_29" },
				{ "elvenarmoryplus", "faen_29" },
				{ "goblintown", "velka_6" },
				{ "harpychest", "velka_27" },
				{ "harpyfight", "velka_27" },
				{ "khazakdhum", "velka_29" },
				{ "kingrat", "sewers_8" },
				{ "minotaurcave", "velka_9" },
				{ "sahtikraken", "sahti_65" },
				{ "sahtikrakenmjolmir", "sahti_65" },
				{ "sahtirustkingtreasure", "sahti_62" },
				{ "spiderqueen", "sen_1" },
				{ "tyrant", "faen_25" },
				{ "tyrantbeavers", "faen_25" },
				{ "tyrantchampy", "faen_25" },
				{ "tyrantchompy", "faen_25" },
				{ "tyrantchumpy", "faen_25" },
				{ "upripreboss", "uprising_13" },
				{ "yogger", "sen_27" }
			};
			List<string> list = new List<string>();
			int num = 5000;
			for (int i = 0; i < num; i++)
			{
				string seed = Functions.RandomStringSafe(7f, 0f).ToUpper();
				List<string> list2 = new List<string>();
				foreach (string key in dictionary.Keys)
				{
					string node = dictionary[key];
					List<string> itemsFromSeed = GetItemsFromSeed(seed, key, node, 0, _obeliskChallenge: false, 1);
				}
			}
		}

		public static void LogAllItems()
		{
			Plugin.LogInfo("LogAllItems - Start");
			LogCaravanItems();
			LogGuaranteedDropItems();
			LogBossDropItems();
			LogPetItems();
			LogMythicItems();
		}

		internal static void LogMythicItems()
		{
			Dictionary<string, string> lootNodeMap = new Dictionary<string, string>
			{
				{ "towntier3", "voidlow_1" },
				{ "towntier3_a", "voidlow_1" },
				{ "towntier3_b", "voidlow_1" },
				{ "ruinedplaza", "voidlow_5" },
				{ "ruinedplaza_crit", "voidlow_5" },
				{ "voidasmody", "voidhigh_6" },
				{ "voidshop", "voidlow_8" },
				{ "voidtreasure", "voidlow_16" },
				{ "voidtreasurejade", "voidlow_16" },
				{ "voidtsnemo", "voidlow_24" },
				{ "voidtwins", "voidlow_25" },
				{ "wareacc1", "voidlow_4" },
				{ "wareacc2", "voidlow_4" },
				{ "warearm1", "voidlow_4" },
				{ "warearm2", "voidlow_4" },
				{ "warejew1", "voidlow_4" },
				{ "warejew2", "voidlow_4" },
				{ "warenavalea", "voidlow_4" },
				{ "wareweap1", "voidlow_4" },
				{ "wareweap2", "voidlow_4" }
			};
			int nSeeds = 2000;
			HandleMythics(lootNodeMap, nSeeds);
			Plugin.LogInfo("Completed Mythic Items");
		}

		internal static void HandleMythics(Dictionary<string, string> lootNodeMap, int nSeeds = 300, bool rareOnly = false)
		{
			Dictionary<string, List<string>> itemDict = new Dictionary<string, List<string>>();
			foreach (string key in lootNodeMap.Keys)
			{
				Plugin.LogDebug("Searching Location " + key);
				for (int i = 0; i < nSeeds; i++)
				{
					string seed = Functions.RandomStringSafe(7f, 0f).ToUpper();
					string node = lootNodeMap[key];
					List<string> itemsFromSeed = GetItemsFromSeed(seed, key, node, 0, _obeliskChallenge: false, 1);
					UpdateItemDictForMythics(ref itemDict, itemsFromSeed, seed, key, 10);
				}
			}
			Plugin.LogDebug("Shop Items - " + Plugin.DictToString(itemDict));
		}

		internal static void LogPetItems()
		{
			Dictionary<string, string> lootNodeMap = new Dictionary<string, string>
			{
				{ "Jelly", "aqua_41" },
				{ "betty", "sen_39" },
				{ "blobbleed", "sen_29" },
				{ "blobcold", "sewers_13" },
				{ "blobdire", "velka_37" },
				{ "blobholy", "pyr_12" },
				{ "bloblightning", "sahti_30" },
				{ "blobmetal", "velka_38" },
				{ "blobmind", "dread_7" },
				{ "blobpoison", "aqua_44" },
				{ "blobselem", "voidlow_28" },
				{ "blobshadow", "ulmin_59" },
				{ "blobsmyst", "voidlow_28" },
				{ "blobsphys", "voidlow_28" },
				{ "blobwater", "aqua_45" },
				{ "cuby", "pyr_9" },
				{ "cubyd", "pyr_9" },
				{ "daley", "faen_7" },
				{ "fenny", "ulmin_6" },
				{ "fishlava", "forge_8" },
				{ "inky", "aqua_41" },
				{ "liante", "spider_5" },
				{ "matey", "sahti_20" },
				{ "mimy", "dread_10" },
				{ "oculy", "aqua_41" },
				{ "sharpy", "aqua_18" },
				{ "slimy", "spider_7" },
				{ "stormy", "aqua_24" },
				{ "wolfy", "sen_46" }
			};
			int nSeeds = 500;
			HandleDropItems(lootNodeMap, nSeeds, rareOnly: true);
			Plugin.LogInfo("Completed Pet Items");
		}

		internal static void LogBossDropItems()
		{
			Dictionary<string, string> lootNodeMap = new Dictionary<string, string>
			{
				{ "Basthet", "pyr_7" },
				{ "Dryad_a", "sen_31" },
				{ "Dryad_b", "sen_32" },
				{ "Faeborg", "faen_38" },
				{ "Hydra", "aqua_35" },
				{ "Ignidoh", "velka_32" },
				{ "Mansionright", "faen_35" },
				{ "Mortis", "ulmin_56" },
				{ "Tulah", "spider_8" },
				{ "Ylmer", "sen_33" },
				{ "belphyor", "secta_5" },
				{ "belphyorquest", "velka_8" },
				{ "burninghand", "velka_25" },
				{ "dreadhalfman", "dread_11" },
				{ "elvenarmory", "faen_29" },
				{ "elvenarmoryplus", "faen_29" },
				{ "goblintown", "velka_6" },
				{ "harpychest", "velka_27" },
				{ "harpyfight", "velka_27" },
				{ "khazakdhum", "velka_29" },
				{ "kingrat", "sewers_8" },
				{ "minotaurcave", "velka_9" },
				{ "sahtikraken", "sahti_65" },
				{ "sahtikrakenmjolmir", "sahti_65" },
				{ "sahtirustkingtreasure", "sahti_62" },
				{ "spiderqueen", "sen_1" },
				{ "tyrant", "faen_25" },
				{ "tyrantbeavers", "faen_25" },
				{ "tyrantchampy", "faen_25" },
				{ "tyrantchompy", "faen_25" },
				{ "tyrantchumpy", "faen_25" },
				{ "upripreboss", "uprising_13" },
				{ "yogger", "sen_27" }
			};
			int nSeeds = 500;
			HandleDropItems(lootNodeMap, nSeeds, rareOnly: true);
			Plugin.LogInfo("Completed Boss Items");
		}

		internal static void LogGuaranteedDropItems()
		{
			Dictionary<string, string> lootNodeMap = new Dictionary<string, string>
			{
				{ "rubychest", "aqua_20" },
				{ "rubyrefuges", "aqua_20" },
				{ "FrozenSewersElves", "sewers_11" },
				{ "FrozenSewersMix", "sewers_11" },
				{ "FrozenSewersRatmen", "sewers_11" },
				{ "Jewelerrings", "sen_35" },
				{ "Mansionleft", "faen_35" },
				{ "Mansionleftplus", "faen_35" },
				{ "Sailor", "faen_4" },
				{ "Stolenitems", "faen_10" },
				{ "apprentince", "sen_24" },
				{ "balanceblack", "ulmin_52" },
				{ "balanceboth", "ulmin_52" },
				{ "balancewhite", "ulmin_52" },
				{ "battlefield", "aqua_6" },
				{ "bridge", "sen_17" },
				{ "chappel", "sen_21" },
				{ "crane", "velka_21" },
				{ "crocoloot", "aqua_7" },
				{ "crocosmugglers", "aqua_48" },
				{ "desertreliquary", "ulmin_58" },
				{ "dreadcosme", "dread_2" },
				{ "dreadcuthbert", "dread_2" },
				{ "dreadfrancis", "dread_2" },
				{ "dreadhoratio", "dread_2" },
				{ "dreadjack", "dread_2" },
				{ "dreadmimic", "dread_10" },
				{ "dreadrhodogor", "dread_2" },
				{ "eeriechest_a", "sen_6" },
				{ "eeriechest_b", "sen_6" },
				{ "lavacascade", "velka_22" },
				{ "lootedarmory", "pyr_10" },
				{ "obsidianall", "forge_3" },
				{ "obsidiananvil", "forge_3" },
				{ "obsidianboots", "forge_3" },
				{ "obsidianrings", "forge_3" },
				{ "obsidianrods", "forge_3" },
				{ "rift", "velka_40" },
				{ "riftsen", "sen_48" },
				{ "sahtibernardstash", "sahti_52" },
				{ "sahtidomedesert", "sahti_49" },
				{ "sahtidomeice", "sahti_49" },
				{ "sahtidomemain", "sahti_49" },
				{ "sahtidomemountain", "sahti_49" },
				{ "sahtidomeswamp", "sahti_49" },
				{ "sahtipiratearsenal", "sahti_25" },
				{ "sahtipiratewarehouse", "sahti_25" },
				{ "sahtiplaguecot", "sahti_11" },
				{ "sahtisurgeonarsenal", "sahti_13" },
				{ "sahtisurgeonstash", "sahti_13" },
				{ "sahtitreasurechamber", "sahti_25" },
				{ "sahtivalkyriestash", "sahti_19" },
				{ "thorimsrod", "forge_8" },
				{ "treasureaquarfall", "aqua_28" },
				{ "uprienergy", "uprising_5" },
				{ "uprimagma", "uprising_4" },
				{ "voidcraftemerald", "voidlow_14" },
				{ "voidcraftgolden", "voidlow_14" },
				{ "voidcraftobsidian", "voidlow_14" },
				{ "voidcraftpearl", "voidlow_14" },
				{ "voidcraftring", "voidlow_14" },
				{ "voidcraftruby", "voidlow_14" },
				{ "voidcraftsapphire", "voidlow_14" },
				{ "voidcrafttopaz", "voidlow_14" },
				{ "voidtreasurejade", "voidlow_16" },
				{ "watermill", "sen_15" }
			};
			int nSeeds = 500;
			HandleDropItems(lootNodeMap, nSeeds, rareOnly: true);
			Plugin.LogInfo("Completed Guaranteed Items");
		}

		internal static void LogShopItems()
		{
			Dictionary<string, string> lootNodeMap = new Dictionary<string, string>
			{
				{ "aquarvendor", "aqua_26" },
				{ "elvenemporium", "faen_23" },
				{ "felineshop", "ulmin_29" },
				{ "firebazaar", "velka_20" }
			};
			int nSeeds = 300;
			HandleDropItems(lootNodeMap, nSeeds);
		}

		internal static void HandleDropItems(Dictionary<string, string> lootNodeMap, int nSeeds = 300, bool rareOnly = false)
		{
			Dictionary<string, List<string>> itemDict = new Dictionary<string, List<string>>();
			foreach (string key in lootNodeMap.Keys)
			{
				LootData lootData = Globals.Instance.GetLootData(key);
				List<string> list = new List<string>();
				LootItem[] lootItemTable = lootData.LootItemTable;
				foreach (LootItem val in lootItemTable)
				{
					if (!((Object)(object)val.LootCard == (Object)null) && val.LootCard.CardName != "")
					{
						if (rareOnly)
						{
							list.Add(val.LootCard.Id + "rare");
						}
						else
						{
							list.Add(val.LootCard.Id);
						}
					}
				}
				Plugin.LogDebug("Shop - " + key + " Valid Items - " + string.Join(", ", list));
				for (int j = 0; j < nSeeds; j++)
				{
					string seed = Functions.RandomStringSafe(7f, 0f).ToUpper();
					string node = lootNodeMap[key];
					List<string> itemsFromSeed = GetItemsFromSeed(seed, key, node, 0, _obeliskChallenge: false, 1);
					UpdateItemDictForShops(ref itemDict, itemsFromSeed, list, seed, key, 10);
				}
			}
			Plugin.LogDebug("Shop Items - " + Plugin.DictToString(itemDict));
		}

		internal static void UpdateItemDictForMythics(ref Dictionary<string, List<string>> itemDict, List<string> itemList, string seed, string shopName, int count = 5)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			foreach (string item in itemList)
			{
				CardData cardData = Globals.Instance.GetCardData(item, false);
				if (!((Object)(object)cardData == (Object)null) && (int)cardData.CardRarity == 4)
				{
					string key = shopName + " - " + cardData.CardName;
					if (!itemDict.ContainsKey(key))
					{
						itemDict.Add(key, new List<string>());
					}
					if (itemDict[key].Count() < count)
					{
						itemDict[key].Add(seed);
					}
				}
			}
		}

		internal static void LogCaravanItems()
		{
			Dictionary<string, List<string>> itemDict = new Dictionary<string, List<string>>();
			int num = 1000;
			for (int i = 0; i < num; i++)
			{
				string seed = Functions.RandomStringSafe(7f, 0f).ToUpper();
				string shop = "caravanshop";
				string node = "sen_44";
				List<string> itemsFromSeed = GetItemsFromSeed(seed, shop, node, 0, _obeliskChallenge: false, 1);
				UpdateItemDict(ref itemDict, itemsFromSeed, seed);
			}
			Plugin.LogDebug("Dictionary - " + Plugin.DictToString(itemDict));
		}

		internal static void UpdateItemDictForShops(ref Dictionary<string, List<string>> itemDict, List<string> itemList, List<string> validItems, string seed, string shopName, int count = 5)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			foreach (string item in itemList)
			{
				if (!validItems.Contains(item))
				{
					continue;
				}
				CardData cardData = Globals.Instance.GetCardData(item, false);
				if (!((Object)(object)cardData == (Object)null) && (int)cardData.CardUpgraded == 3)
				{
					string key = shopName + " - " + cardData.CardName;
					if (!itemDict.ContainsKey(key))
					{
						itemDict.Add(key, new List<string>());
					}
					if (itemDict[key].Count() < count)
					{
						itemDict[key].Add(seed);
					}
				}
			}
		}

		internal static void UpdateItemDict(ref Dictionary<string, List<string>> itemDict, List<string> itemList, string seed, int count = 5)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			foreach (string item in itemList)
			{
				CardData cardData = Globals.Instance.GetCardData(item, false);
				string key = (((int)cardData.CardUpgraded == 3) ? (cardData.CardName + " (Corrupted)") : cardData.CardName);
				if (!itemDict.ContainsKey(key))
				{
					itemDict.Add(key, new List<string>());
				}
				if (itemDict[key].Count() < count)
				{
					itemDict[key].Add(seed);
				}
			}
		}

		internal static List<string> GetItemsFromSeed(string _seed = "", string _shop = "caravanshop", string _node = "", int _townReroll = 0, bool _obeliskChallenge = false, int _madness = 0, int _corruptorCount = 0, bool _poverty = false)
		{
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Invalid comparison between Unknown and I4
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Invalid comparison between Unknown and I4
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Invalid comparison between Unknown and I4
			//IL_067c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0682: Invalid comparison between Unknown and I4
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Invalid comparison between Unknown and I4
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Invalid comparison between Unknown and I4
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Invalid comparison between Unknown and I4
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Invalid comparison between Unknown and I4
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Invalid comparison between Unknown and I4
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Invalid comparison between Unknown and I4
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Invalid comparison between Unknown and I4
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			string text2 = _node;
			if (_shop == "caravanshop" && text2 == "")
			{
				text2 = "sen_44";
			}
			if (_townReroll > 0)
			{
			}
			LootData lootData = Globals.Instance.GetLootData(_shop);
			if ((Object)(object)lootData == (Object)null)
			{
				Plugin.LogError("Unable to get shop items for " + _shop + " (shop does not exist!)");
				return null;
			}
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			for (int i = 0; i < Globals.Instance.CardListByClass[(CardClass)8].Count; i++)
			{
				list2.Add(Globals.Instance.CardListByClass[(CardClass)8][i]);
			}
			int deterministicHashCode = Functions.GetDeterministicHashCode(text2 + _seed + text);
			Random.InitState(deterministicHashCode);
			IListExtensions.Shuffle<string>((IList<string>)list2, deterministicHashCode);
			int num = 0;
			int num2 = ((!_obeliskChallenge) ? lootData.NumItems : lootData.LootItemTable.Length);
			for (int j = 0; j < num2; j++)
			{
				if (list.Count >= lootData.NumItems)
				{
					break;
				}
				if (j >= lootData.LootItemTable.Length)
				{
					continue;
				}
				LootItem val = lootData.LootItemTable[j];
				if (!((double)Random.Range(0, 100) < (double)val.LootPercent))
				{
					continue;
				}
				if ((Object)(object)val.LootCard != (Object)null)
				{
					list.Add(val.LootCard.Id);
					continue;
				}
				bool flag = false;
				int num3 = 0;
				CardData val2 = null;
				while (!flag && num3 < 10000)
				{
					if (num >= list2.Count)
					{
						num = 0;
					}
					string text3 = list2[num];
					if (!list.Contains(text3))
					{
						val2 = Globals.Instance.GetCardData(text3, false);
						if ((Object)(object)val2.Item != (Object)null && !val2.Item.DropOnly)
						{
							if ((int)val2.CardUpgraded == 3)
							{
								flag = false;
							}
							else if (val2.Item.PercentRetentionEndGame > 0 && (_madness > 2 || _obeliskChallenge))
							{
								flag = false;
							}
							else if (val2.Item.PercentDiscountShop > 0 && _poverty)
							{
								flag = false;
							}
							else if ((int)val.LootType == 0 && val2.CardRarity == val.LootRarity)
							{
								flag = true;
							}
							else if (val2.CardType == val.LootType && val2.CardRarity == val.LootRarity)
							{
								flag = true;
							}
						}
					}
					num++;
					num3++;
				}
				if (flag && (Object)(object)val2 != (Object)null)
				{
					list.Add(val2.Id);
				}
			}
			for (int k = list.Count; k < lootData.NumItems; k++)
			{
				bool flag2 = false;
				int num4 = 0;
				CardData val3 = null;
				int num5 = Random.Range(0, 100);
				while (!flag2 && num4 < 10000)
				{
					if (num >= list2.Count)
					{
						num = 0;
					}
					string text4 = list2[num];
					if (!list.Contains(text4))
					{
						val3 = Globals.Instance.GetCardData(text4, false);
						if ((Object)(object)val3.Item != (Object)null && !val3.Item.DropOnly)
						{
							if ((int)val3.CardUpgraded == 3)
							{
								flag2 = false;
							}
							else if (val3.Item.PercentRetentionEndGame > 0 && (_madness > 2 || _obeliskChallenge))
							{
								flag2 = false;
							}
							else if (val3.Item.PercentDiscountShop > 0 && _poverty)
							{
								flag2 = false;
							}
							else if ((double)num5 < (double)lootData.DefaultPercentMythic)
							{
								if ((int)val3.CardRarity == 4)
								{
									flag2 = true;
								}
							}
							else if ((double)num5 < (double)lootData.DefaultPercentEpic + (double)lootData.DefaultPercentMythic)
							{
								if ((int)val3.CardRarity == 3)
								{
									flag2 = true;
								}
							}
							else if ((double)num5 < (double)lootData.DefaultPercentRare + (double)lootData.DefaultPercentEpic + (double)lootData.DefaultPercentMythic)
							{
								if ((int)val3.CardRarity == 2)
								{
									flag2 = true;
								}
							}
							else if ((double)num5 < (double)lootData.DefaultPercentUncommon + (double)lootData.DefaultPercentRare + (double)lootData.DefaultPercentEpic + (double)lootData.DefaultPercentMythic)
							{
								if ((int)val3.CardRarity == 1)
								{
									flag2 = true;
								}
							}
							else if ((int)val3.CardRarity == 0)
							{
								flag2 = true;
							}
						}
					}
					num++;
					num4++;
					if (!flag2 && num4 % 100 == 0)
					{
						num5 += 10;
					}
				}
				if (flag2 && (Object)(object)val3 != (Object)null)
				{
					list.Add(val3.Id);
					continue;
				}
				break;
			}
			IListExtensions.Shuffle<string>((IList<string>)list, deterministicHashCode);
			if (!_shop.Contains("towntier") && ((!_obeliskChallenge && _madness > 0) || _obeliskChallenge))
			{
				int num6 = 0;
				if (_shop.Contains("exoticshop"))
				{
					num6 += 8;
				}
				else if (_shop.Contains("rareshop"))
				{
					num6 += 4;
				}
				if (_obeliskChallenge)
				{
					if (_madness > 8)
					{
						num6 += 4;
					}
					else if (_madness > 4)
					{
						num6 += 2;
					}
				}
				else
				{
					num6 += Functions.FuncRoundToInt(0.2f * (float)(_madness + _corruptorCount));
				}
				for (int l = 0; l < list.Count; l++)
				{
					int num7 = Random.Range(0, 100);
					CardData cardData = Globals.Instance.GetCardData(list[l], false);
					if (!((Object)(object)cardData == (Object)null))
					{
						bool flag3 = false;
						if (((int)cardData.CardRarity == 4 || (int)cardData.CardRarity == 3) && num7 < 3 + num6)
						{
							flag3 = true;
						}
						else if ((int)cardData.CardRarity == 2 && num7 < 5 + num6)
						{
							flag3 = true;
						}
						else if ((int)cardData.CardRarity == 1 && num7 < 7 + num6)
						{
							flag3 = true;
						}
						else if ((int)cardData.CardRarity == 0 && num7 < 9 + num6)
						{
							flag3 = true;
						}
						if (flag3 && (Object)(object)cardData.UpgradesToRare != (Object)null)
						{
							list[l] = cardData.UpgradesToRare.Id;
						}
					}
				}
			}
			return list;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.binbin.definiteseeds";

		public const string PLUGIN_NAME = "SeedSearcher";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}