Decompiled source of Vammopires v1.2.0

plugins/Vammopires.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Alexandria.DungeonAPI;
using Alexandria.EnemyAPI;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using Alexandria.NPCAPI;
using BepInEx;
using Brave.BulletScript;
using Dungeonator;
using FullSerializer;
using Gungeon;
using MonoMod.RuntimeDetour;
using Pathfinding;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Vammopires")]
[assembly: AssemblyDescription("I vant to suck your blood!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Vammopires")]
[assembly: AssemblyCopyright("I Don't Care")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("57445610-0892-47c3-be16-453172104123")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SaveAPI
{
	[fsObject]
	public class AdvancedGameStats
	{
		[fsProperty]
		private Dictionary<CustomTrackedStats, float> stats;

		[fsProperty]
		private Dictionary<CustomTrackedMaximums, float> maxima;

		[fsProperty]
		public HashSet<CustomCharacterSpecificGungeonFlags> m_flags;

		public AdvancedGameStats()
		{
			m_flags = new HashSet<CustomCharacterSpecificGungeonFlags>();
			stats = new Dictionary<CustomTrackedStats, float>(new CustomTrackedStatsComparer());
			maxima = new Dictionary<CustomTrackedMaximums, float>(new CustomTrackedMaximumsComparer());
		}

		public float GetStatValue(CustomTrackedStats statToCheck)
		{
			if (!stats.ContainsKey(statToCheck))
			{
				return 0f;
			}
			return stats[statToCheck];
		}

		public float GetMaximumValue(CustomTrackedMaximums maxToCheck)
		{
			if (!maxima.ContainsKey(maxToCheck))
			{
				return 0f;
			}
			return maxima[maxToCheck];
		}

		public bool GetFlag(CustomCharacterSpecificGungeonFlags flag)
		{
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to get a NONE character-specific save flag!");
				return false;
			}
			return m_flags.Contains(flag);
		}

		public void SetStat(CustomTrackedStats stat, float val)
		{
			if (stats.ContainsKey(stat))
			{
				stats[stat] = val;
			}
			else
			{
				stats.Add(stat, val);
			}
		}

		public void SetMax(CustomTrackedMaximums max, float val)
		{
			if (maxima.ContainsKey(max))
			{
				maxima[max] = Mathf.Max(maxima[max], val);
			}
			else
			{
				maxima.Add(max, val);
			}
		}

		public void SetFlag(CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to set a NONE character-specific save flag!");
			}
			else if (value)
			{
				m_flags.Add(flag);
			}
			else
			{
				m_flags.Remove(flag);
			}
		}

		public void IncrementStat(CustomTrackedStats stat, float val)
		{
			if (stats.ContainsKey(stat))
			{
				stats[stat] += val;
			}
			else
			{
				stats.Add(stat, val);
			}
		}

		public void AddStats(AdvancedGameStats otherStats)
		{
			foreach (KeyValuePair<CustomTrackedStats, float> stat in otherStats.stats)
			{
				IncrementStat(stat.Key, stat.Value);
			}
			foreach (KeyValuePair<CustomTrackedMaximums, float> item in otherStats.maxima)
			{
				SetMax(item.Key, item.Value);
			}
			foreach (CustomCharacterSpecificGungeonFlags flag in otherStats.m_flags)
			{
				m_flags.Add(flag);
			}
		}

		public void ClearAllState()
		{
			List<CustomTrackedStats> list = new List<CustomTrackedStats>();
			foreach (KeyValuePair<CustomTrackedStats, float> stat in stats)
			{
				list.Add(stat.Key);
			}
			foreach (CustomTrackedStats item in list)
			{
				stats[item] = 0f;
			}
			List<CustomTrackedMaximums> list2 = new List<CustomTrackedMaximums>();
			foreach (KeyValuePair<CustomTrackedMaximums, float> item2 in maxima)
			{
				list2.Add(item2.Key);
			}
			foreach (CustomTrackedMaximums item3 in list2)
			{
				maxima[item3] = 0f;
			}
		}
	}
	[fsObject]
	internal class AdvancedGameStatsManager
	{
		private static AdvancedGameStatsManager m_instance;

		[fsProperty]
		public HashSet<CustomDungeonFlags> m_flags;

		[fsProperty]
		public string midGameSaveGuid;

		[fsProperty]
		public Dictionary<PlayableCharacters, AdvancedGameStats> m_characterStats;

		private AdvancedGameStats m_sessionStats;

		private AdvancedGameStats m_savedSessionStats;

		private PlayableCharacters m_sessionCharacter;

		private int m_numCharacters;

		[fsIgnore]
		public int cachedHuntIndex;

		[fsIgnore]
		public SaveSlot cachedSaveSlot;

		[fsIgnore]
		public bool IsInSession => m_sessionStats != null;

		public static bool HasInstance => m_instance != null;

		public static AdvancedGameStatsManager Instance => m_instance;

		public AdvancedGameStatsManager()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			m_flags = new HashSet<CustomDungeonFlags>(new CustomDungeonFlagsComparer());
			m_characterStats = new Dictionary<PlayableCharacters, AdvancedGameStats>((IEqualityComparer<PlayableCharacters>?)new PlayableCharactersComparer());
			m_numCharacters = -1;
			cachedHuntIndex = -1;
		}

		public static void Unload()
		{
			m_instance = null;
		}

		public void SetCharacterSpecificFlag(PlayableCharacters character, CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to set a NONE character-specific save flag!");
				return;
			}
			if (!m_characterStats.ContainsKey(character))
			{
				m_characterStats.Add(character, new AdvancedGameStats());
			}
			if (m_sessionStats != null && m_sessionCharacter == character)
			{
				m_sessionStats.SetFlag(flag, value);
			}
			else
			{
				m_characterStats[character].SetFlag(flag, value);
			}
		}

		public void SetStat(CustomTrackedStats stat, float value)
		{
			if (!float.IsNaN(value) && !float.IsInfinity(value) && m_sessionStats != null)
			{
				m_sessionStats.SetStat(stat, value);
			}
		}

		public void UpdateMaximum(CustomTrackedMaximums maximum, float val)
		{
			if (!float.IsNaN(val) && !float.IsInfinity(val) && m_sessionStats != null)
			{
				m_sessionStats.SetMax(maximum, val);
			}
		}

		public bool GetCharacterSpecificFlag(CustomCharacterSpecificGungeonFlags flag)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GetCharacterSpecificFlag(m_sessionCharacter, flag);
		}

		public bool GetCharacterSpecificFlag(PlayableCharacters character, CustomCharacterSpecificGungeonFlags flag)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to get a NONE character-specific save flag!");
				return false;
			}
			if (m_sessionStats != null && m_sessionCharacter == character)
			{
				if (m_sessionStats.GetFlag(flag))
				{
					return true;
				}
				if (m_savedSessionStats.GetFlag(flag))
				{
					return true;
				}
			}
			AdvancedGameStats value;
			return m_characterStats.TryGetValue(character, out value) && value.GetFlag(flag);
		}

		public static void DoMidgameSave()
		{
			string text = Guid.NewGuid().ToString();
			AdvancedMidGameSaveData advancedMidGameSaveData = new AdvancedMidGameSaveData(text);
			SaveManager.Save<AdvancedMidGameSaveData>(advancedMidGameSaveData, SaveAPIManager.AdvancedMidGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
			Instance.midGameSaveGuid = text;
			Save();
		}

		public void RegisterStatChange(CustomTrackedStats stat, float value)
		{
			if (m_sessionStats == null)
			{
				Debug.LogError((object)"No session stats active and we're registering a stat change!");
			}
			else if (!float.IsNaN(value) && !float.IsInfinity(value) && !(Mathf.Abs(value) > 10000f))
			{
				m_sessionStats.IncrementStat(stat, value);
			}
		}

		public static void InvalidateMidgameSave(bool saveStats)
		{
			AdvancedMidGameSaveData midgameSave = null;
			if (VerifyAndLoadMidgameSave(out midgameSave, checkValidity: false))
			{
				midgameSave.Invalidate();
				SaveManager.Save<AdvancedMidGameSaveData>(midgameSave, SaveAPIManager.AdvancedMidGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
				GameStatsManager.Instance.midGameSaveGuid = midgameSave.midGameSaveGuid;
				if (saveStats)
				{
					GameStatsManager.Save();
				}
			}
		}

		public static void RevalidateMidgameSave(bool saveStats)
		{
			AdvancedMidGameSaveData midgameSave = null;
			if (VerifyAndLoadMidgameSave(out midgameSave, checkValidity: false))
			{
				midgameSave.Revalidate();
				SaveManager.Save<AdvancedMidGameSaveData>(midgameSave, SaveAPIManager.AdvancedMidGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
				GameStatsManager.Instance.midGameSaveGuid = midgameSave.midGameSaveGuid;
				if (saveStats)
				{
					GameStatsManager.Save();
				}
			}
		}

		public static bool VerifyAndLoadMidgameSave(out AdvancedMidGameSaveData midgameSave, bool checkValidity = true)
		{
			if (!SaveManager.Load<AdvancedMidGameSaveData>(SaveAPIManager.AdvancedGameSave, ref midgameSave, true, 0u, (Func<string, uint, string>)null, (SaveSlot?)null))
			{
				Debug.LogError((object)"No mid game save found");
				return false;
			}
			if (midgameSave == null)
			{
				Debug.LogError((object)"Failed to load mid game save (0)");
				return false;
			}
			if (checkValidity && !midgameSave.IsValid())
			{
				return false;
			}
			if (GameStatsManager.Instance.midGameSaveGuid == null || GameStatsManager.Instance.midGameSaveGuid != midgameSave.midGameSaveGuid)
			{
				Debug.LogError((object)"Failed to load mid game save (1)");
				return false;
			}
			return true;
		}

		public void ClearAllStatsGlobal()
		{
			m_sessionStats.ClearAllState();
			m_savedSessionStats.ClearAllState();
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					value.ClearAllState();
				}
			}
		}

		public void ClearStatValueGlobal(CustomTrackedStats stat)
		{
			m_sessionStats.SetStat(stat, 0f);
			m_savedSessionStats.SetStat(stat, 0f);
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					value.SetStat(stat, 0f);
				}
			}
		}

		private PlayableCharacters GetCurrentCharacter()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return GameManager.Instance.PrimaryPlayer.characterIdentity;
		}

		public float GetPlayerMaximum(CustomTrackedMaximums maximum)
		{
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			float num = 0f;
			if (m_sessionStats != null)
			{
				num = Mathf.Max(new float[3]
				{
					num,
					m_sessionStats.GetMaximumValue(maximum),
					m_savedSessionStats.GetMaximumValue(maximum)
				});
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					num = Mathf.Max(num, value.GetMaximumValue(maximum));
				}
			}
			return num;
		}

		public float GetPlayerStatValue(CustomTrackedStats stat)
		{
			if (m_numCharacters <= 0)
			{
				m_numCharacters = Enum.GetValues(typeof(PlayableCharacters)).Length;
			}
			float num = 0f;
			if (m_sessionStats != null)
			{
				num += m_sessionStats.GetStatValue(stat);
			}
			for (int i = 0; i < m_numCharacters; i++)
			{
				if (m_characterStats.TryGetValue((PlayableCharacters)i, out var value))
				{
					num += value.GetStatValue(stat);
				}
			}
			return num;
		}

		public void SetCharacterSpecificFlag(CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SetCharacterSpecificFlag(m_sessionCharacter, flag, value);
		}

		public float GetSessionStatValue(CustomTrackedStats stat)
		{
			return m_sessionStats.GetStatValue(stat) + m_savedSessionStats.GetStatValue(stat);
		}

		public float GetCharacterStatValue(CustomTrackedStats stat)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return GetCharacterStatValue(GetCurrentCharacter(), stat);
		}

		public AdvancedGameStats MoveSessionStatsToSavedSessionStats()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (!IsInSession)
			{
				return null;
			}
			if (m_sessionStats != null)
			{
				if (m_characterStats.ContainsKey(m_sessionCharacter))
				{
					m_characterStats[m_sessionCharacter].AddStats(m_sessionStats);
				}
				m_savedSessionStats.AddStats(m_sessionStats);
				m_sessionStats.ClearAllState();
			}
			return m_savedSessionStats;
		}

		public float GetCharacterStatValue(PlayableCharacters character, CustomTrackedStats stat)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			float num = 0f;
			if (m_sessionCharacter == character)
			{
				num += m_sessionStats.GetStatValue(stat);
			}
			if (m_characterStats.ContainsKey(character))
			{
				num += m_characterStats[character].GetStatValue(stat);
			}
			return num;
		}

		public void BeginNewSession(PlayerController player)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (m_characterStats == null)
			{
				m_characterStats = new Dictionary<PlayableCharacters, AdvancedGameStats>((IEqualityComparer<PlayableCharacters>?)new PlayableCharactersComparer());
			}
			if (IsInSession)
			{
				m_sessionCharacter = player.characterIdentity;
				if (!m_characterStats.ContainsKey(player.characterIdentity))
				{
					m_characterStats.Add(player.characterIdentity, new AdvancedGameStats());
				}
				return;
			}
			m_sessionCharacter = player.characterIdentity;
			m_sessionStats = new AdvancedGameStats();
			m_savedSessionStats = new AdvancedGameStats();
			if (!m_characterStats.ContainsKey(player.characterIdentity))
			{
				m_characterStats.Add(player.characterIdentity, new AdvancedGameStats());
			}
		}

		public void EndSession(bool recordSessionStats)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (IsInSession && m_sessionStats != null)
			{
				if (recordSessionStats && m_characterStats.ContainsKey(m_sessionCharacter))
				{
					m_characterStats[m_sessionCharacter].AddStats(m_sessionStats);
				}
				m_sessionStats = null;
				m_savedSessionStats = null;
			}
		}

		public static void Load()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			SaveManager.Init();
			bool flag = false;
			SaveSlot? val = null;
			int num = -1;
			if (m_instance != null)
			{
				flag = true;
				val = m_instance.cachedSaveSlot;
				num = m_instance.cachedHuntIndex;
			}
			if (!SaveManager.Load<AdvancedGameStatsManager>(SaveAPIManager.AdvancedGameSave, ref m_instance, true, 0u, (Func<string, uint, string>)null, (SaveSlot?)null))
			{
				m_instance = new AdvancedGameStatsManager();
			}
			m_instance.cachedSaveSlot = SaveManager.CurrentSaveSlot;
			if (flag && val.HasValue && m_instance.cachedSaveSlot == val.Value)
			{
				m_instance.cachedHuntIndex = num;
			}
			else
			{
				m_instance.cachedHuntIndex = -1;
			}
		}

		public static void DANGEROUS_ResetAllStats()
		{
			m_instance = new AdvancedGameStatsManager();
			SaveManager.DeleteAllBackups(SaveAPIManager.AdvancedGameSave, (SaveSlot?)null);
		}

		public bool GetFlag(CustomDungeonFlags flag)
		{
			if (flag == CustomDungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to get a NONE save flag!");
				return false;
			}
			return m_flags.Contains(flag);
		}

		public void SetFlag(CustomDungeonFlags flag, bool value)
		{
			if (flag == CustomDungeonFlags.NONE)
			{
				Debug.LogError((object)"Something is attempting to set a NONE save flag!");
			}
			else if (value)
			{
				m_flags.Add(flag);
			}
			else
			{
				m_flags.Remove(flag);
			}
		}

		public static bool Save()
		{
			bool result = false;
			try
			{
				result = SaveManager.Save<AdvancedGameStatsManager>(m_instance, SaveAPIManager.AdvancedGameSave, GameStatsManager.Instance.PlaytimeMin, 0u, (SaveSlot?)null);
			}
			catch (Exception ex)
			{
				Debug.LogErrorFormat("SAVE FAILED: {0}", new object[1] { ex });
			}
			return result;
		}

		public void AssignMidGameSavedSessionStats(AdvancedGameStats source)
		{
			if (IsInSession && m_savedSessionStats != null)
			{
				m_savedSessionStats.AddStats(source);
			}
		}
	}
	public class AdvancedMidGameSaveData
	{
		[fsProperty]
		public AdvancedGameStats PriorSessionStats;

		[fsProperty]
		public string midGameSaveGuid;

		[fsProperty]
		public bool invalidated;

		public AdvancedMidGameSaveData(string midGameSaveGuid)
		{
			this.midGameSaveGuid = midGameSaveGuid;
			PriorSessionStats = AdvancedGameStatsManager.Instance.MoveSessionStatsToSavedSessionStats();
		}

		public bool IsValid()
		{
			return !invalidated;
		}

		public void Invalidate()
		{
			invalidated = true;
		}

		public void Revalidate()
		{
			invalidated = false;
		}

		public void LoadDataFromMidGameSave()
		{
			AdvancedGameStatsManager.Instance.AssignMidGameSavedSessionStats(PriorSessionStats);
		}
	}
	public static class BreachShopTool
	{
		public class DoubleMetaShopTier
		{
			private MetaShopTier m_topTier;

			private MetaShopTier m_bottomTier;

			public DoubleMetaShopTier(MetaShopTier topTier, MetaShopTier bottomTier)
			{
				m_topTier = topTier;
				m_bottomTier = bottomTier;
			}

			public DoubleMetaShopTier(DoubleMetaShopTier other)
			{
				m_topTier = other.m_topTier;
				m_bottomTier = other.m_bottomTier;
			}

			public MetaShopTier GetTopTier()
			{
				return m_topTier;
			}

			public MetaShopTier GetBottomTier()
			{
				return m_topTier;
			}

			public List<MetaShopTier> GetTierList()
			{
				return new List<MetaShopTier> { m_topTier, m_bottomTier };
			}
		}

		public static MetaShopController BaseMetaShopController;

		public static GenericLootTable TrorcMetaShopItems;

		public static GenericLootTable GooptonMetaShopItems;

		public static GenericLootTable DougMetaShopItems;

		private static FieldInfo ItemControllersInfo = typeof(ShopController).GetField("m_itemControllers", BindingFlags.Instance | BindingFlags.NonPublic);

		private static FieldInfo BaseItemControllersInfo = typeof(BaseShopController).GetField("m_itemControllers", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Hook pickupObjectEncounterableHook;

		private static Hook baseShopSetupHook;

		private static Hook metaShopSetupHook;

		private static Hook metaShopCurrentTierHook;

		private static Hook metaShopProximateTierHook;

		public static Dictionary<WeightedGameObjectCollection, List<WeightedGameObject>> baseShopAddedItems;

		public static List<MetaShopTier> metaShopAddedTiers;

		private static bool m_loaded;

		public static void DoSetup()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			if (!m_loaded)
			{
				BaseMetaShopController = SaveTools.LoadAssetFromAnywhere<GameObject>("Foyer_MetaShop").GetComponent<MetaShopController>();
				TrorcMetaShopItems = SaveTools.LoadAssetFromAnywhere<GenericLootTable>("Shop_Truck_Meta");
				GooptonMetaShopItems = SaveTools.LoadAssetFromAnywhere<GenericLootTable>("Shop_Goop_Meta");
				DougMetaShopItems = SaveTools.LoadAssetFromAnywhere<GenericLootTable>("Shop_Beetle_Meta");
				pickupObjectEncounterableHook = new Hook((MethodBase)typeof(PickupObject).GetMethod("HandleEncounterable", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("HandleEncounterableHook"));
				baseShopSetupHook = new Hook((MethodBase)typeof(BaseShopController).GetMethod("DoSetup", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("BaseShopSetupHook"));
				metaShopSetupHook = new Hook((MethodBase)typeof(MetaShopController).GetMethod("DoSetup", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("MetaSetupHook"));
				metaShopCurrentTierHook = new Hook((MethodBase)typeof(MetaShopController).GetMethod("GetCurrentTier", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("MetaShopCurrentTierHook"));
				metaShopProximateTierHook = new Hook((MethodBase)typeof(MetaShopController).GetMethod("GetProximateTier", BindingFlags.Instance | BindingFlags.NonPublic), typeof(BreachShopTool).GetMethod("MetaShopProximateTierHook"));
				m_loaded = true;
			}
		}

		public static void Unload()
		{
			if (!m_loaded)
			{
				return;
			}
			if (baseShopAddedItems != null)
			{
				for (int i = 0; i < baseShopAddedItems.Keys.Count; i++)
				{
					WeightedGameObjectCollection val = baseShopAddedItems.Keys.ToList()[i];
					if (val == null || baseShopAddedItems[val] == null)
					{
						continue;
					}
					for (int j = 0; j < baseShopAddedItems[val].Count; j++)
					{
						WeightedGameObject val2 = baseShopAddedItems[val][j];
						if (val2 != null && val.elements.Contains(val2))
						{
							val.elements.Remove(val2);
						}
					}
				}
				baseShopAddedItems.Clear();
				baseShopAddedItems = null;
			}
			if (metaShopAddedTiers != null)
			{
				for (int k = 0; k < metaShopAddedTiers.Count; k++)
				{
					MetaShopTier val3 = metaShopAddedTiers[k];
					if (val3 != null && BaseMetaShopController.metaShopTiers.Contains(val3))
					{
						BaseMetaShopController.metaShopTiers.Remove(val3);
					}
				}
				metaShopAddedTiers.Clear();
				metaShopAddedTiers = null;
			}
			BaseMetaShopController = null;
			TrorcMetaShopItems = null;
			GooptonMetaShopItems = null;
			DougMetaShopItems = null;
			Hook obj = pickupObjectEncounterableHook;
			if (obj != null)
			{
				obj.Dispose();
			}
			Hook obj2 = baseShopSetupHook;
			if (obj2 != null)
			{
				obj2.Dispose();
			}
			Hook obj3 = metaShopSetupHook;
			if (obj3 != null)
			{
				obj3.Dispose();
			}
			Hook obj4 = metaShopCurrentTierHook;
			if (obj4 != null)
			{
				obj4.Dispose();
			}
			Hook obj5 = metaShopProximateTierHook;
			if (obj5 != null)
			{
				obj5.Dispose();
			}
			m_loaded = false;
		}

		public static void HandleEncounterableHook(Action<PickupObject, PlayerController> orig, PickupObject po, PlayerController player)
		{
			orig(po, player);
			if ((Object)(object)po != (Object)null && (Object)(object)((Component)po).GetComponent<SpecialPickupObject>() != (Object)null && ((Component)po).GetComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition != 0)
			{
				AdvancedGameStatsManager.Instance.SetFlag(((Component)po).GetComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition, value: true);
			}
		}

		public static void BaseShopSetupHook(Action<BaseShopController> orig, BaseShopController self)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			orig(self);
			if ((int)self.baseShopType != 6 || !((Object)(object)self.ExampleBlueprintPrefab != (Object)null))
			{
				return;
			}
			List<ShopItemController> list = (List<ShopItemController>)BaseItemControllersInfo.GetValue(self);
			if (list == null)
			{
				return;
			}
			foreach (ShopItemController item in list)
			{
				if (!((Object)(object)item != (Object)null) || !((Object)(object)item.item != (Object)null) || !((Object)(object)((BraveBehaviour)item.item).encounterTrackable != (Object)null) || ((BraveBehaviour)item.item).encounterTrackable.journalData == null)
				{
					continue;
				}
				PickupObject blueprintUnlockedItem = GetBlueprintUnlockedItem(((BraveBehaviour)item.item).encounterTrackable);
				if (!((Object)(object)blueprintUnlockedItem != (Object)null) || !((Object)(object)((BraveBehaviour)blueprintUnlockedItem).encounterTrackable != (Object)null) || ((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites == null)
				{
					continue;
				}
				CustomDungeonFlags customDungeonFlags = CustomDungeonFlags.NONE;
				for (int i = 0; i < ((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites.Length; i++)
				{
					if (((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites[i] is CustomDungeonPrerequisite && (((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).advancedPrerequisiteType == CustomDungeonPrerequisite.AdvancedPrerequisiteType.CUSTOM_FLAG)
					{
						customDungeonFlags = (((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).customFlagToCheck;
					}
				}
				if (customDungeonFlags != 0)
				{
					((Component)item.item).gameObject.AddComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition = customDungeonFlags;
				}
			}
		}

		public static void MetaSetupHook(Action<MetaShopController> orig, MetaShopController meta)
		{
			orig(meta);
			List<ShopItemController> list = (List<ShopItemController>)ItemControllersInfo.GetValue(meta);
			if (list == null)
			{
				return;
			}
			foreach (ShopItemController item in list)
			{
				if (!((Object)(object)item != (Object)null) || !((Object)(object)item.item != (Object)null) || !((Object)(object)((BraveBehaviour)item.item).encounterTrackable != (Object)null) || ((BraveBehaviour)item.item).encounterTrackable.journalData == null)
				{
					continue;
				}
				PickupObject blueprintUnlockedItem = GetBlueprintUnlockedItem(((BraveBehaviour)item.item).encounterTrackable);
				if (!((Object)(object)blueprintUnlockedItem != (Object)null) || !((Object)(object)((BraveBehaviour)blueprintUnlockedItem).encounterTrackable != (Object)null) || ((BraveBehaviour)blueprintUnlockedItem).encounterTrackable.prerequisites == null)
				{
					continue;
				}
				CustomDungeonFlags customFlagFromTargetItem = GetCustomFlagFromTargetItem(blueprintUnlockedItem.PickupObjectId);
				if (customFlagFromTargetItem != 0)
				{
					((Component)item.item).gameObject.AddComponent<SpecialPickupObject>().CustomSaveFlagToSetOnAcquisition = customFlagFromTargetItem;
					if (AdvancedGameStatsManager.Instance.GetFlag(customFlagFromTargetItem))
					{
						item.ForceOutOfStock();
					}
				}
			}
		}

		private static bool GetMetaItemUnlockedAdvanced(int pickupObjectId)
		{
			CustomDungeonFlags customFlagFromTargetItem = GetCustomFlagFromTargetItem(pickupObjectId);
			if (customFlagFromTargetItem == CustomDungeonFlags.NONE)
			{
				return true;
			}
			return AdvancedGameStatsManager.Instance.GetFlag(customFlagFromTargetItem);
		}

		public static MetaShopTier MetaShopCurrentTierHook(Func<MetaShopController, MetaShopTier> orig, MetaShopController self)
		{
			MetaShopTier val = null;
			for (int i = 0; i < self.metaShopTiers.Count; i++)
			{
				if (!GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId1) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId2) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId3))
				{
					val = self.metaShopTiers[i];
					break;
				}
			}
			List<MetaShopTier> metaShopTiers = self.metaShopTiers;
			List<MetaShopTier> list = new List<MetaShopTier>();
			for (int j = 0; j < metaShopTiers.Count; j++)
			{
				if (metaShopTiers[j] != null && (!ItemConditionsFulfilled(metaShopTiers[j].itemId1) || !ItemConditionsFulfilled(metaShopTiers[j].itemId2) || !ItemConditionsFulfilled(metaShopTiers[j].itemId3) || j == metaShopTiers.Count - 1))
				{
					list.Add(metaShopTiers[j]);
				}
			}
			self.metaShopTiers = list;
			MetaShopTier val2 = orig(self);
			self.metaShopTiers = metaShopTiers;
			if (val == null)
			{
				return val2;
			}
			if (val2 == null)
			{
				return val;
			}
			return (self.metaShopTiers.IndexOf(val) < self.metaShopTiers.IndexOf(val2)) ? val : val2;
		}

		public static MetaShopTier MetaShopProximateTierHook(Func<MetaShopController, MetaShopTier> orig, MetaShopController self)
		{
			MetaShopTier val = null;
			for (int i = 0; i < self.metaShopTiers.Count - 1; i++)
			{
				if (!GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId1) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId2) || !GetMetaItemUnlockedAdvanced(self.metaShopTiers[i].itemId3))
				{
					val = self.metaShopTiers[i + 1];
					break;
				}
			}
			List<MetaShopTier> metaShopTiers = self.metaShopTiers;
			List<MetaShopTier> list = new List<MetaShopTier>();
			for (int j = 0; j < metaShopTiers.Count; j++)
			{
				if (metaShopTiers[j] != null && (!ItemConditionsFulfilled(metaShopTiers[j].itemId1) || !ItemConditionsFulfilled(metaShopTiers[j].itemId2) || !ItemConditionsFulfilled(metaShopTiers[j].itemId3)))
				{
					list.Add(metaShopTiers[j]);
				}
			}
			self.metaShopTiers = list;
			MetaShopTier val2 = orig(self);
			self.metaShopTiers = metaShopTiers;
			if (val == null)
			{
				return val2;
			}
			if (val2 == null)
			{
				return val;
			}
			return (self.metaShopTiers.IndexOf(val) < self.metaShopTiers.IndexOf(val2)) ? val : val2;
		}

		public static CustomDungeonFlags GetCustomFlagFromTargetItem(int shopItemId)
		{
			CustomDungeonFlags result = CustomDungeonFlags.NONE;
			PickupObject byId = PickupObjectDatabase.GetById(shopItemId);
			for (int i = 0; i < ((BraveBehaviour)byId).encounterTrackable.prerequisites.Length; i++)
			{
				if (((BraveBehaviour)byId).encounterTrackable.prerequisites[i] is CustomDungeonPrerequisite && (((BraveBehaviour)byId).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).advancedPrerequisiteType == CustomDungeonPrerequisite.AdvancedPrerequisiteType.CUSTOM_FLAG)
				{
					result = (((BraveBehaviour)byId).encounterTrackable.prerequisites[i] as CustomDungeonPrerequisite).customFlagToCheck;
				}
			}
			return result;
		}

		public static GungeonFlags GetFlagFromTargetItem(int shopItemId)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			GungeonFlags result = (GungeonFlags)0;
			PickupObject byId = PickupObjectDatabase.GetById(shopItemId);
			for (int i = 0; i < ((BraveBehaviour)byId).encounterTrackable.prerequisites.Length; i++)
			{
				if ((int)((BraveBehaviour)byId).encounterTrackable.prerequisites[i].prerequisiteType == 4)
				{
					result = ((BraveBehaviour)byId).encounterTrackable.prerequisites[i].saveFlagToCheck;
				}
			}
			return result;
		}

		public static bool ItemConditionsFulfilled(int shopItemId)
		{
			return (Object)(object)PickupObjectDatabase.GetById(shopItemId) != (Object)null && PickupObjectDatabase.GetById(shopItemId).PrerequisitesMet();
		}

		public static PickupObject GetBlueprintUnlockedItem(EncounterTrackable blueprintTrackable)
		{
			for (int i = 0; i < ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects.Count; i++)
			{
				PickupObject val = ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects[i];
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				EncounterTrackable encounterTrackable = ((BraveBehaviour)val).encounterTrackable;
				if (!Object.op_Implicit((Object)(object)encounterTrackable))
				{
					continue;
				}
				string primaryDisplayName = encounterTrackable.journalData.PrimaryDisplayName;
				if (!primaryDisplayName.Equals(blueprintTrackable.journalData.PrimaryDisplayName, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				string notificationPanelDescription = encounterTrackable.journalData.NotificationPanelDescription;
				if (!notificationPanelDescription.Equals(blueprintTrackable.journalData.NotificationPanelDescription, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				string ammonomiconFullEntry = encounterTrackable.journalData.AmmonomiconFullEntry;
				if (ammonomiconFullEntry.Equals(blueprintTrackable.journalData.AmmonomiconFullEntry, StringComparison.OrdinalIgnoreCase))
				{
					string ammonomiconSprite = encounterTrackable.journalData.AmmonomiconSprite;
					if (ammonomiconSprite.Equals(blueprintTrackable.journalData.AmmonomiconSprite, StringComparison.OrdinalIgnoreCase))
					{
						return val;
					}
				}
			}
			return null;
		}

		public static WeightedGameObject AddItemToTrorcMetaShop(this PickupObject po, int cost, int? index = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)TrorcMetaShopItems == (Object)null)
			{
				DoSetup();
			}
			WeightedGameObject val = new WeightedGameObject();
			val.rawGameObject = null;
			val.pickupId = po.PickupObjectId;
			val.weight = cost;
			val.forceDuplicatesPossible = false;
			val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			WeightedGameObject val2 = val;
			if (!index.HasValue)
			{
				TrorcMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else if (index.Value < 0)
			{
				TrorcMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else
			{
				TrorcMetaShopItems.defaultItemDrops.elements.InsertOrAdd(index.Value, val2);
			}
			RegisterBaseShopControllerAddedItem(val2, TrorcMetaShopItems.defaultItemDrops);
			return val2;
		}

		public static WeightedGameObject AddItemToGooptonMetaShop(this PickupObject po, int cost, int? index = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)GooptonMetaShopItems == (Object)null)
			{
				DoSetup();
			}
			WeightedGameObject val = new WeightedGameObject();
			val.rawGameObject = null;
			val.pickupId = po.PickupObjectId;
			val.weight = cost;
			val.forceDuplicatesPossible = false;
			val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			WeightedGameObject val2 = val;
			if (!index.HasValue)
			{
				GooptonMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else if (index.Value < 0)
			{
				TrorcMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else
			{
				GooptonMetaShopItems.defaultItemDrops.elements.InsertOrAdd(index.Value, val2);
			}
			RegisterBaseShopControllerAddedItem(val2, GooptonMetaShopItems.defaultItemDrops);
			return val2;
		}

		public static WeightedGameObject AddItemToDougMetaShop(this PickupObject po, int cost, int? index = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if ((Object)(object)DougMetaShopItems == (Object)null)
			{
				DoSetup();
			}
			WeightedGameObject val = new WeightedGameObject();
			val.rawGameObject = null;
			val.pickupId = po.PickupObjectId;
			val.weight = cost;
			val.forceDuplicatesPossible = false;
			val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
			WeightedGameObject val2 = val;
			if (!index.HasValue)
			{
				DougMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else if (index.Value < 0)
			{
				DougMetaShopItems.defaultItemDrops.elements.Add(val2);
			}
			else
			{
				DougMetaShopItems.defaultItemDrops.elements.InsertOrAdd(index.Value, val2);
			}
			RegisterBaseShopControllerAddedItem(val2, DougMetaShopItems.defaultItemDrops);
			return val2;
		}

		private static void RegisterBaseShopControllerAddedItem(WeightedGameObject obj, WeightedGameObjectCollection collection)
		{
			if (baseShopAddedItems == null)
			{
				baseShopAddedItems = new Dictionary<WeightedGameObjectCollection, List<WeightedGameObject>>();
			}
			if (!baseShopAddedItems.ContainsKey(collection))
			{
				baseShopAddedItems.Add(collection, new List<WeightedGameObject>());
			}
			if (baseShopAddedItems[collection] == null)
			{
				baseShopAddedItems[collection] = new List<WeightedGameObject>();
			}
			baseShopAddedItems[collection].Add(obj);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(int topLeftItemId, int topLeftItemPrice, int topMiddleItemId, int topMiddleItemPrice, int topRightItemId, int topRightItemPrice, int bottomLeftItemId, int bottomLeftItemPrice, int bottomMiddleItemId, int bottomMiddleItemPrice, int bottomRightItemId, int bottomRightItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_007a: Expected O, but got Unknown
			//IL_007a: Expected O, but got Unknown
			return AddBaseMetaShopDoubleTier(new DoubleMetaShopTier(new MetaShopTier
			{
				itemId1 = topLeftItemId,
				overrideItem1Cost = topLeftItemPrice,
				itemId2 = topMiddleItemId,
				overrideItem2Cost = topMiddleItemPrice,
				itemId3 = topRightItemId,
				overrideItem3Cost = topRightItemPrice,
				overrideTierCost = topLeftItemId
			}, new MetaShopTier
			{
				itemId1 = bottomLeftItemId,
				overrideItem1Cost = bottomLeftItemPrice,
				itemId2 = bottomMiddleItemId,
				overrideItem2Cost = bottomMiddleItemPrice,
				itemId3 = bottomRightItemId,
				overrideItem3Cost = bottomRightItemPrice,
				overrideTierCost = topLeftItemId
			}), index);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(int topLeftItemId, int topLeftItemPrice, int topMiddleItemId, int topMiddleItemPrice, int topRightItemId, int topRightItemPrice, int bottomLeftItemId, int bottomLeftItemPrice, int bottomMiddleItemId, int bottomMiddleItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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
			return AddBaseMetaShopDoubleTier(new DoubleMetaShopTier(new MetaShopTier
			{
				itemId1 = topLeftItemId,
				overrideItem1Cost = topLeftItemPrice,
				itemId2 = topMiddleItemId,
				overrideItem2Cost = topMiddleItemPrice,
				itemId3 = topRightItemId,
				overrideItem3Cost = topRightItemPrice,
				overrideTierCost = topLeftItemId
			}, new MetaShopTier
			{
				itemId1 = bottomLeftItemId,
				overrideItem1Cost = bottomLeftItemPrice,
				itemId2 = bottomMiddleItemId,
				overrideItem2Cost = bottomMiddleItemPrice,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = topLeftItemId
			}), index);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(int topLeftItemId, int topLeftItemPrice, int topMiddleItemId, int topMiddleItemPrice, int topRightItemId, int topRightItemPrice, int bottomLeftItemId, int bottomLeftItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0076: Expected O, but got Unknown
			return AddBaseMetaShopDoubleTier(new DoubleMetaShopTier(new MetaShopTier
			{
				itemId1 = topLeftItemId,
				overrideItem1Cost = topLeftItemPrice,
				itemId2 = topMiddleItemId,
				overrideItem2Cost = topMiddleItemPrice,
				itemId3 = topRightItemId,
				overrideItem3Cost = topRightItemPrice,
				overrideTierCost = topLeftItemId
			}, new MetaShopTier
			{
				itemId1 = bottomLeftItemId,
				overrideItem1Cost = bottomLeftItemPrice,
				itemId2 = -1,
				overrideItem2Cost = -1,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = topLeftItemId
			}), index);
		}

		public static MetaShopTier AddBaseMetaShopTier(int leftItemId, int leftItemPrice, int middleItemId, int middleItemPrice, int rightItemId, int rightItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			return AddBaseMetaShopTier(new MetaShopTier
			{
				itemId1 = leftItemId,
				overrideItem1Cost = leftItemPrice,
				itemId2 = middleItemId,
				overrideItem2Cost = middleItemPrice,
				itemId3 = rightItemId,
				overrideItem3Cost = rightItemPrice,
				overrideTierCost = leftItemPrice
			}, index);
		}

		public static MetaShopTier AddBaseMetaShopTier(int leftItemId, int leftItemPrice, int middleItemId, int middleItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			return AddBaseMetaShopTier(new MetaShopTier
			{
				itemId1 = leftItemId,
				overrideItem1Cost = leftItemPrice,
				itemId2 = middleItemId,
				overrideItem2Cost = middleItemPrice,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = leftItemPrice
			}, index);
		}

		public static MetaShopTier AddBaseMetaShopTier(int leftItemId, int leftItemPrice, int? index = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			return AddBaseMetaShopTier(new MetaShopTier
			{
				itemId1 = leftItemId,
				overrideItem1Cost = leftItemPrice,
				itemId2 = -1,
				overrideItem2Cost = -1,
				itemId3 = -1,
				overrideItem3Cost = -1,
				overrideTierCost = leftItemPrice
			}, index);
		}

		public static List<MetaShopTier> AddBaseMetaShopDoubleTier(DoubleMetaShopTier tier, int? index = null)
		{
			return new List<MetaShopTier>
			{
				AddBaseMetaShopTier(tier.GetBottomTier(), index),
				AddBaseMetaShopTier(tier.GetTopTier(), index)
			};
		}

		public static MetaShopTier AddBaseMetaShopTier(MetaShopTier tier, int? index = null)
		{
			if ((Object)(object)BaseMetaShopController == (Object)null)
			{
				DoSetup();
			}
			if (!index.HasValue)
			{
				BaseMetaShopController.metaShopTiers.Add(tier);
			}
			else if (index.Value < 0)
			{
				BaseMetaShopController.metaShopTiers.Add(tier);
			}
			else
			{
				BaseMetaShopController.metaShopTiers.InsertOrAdd(index.Value, tier);
			}
			if (metaShopAddedTiers == null)
			{
				metaShopAddedTiers = new List<MetaShopTier>();
			}
			metaShopAddedTiers.Add(tier);
			ReloadInstanceMetaShopTiers();
			return tier;
		}

		public static void ReloadInstanceMetaShopTiers()
		{
			MetaShopController[] array = Object.FindObjectsOfType<MetaShopController>();
			foreach (MetaShopController val in array)
			{
				val.metaShopTiers = SaveTools.CloneList(BaseMetaShopController.metaShopTiers);
			}
		}
	}
	public class CustomDungeonPrerequisite : DungeonPrerequisite
	{
		public enum AdvancedPrerequisiteType
		{
			NONE,
			CUSTOM_FLAG,
			CUSTOM_STAT_COMPARISION,
			CUSTOM_MAXIMUM_COMPARISON,
			NUMBER_PASTS_COMPLETED_BETTER,
			ENCOUNTER_OR_CUSTOM_FLAG
		}

		public AdvancedPrerequisiteType advancedPrerequisiteType;

		public CustomDungeonFlags customFlagToCheck;

		public bool requireCustomFlag;

		public Type requiredPassiveFlag;

		public CustomTrackedMaximums customMaximumToCheck;

		public CustomTrackedStats customStatToCheck;

		public virtual bool CheckConditionsFulfilled()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected I4, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected I4, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected I4, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected I4, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Expected I4, but got Unknown
			if (advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_FLAG)
			{
				return AdvancedGameStatsManager.Instance.GetFlag(customFlagToCheck) == requireCustomFlag;
			}
			if (advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_STAT_COMPARISION)
			{
				float playerStatValue = AdvancedGameStatsManager.Instance.GetPlayerStatValue(customStatToCheck);
				PrerequisiteOperation prerequisiteOperation = base.prerequisiteOperation;
				PrerequisiteOperation val = prerequisiteOperation;
				switch ((int)val)
				{
				case 0:
					return playerStatValue < base.comparisonValue;
				case 1:
					return playerStatValue == base.comparisonValue;
				case 2:
					return playerStatValue > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
			}
			else if (advancedPrerequisiteType == AdvancedPrerequisiteType.CUSTOM_MAXIMUM_COMPARISON)
			{
				float playerMaximum = AdvancedGameStatsManager.Instance.GetPlayerMaximum(customMaximumToCheck);
				PrerequisiteOperation prerequisiteOperation2 = base.prerequisiteOperation;
				PrerequisiteOperation val2 = prerequisiteOperation2;
				switch ((int)val2)
				{
				case 0:
					return playerMaximum < base.comparisonValue;
				case 1:
					return playerMaximum == base.comparisonValue;
				case 2:
					return playerMaximum > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
			}
			else
			{
				if (advancedPrerequisiteType != AdvancedPrerequisiteType.NUMBER_PASTS_COMPLETED_BETTER)
				{
					if (advancedPrerequisiteType == AdvancedPrerequisiteType.ENCOUNTER_OR_CUSTOM_FLAG)
					{
						EncounterDatabaseEntry val3 = null;
						if (!string.IsNullOrEmpty(base.encounteredObjectGuid))
						{
							val3 = EncounterDatabase.GetEntry(base.encounteredObjectGuid);
						}
						if (AdvancedGameStatsManager.Instance.GetFlag(customFlagToCheck) == requireCustomFlag)
						{
							return true;
						}
						if (val3 != null)
						{
							int num = GameStatsManager.Instance.QueryEncounterable(val3);
							PrerequisiteOperation prerequisiteOperation3 = base.prerequisiteOperation;
							PrerequisiteOperation val4 = prerequisiteOperation3;
							switch ((int)val4)
							{
							case 0:
								return num < base.requiredNumberOfEncounters;
							case 1:
								return num == base.requiredNumberOfEncounters;
							case 2:
								return num > base.requiredNumberOfEncounters;
							}
							Debug.LogError((object)"Switching on invalid stat comparison operation!");
						}
						else if ((Object)(object)base.encounteredRoom != (Object)null)
						{
							int num2 = GameStatsManager.Instance.QueryRoomEncountered(base.encounteredRoom.GUID);
							PrerequisiteOperation prerequisiteOperation4 = base.prerequisiteOperation;
							PrerequisiteOperation val5 = prerequisiteOperation4;
							switch ((int)val5)
							{
							case 0:
								return num2 < base.requiredNumberOfEncounters;
							case 1:
								return num2 == base.requiredNumberOfEncounters;
							case 2:
								return num2 > base.requiredNumberOfEncounters;
							}
							Debug.LogError((object)"Switching on invalid stat comparison operation!");
						}
						return false;
					}
					return CheckConditionsFulfilledOrig();
				}
				float num3 = GameStatsManager.Instance.GetNumberPastsBeaten();
				PrerequisiteOperation prerequisiteOperation5 = base.prerequisiteOperation;
				PrerequisiteOperation val6 = prerequisiteOperation5;
				switch ((int)val6)
				{
				case 0:
					return num3 < base.comparisonValue;
				case 1:
					return num3 == base.comparisonValue;
				case 2:
					return num3 > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
			}
			return false;
		}

		public bool CheckConditionsFulfilledOrig()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected I4, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected I4, but got Unknown
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Expected I4, but got Unknown
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Expected I4, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Expected I4, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected I4, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected I4, but got Unknown
			EncounterDatabaseEntry val = null;
			if (!string.IsNullOrEmpty(base.encounteredObjectGuid))
			{
				val = EncounterDatabase.GetEntry(base.encounteredObjectGuid);
			}
			PrerequisiteType prerequisiteType = base.prerequisiteType;
			PrerequisiteType val2 = prerequisiteType;
			switch ((int)val2)
			{
			case 0:
				if (val == null && (Object)(object)base.encounteredRoom == (Object)null)
				{
					return true;
				}
				if (val != null)
				{
					int num3 = GameStatsManager.Instance.QueryEncounterable(val);
					PrerequisiteOperation prerequisiteOperation4 = base.prerequisiteOperation;
					PrerequisiteOperation val7 = prerequisiteOperation4;
					switch ((int)val7)
					{
					case 0:
						return num3 < base.requiredNumberOfEncounters;
					case 1:
						return num3 == base.requiredNumberOfEncounters;
					case 2:
						return num3 > base.requiredNumberOfEncounters;
					}
					Debug.LogError((object)"Switching on invalid stat comparison operation!");
				}
				else if ((Object)(object)base.encounteredRoom != (Object)null)
				{
					int num4 = GameStatsManager.Instance.QueryRoomEncountered(base.encounteredRoom.GUID);
					PrerequisiteOperation prerequisiteOperation5 = base.prerequisiteOperation;
					PrerequisiteOperation val8 = prerequisiteOperation5;
					switch ((int)val8)
					{
					case 0:
						return num4 < base.requiredNumberOfEncounters;
					case 1:
						return num4 == base.requiredNumberOfEncounters;
					case 2:
						return num4 > base.requiredNumberOfEncounters;
					}
					Debug.LogError((object)"Switching on invalid stat comparison operation!");
				}
				return false;
			case 1:
			{
				float playerStatValue = GameStatsManager.Instance.GetPlayerStatValue(base.statToCheck);
				PrerequisiteOperation prerequisiteOperation6 = base.prerequisiteOperation;
				PrerequisiteOperation val9 = prerequisiteOperation6;
				switch ((int)val9)
				{
				case 0:
					return playerStatValue < base.comparisonValue;
				case 1:
					return playerStatValue == base.comparisonValue;
				case 2:
					return playerStatValue > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
				break;
			}
			case 2:
			{
				PlayableCharacters val5 = (PlayableCharacters)(-1);
				if (!BraveRandom.IgnoreGenerationDifferentiator)
				{
					if ((Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null)
					{
						val5 = GameManager.Instance.PrimaryPlayer.characterIdentity;
					}
					else if ((Object)(object)GameManager.PlayerPrefabForNewGame != (Object)null)
					{
						val5 = GameManager.PlayerPrefabForNewGame.GetComponent<PlayerController>().characterIdentity;
					}
					else if ((Object)(object)GameManager.Instance.BestGenerationDungeonPrefab != (Object)null)
					{
						val5 = GameManager.Instance.BestGenerationDungeonPrefab.defaultPlayerPrefab.GetComponent<PlayerController>().characterIdentity;
					}
				}
				return base.requireCharacter == (val5 == base.requiredCharacter);
			}
			case 3:
				if ((Object)(object)GameManager.Instance.BestGenerationDungeonPrefab != (Object)null)
				{
					return base.requireTileset == (GameManager.Instance.BestGenerationDungeonPrefab.tileIndices.tilesetId == base.requiredTileset);
				}
				return base.requireTileset == (GameManager.Instance.Dungeon.tileIndices.tilesetId == base.requiredTileset);
			case 4:
				return GameStatsManager.Instance.GetFlag(base.saveFlagToCheck) == base.requireFlag;
			case 5:
				return !base.requireDemoMode;
			case 6:
			{
				float playerMaximum = GameStatsManager.Instance.GetPlayerMaximum(base.maxToCheck);
				PrerequisiteOperation prerequisiteOperation3 = base.prerequisiteOperation;
				PrerequisiteOperation val6 = prerequisiteOperation3;
				switch ((int)val6)
				{
				case 0:
					return playerMaximum < base.comparisonValue;
				case 1:
					return playerMaximum == base.comparisonValue;
				case 2:
					return playerMaximum > base.comparisonValue;
				}
				Debug.LogError((object)"Switching on invalid stat comparison operation!");
				break;
			}
			case 7:
				if (GameStatsManager.Instance.GetFlag(base.saveFlagToCheck) == base.requireFlag)
				{
					return true;
				}
				if (val != null)
				{
					int num = GameStatsManager.Instance.QueryEncounterable(val);
					PrerequisiteOperation prerequisiteOperation = base.prerequisiteOperation;
					PrerequisiteOperation val3 = prerequisiteOperation;
					switch ((int)val3)
					{
					case 0:
						return num < base.requiredNumberOfEncounters;
					case 1:
						return num == base.requiredNumberOfEncounters;
					case 2:
						return num > base.requiredNumberOfEncounters;
					}
					Debug.LogError((object)"Switching on invalid stat comparison operation!");
				}
				else if ((Object)(object)base.encounteredRoom != (Object)null)
				{
					int num2 = GameStatsManager.Instance.QueryRoomEncountered(base.encounteredRoom.GUID);
					PrerequisiteOperation prerequisiteOperation2 = base.prerequisiteOperation;
					PrerequisiteOperation val4 = prerequisiteOperation2;
					switch ((int)val4)
					{
					case 0:
						return num2 < base.requiredNumberOfEncounters;
					case 1:
						return num2 == base.requiredNumberOfEncounters;
					case 2:
						return num2 > base.requiredNumberOfEncounters;
					}
					Debug.LogError((object)"Switching on invalid stat comparison operation!");
				}
				return false;
			case 8:
				return (float)GameStatsManager.Instance.GetNumberPastsBeaten() >= base.comparisonValue;
			default:
				Debug.LogError((object)"Switching on invalid prerequisite type!!!");
				break;
			}
			return false;
		}
	}
	[Serializable]
	public class CustomHuntQuest : MonsterHuntQuest
	{
		[LongEnum]
		[SerializeField]
		public CustomDungeonFlags CustomQuestFlag;

		[LongEnum]
		[SerializeField]
		public List<CustomDungeonFlags> CustomFlagsToSetUponReward;

		[SerializeField]
		public Func<AIActor, MonsterHuntProgress, bool> ValidTargetCheck;

		[SerializeField]
		public JammedEnemyState RequiredEnemyState;

		public bool IsQuestComplete()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (CustomQuestFlag != 0 && AdvancedGameStatsManager.Instance.GetFlag(CustomQuestFlag))
			{
				return true;
			}
			return GameStatsManager.Instance.GetFlag(base.QuestFlag);
		}

		public bool IsEnemyValid(AIActor enemy, MonsterHuntProgress progress)
		{
			if (ValidTargetCheck != null && !ValidTargetCheck(enemy, progress))
			{
				return false;
			}
			return SaveTools.IsEnemyStateValid(enemy, RequiredEnemyState);
		}

		public void Complete()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if ((int)base.QuestFlag > 0)
			{
				GameStatsManager.Instance.SetFlag(base.QuestFlag, true);
			}
			if (CustomQuestFlag != 0)
			{
				AdvancedGameStatsManager.Instance.SetFlag(CustomQuestFlag, value: true);
			}
		}

		public void UnlockRewards()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < base.FlagsToSetUponReward.Count; i++)
			{
				GameStatsManager.Instance.SetFlag(base.FlagsToSetUponReward[i], true);
			}
			for (int j = 0; j < CustomFlagsToSetUponReward.Count; j++)
			{
				AdvancedGameStatsManager.Instance.SetFlag(CustomFlagsToSetUponReward[j], value: true);
			}
		}
	}
	public static class CustomHuntQuests
	{
		private static bool m_loaded;

		private static Hook huntProgressLoadedHook;

		private static Hook huntProgressCompleteHook;

		private static Hook huntProgressQuestCompleteHook;

		private static Hook huntProgressNextQuestHook;

		private static Hook huntProgressProcessKillHook;

		private static Hook huntQuestCompleteHook;

		private static Hook huntQuestUnlockRewardsHook;

		public static MonsterHuntData HuntData;

		public static List<MonsterHuntQuest> addedOrderedQuests;

		public static List<MonsterHuntQuest> addedProceduralQuests;

		public static void DoSetup()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			if (!m_loaded)
			{
				HuntData = (MonsterHuntData)BraveResources.Load("Monster Hunt Data", ".asset");
				huntProgressLoadedHook = new Hook((MethodBase)typeof(MonsterHuntProgress).GetMethod("OnLoaded"), typeof(CustomHuntQuests).GetMethod("HuntProgressLoadedHook"));
				huntProgressCompleteHook = new Hook((MethodBase)typeof(MonsterHuntProgress).GetMethod("Complete"), typeof(CustomHuntQuests).GetMethod("HuntProgressCompleteHook"));
				huntProgressQuestCompleteHook = new Hook((MethodBase)typeof(MonsterHuntProgress).GetMethod("IsQuestComplete"), typeof(CustomHuntQuests).GetMethod("HuntProgressQuestCompleteHook"));
				huntProgressNextQuestHook = new Hook((MethodBase)typeof(MonsterHuntProgress).GetMethod("TriggerNextQuest"), typeof(CustomHuntQuests).GetMethod("HuntProgressNextQuestHook"));
				huntProgressProcessKillHook = new Hook((MethodBase)typeof(MonsterHuntProgress).GetMethod("ProcessKill"), typeof(CustomHuntQuests).GetMethod("HuntProgressProcessKillHook"));
				huntQuestCompleteHook = new Hook((MethodBase)typeof(MonsterHuntQuest).GetMethod("IsQuestComplete"), typeof(CustomHuntQuests).GetMethod("HuntQuestCompleteHook"));
				huntQuestUnlockRewardsHook = new Hook((MethodBase)typeof(MonsterHuntQuest).GetMethod("UnlockRewards"), typeof(CustomHuntQuests).GetMethod("HuntQuestUnlockRewardsHook"));
				m_loaded = true;
			}
		}

		public static void Unload()
		{
			if (!m_loaded)
			{
				return;
			}
			if (addedOrderedQuests != null)
			{
				foreach (MonsterHuntQuest addedOrderedQuest in addedOrderedQuests)
				{
					if (HuntData.OrderedQuests.Contains(addedOrderedQuest))
					{
						HuntData.OrderedQuests.Remove(addedOrderedQuest);
					}
				}
				addedOrderedQuests.Clear();
				addedOrderedQuests = null;
			}
			if (addedProceduralQuests != null)
			{
				foreach (MonsterHuntQuest addedProceduralQuest in addedProceduralQuests)
				{
					if (HuntData.ProceduralQuests.Contains(addedProceduralQuest))
					{
						HuntData.ProceduralQuests.Remove(addedProceduralQuest);
					}
				}
				addedProceduralQuests.Clear();
				addedProceduralQuests = null;
			}
			if (GameStatsManager.HasInstance && GameStatsManager.Instance.huntProgress != null)
			{
				GameStatsManager.Instance.huntProgress.OnLoaded();
			}
			else
			{
				int? num = null;
				if (AdvancedGameStatsManager.HasInstance)
				{
					num = AdvancedGameStatsManager.Instance.cachedHuntIndex;
					AdvancedGameStatsManager.Save();
				}
				GameStatsManager.Load();
				if (num.HasValue && AdvancedGameStatsManager.HasInstance)
				{
					AdvancedGameStatsManager.Instance.cachedHuntIndex = num.Value;
				}
			}
			HuntData = null;
			Hook obj = huntProgressLoadedHook;
			if (obj != null)
			{
				obj.Dispose();
			}
			Hook obj2 = huntProgressCompleteHook;
			if (obj2 != null)
			{
				obj2.Dispose();
			}
			Hook obj3 = huntProgressNextQuestHook;
			if (obj3 != null)
			{
				obj3.Dispose();
			}
			Hook obj4 = huntProgressProcessKillHook;
			if (obj4 != null)
			{
				obj4.Dispose();
			}
			Hook obj5 = huntQuestCompleteHook;
			if (obj5 != null)
			{
				obj5.Dispose();
			}
			Hook obj6 = huntQuestUnlockRewardsHook;
			if (obj6 != null)
			{
				obj6.Dispose();
			}
			Hook obj7 = huntProgressQuestCompleteHook;
			if (obj7 != null)
			{
				obj7.Dispose();
			}
			m_loaded = false;
		}

		public static void HuntProgressProcessKillHook(Action<MonsterHuntProgress, AIActor> orig, MonsterHuntProgress self, AIActor target)
		{
			if (self.ActiveQuest == null || (self.CurrentActiveMonsterHuntProgress < self.ActiveQuest.NumberKillsRequired && (!(self.ActiveQuest is CustomHuntQuest) || (self.ActiveQuest as CustomHuntQuest).IsEnemyValid(target, self))))
			{
				orig(self, target);
			}
		}

		public static MonsterHuntQuest FindNextQuestNoProcedural()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < HuntData.OrderedQuests.Count; i++)
			{
				if (!GameStatsManager.Instance.GetFlag(HuntData.OrderedQuests[i].QuestFlag))
				{
					return HuntData.OrderedQuests[i];
				}
			}
			return null;
		}

		public static int HuntProgressNextQuestHook(Func<MonsterHuntProgress, int> orig, MonsterHuntProgress self)
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			MonsterHuntQuest val = null;
			int num = 0;
			for (int i = 0; i < HuntData.OrderedQuests.Count; i++)
			{
				if (HuntData.OrderedQuests[i] != null && !HuntData.OrderedQuests[i].IsQuestComplete())
				{
					val = HuntData.OrderedQuests[i];
					num = i;
					break;
				}
			}
			List<MonsterHuntQuest> orderedQuests = HuntData.OrderedQuests;
			List<MonsterHuntQuest> list = new List<MonsterHuntQuest>();
			for (int j = 0; j < orderedQuests.Count; j++)
			{
				if (orderedQuests[j] != null && (int)orderedQuests[j].QuestFlag > 0)
				{
					list.Add(orderedQuests[j]);
				}
			}
			HuntData.OrderedQuests = list;
			int result = orig(self);
			MonsterHuntQuest val2 = FindNextQuestNoProcedural();
			HuntData.OrderedQuests = orderedQuests;
			if (self.ActiveQuest != null && val2 != null && HuntData.OrderedQuests.IndexOf(self.ActiveQuest) != self.CurrentActiveMonsterHuntID)
			{
				self.CurrentActiveMonsterHuntID = HuntData.OrderedQuests.IndexOf(self.ActiveQuest);
			}
			if (val != null && val2 == null)
			{
				self.ActiveQuest = val;
				self.CurrentActiveMonsterHuntID = num;
				self.CurrentActiveMonsterHuntProgress = 0;
			}
			else if (val != null && val2 != null && num < self.CurrentActiveMonsterHuntID)
			{
				self.ActiveQuest = val;
				self.CurrentActiveMonsterHuntID = num;
				self.CurrentActiveMonsterHuntProgress = 0;
			}
			return result;
		}

		public static void HuntProgressCompleteHook(Action<MonsterHuntProgress> orig, MonsterHuntProgress self)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			GungeonFlags questFlag = self.ActiveQuest.QuestFlag;
			bool flag = GameStatsManager.Instance.GetFlag((GungeonFlags)1);
			if (self.ActiveQuest is CustomHuntQuest)
			{
				(self.ActiveQuest as CustomHuntQuest).Complete();
				if ((int)self.ActiveQuest.QuestFlag == 0)
				{
					self.ActiveQuest.QuestFlag = (GungeonFlags)1;
				}
			}
			orig(self);
			GameStatsManager.Instance.SetFlag((GungeonFlags)1, flag);
			self.ActiveQuest.QuestFlag = questFlag;
		}

		public static bool HuntQuestCompleteHook(Func<MonsterHuntQuest, bool> orig, MonsterHuntQuest self)
		{
			if (self is CustomHuntQuest)
			{
				return (self as CustomHuntQuest).IsQuestComplete();
			}
			return orig(self);
		}

		public static bool HuntProgressQuestCompleteHook(Func<MonsterHuntProgress, bool> orig, MonsterHuntProgress self)
		{
			if (self.ActiveQuest is CustomHuntQuest)
			{
				return (self.ActiveQuest as CustomHuntQuest).IsQuestComplete();
			}
			return orig(self);
		}

		public static void HuntQuestUnlockRewardsHook(Action<MonsterHuntQuest> orig, MonsterHuntQuest self)
		{
			if (self is CustomHuntQuest)
			{
				(self as CustomHuntQuest).UnlockRewards();
			}
			else
			{
				orig(self);
			}
		}

		public static void HuntProgressLoadedHook(Action<MonsterHuntProgress> orig, MonsterHuntProgress self)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			if (GameManager.HasInstance)
			{
				if (GameManager.Instance.platformInterface == null)
				{
					if (PlatformInterfaceSteam.IsSteamBuild())
					{
						GameManager.Instance.platformInterface = (PlatformInterface)new PlatformInterfaceSteam();
					}
					else if (PlatformInterfaceGalaxy.IsGalaxyBuild())
					{
						GameManager.Instance.platformInterface = (PlatformInterface)new PlatformInterfaceGalaxy();
					}
					else
					{
						GameManager.Instance.platformInterface = (PlatformInterface)new PlatformInterfaceGenericPC();
					}
				}
				GameManager.Instance.platformInterface.Start();
			}
			FieldInfo field = typeof(GameStatsManager).GetField("s_frifleHuntFlags", BindingFlags.Static | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(GameStatsManager).GetField("s_pastFlags", BindingFlags.Static | BindingFlags.NonPublic);
			FieldInfo field3 = typeof(GameStatsManager).GetField("s_npcFoyerFlags", BindingFlags.Static | BindingFlags.NonPublic);
			if (field2.GetValue(null) == null)
			{
				List<GungeonFlags> list = new List<GungeonFlags>();
				list.Add((GungeonFlags)18001);
				list.Add((GungeonFlags)18002);
				list.Add((GungeonFlags)18003);
				list.Add((GungeonFlags)18004);
				field2.SetValue(null, list);
			}
			if (field3.GetValue(null) == null)
			{
				List<GungeonFlags> list2 = new List<GungeonFlags>();
				list2.Add((GungeonFlags)40005);
				list2.Add((GungeonFlags)27505);
				list2.Add((GungeonFlags)55505);
				list2.Add((GungeonFlags)24505);
				list2.Add((GungeonFlags)2003);
				list2.Add((GungeonFlags)45500);
				list2.Add((GungeonFlags)30005);
				list2.Add((GungeonFlags)25506);
				list2.Add((GungeonFlags)28501);
				list2.Add((GungeonFlags)35051);
				field3.SetValue(null, list2);
			}
			if (field.GetValue(null) == null)
			{
				List<GungeonFlags> list3 = new List<GungeonFlags>();
				list3.Add((GungeonFlags)35101);
				list3.Add((GungeonFlags)35102);
				list3.Add((GungeonFlags)35103);
				list3.Add((GungeonFlags)35104);
				list3.Add((GungeonFlags)35105);
				list3.Add((GungeonFlags)35106);
				list3.Add((GungeonFlags)35107);
				list3.Add((GungeonFlags)35108);
				list3.Add((GungeonFlags)35109);
				list3.Add((GungeonFlags)35110);
				list3.Add((GungeonFlags)35111);
				list3.Add((GungeonFlags)35112);
				list3.Add((GungeonFlags)35113);
				list3.Add((GungeonFlags)35114);
				list3.Add((GungeonFlags)35500);
				field.SetValue(null, list3);
			}
			MonsterHuntQuest val = null;
			bool flag = GameStatsManager.Instance.GetFlag((GungeonFlags)35500);
			foreach (MonsterHuntQuest orderedQuest in HuntData.OrderedQuests)
			{
				if (orderedQuest != null && !orderedQuest.IsQuestComplete())
				{
					val = orderedQuest;
				}
			}
			if (val != null)
			{
				GameStatsManager.Instance.SetFlag((GungeonFlags)35500, false);
			}
			if (SaveAPIManager.IsFirstLoad)
			{
				if (!AdvancedGameStatsManager.HasInstance)
				{
					AdvancedGameStatsManager.Load();
				}
				AdvancedGameStatsManager.Instance.cachedHuntIndex = self.CurrentActiveMonsterHuntID;
			}
			else
			{
				if (!AdvancedGameStatsManager.HasInstance)
				{
					AdvancedGameStatsManager.Load();
				}
				if (AdvancedGameStatsManager.HasInstance && self.CurrentActiveMonsterHuntID == -1 && AdvancedGameStatsManager.Instance.cachedHuntIndex != -1)
				{
					if (GameStatsManager.Instance.GetFlag((GungeonFlags)35500) && GameStatsManager.Instance.GetFlag((GungeonFlags)36015))
					{
						if (AdvancedGameStatsManager.Instance.cachedHuntIndex >= 0 && AdvancedGameStatsManager.Instance.cachedHuntIndex < HuntData.ProceduralQuests.Count)
						{
							self.CurrentActiveMonsterHuntID = AdvancedGameStatsManager.Instance.cachedHuntIndex;
							AdvancedGameStatsManager.Instance.cachedHuntIndex = -1;
						}
					}
					else if (AdvancedGameStatsManager.Instance.cachedHuntIndex >= 0 || AdvancedGameStatsManager.Instance.cachedHuntIndex < HuntData.OrderedQuests.Count)
					{
						self.CurrentActiveMonsterHuntID = AdvancedGameStatsManager.Instance.cachedHuntIndex;
						AdvancedGameStatsManager.Instance.cachedHuntIndex = -1;
					}
				}
			}
			orig(self);
			if (val == null && !GameStatsManager.Instance.GetFlag((GungeonFlags)35500))
			{
				flag = true;
				List<GungeonFlags> list4 = (List<GungeonFlags>)field.GetValue(null);
				if (list4 != null)
				{
					int num = 0;
					for (int i = 0; i < list4.Count; i++)
					{
						num++;
					}
					if ((Object)(object)GameManager.Instance == (Object)null && GameManager.Instance.platformInterface == null)
					{
						GameManager.Instance.platformInterface.SetStat((PlatformStat)7, num);
					}
				}
			}
			GameStatsManager.Instance.SetFlag((GungeonFlags)35500, flag);
		}

		public static MonsterHuntQuest AddProceduralQuest(List<string> questIntroConversation, string targetEnemyName, List<string> targetEnemyGuids, int numberKillsRequired, JammedEnemyState requiredState = JammedEnemyState.NoCheck, Func<AIActor, MonsterHuntProgress, bool> validTargetCheck = null, List<GungeonFlags> rewardFlags = null, List<CustomDungeonFlags> customRewardFlags = null)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			string text = "#CUSTOMQUEST_PROCEDURAL_" + Guid.NewGuid().ToString().ToUpper() + "_" + Guid.NewGuid().ToString().ToUpper();
			string text2 = text + "_INTRO";
			string text3 = text + "_TARGET";
			Databases.Strings.Core.SetComplex(text2, questIntroConversation.ToArray());
			Databases.Strings.Core.Set(text3, targetEnemyName);
			return AddProceduralQuest((MonsterHuntQuest)(object)new CustomHuntQuest
			{
				QuestFlag = (GungeonFlags)0,
				QuestIntroString = text2,
				TargetStringKey = text3,
				ValidTargetMonsterGuids = SaveTools.CloneList(targetEnemyGuids),
				FlagsToSetUponReward = ((rewardFlags != null) ? SaveTools.CloneList(rewardFlags) : new List<GungeonFlags>()),
				CustomFlagsToSetUponReward = ((customRewardFlags != null) ? SaveTools.CloneList(customRewardFlags) : new List<CustomDungeonFlags>()),
				NumberKillsRequired = numberKillsRequired,
				RequiredEnemyState = requiredState,
				ValidTargetCheck = validTargetCheck,
				CustomQuestFlag = CustomDungeonFlags.NONE
			});
		}

		public static MonsterHuntQuest AddProceduralQuest(List<string> questIntroConversation, string targetEnemyName, List<AIActor> targetEnemies, int numberKillsRequired, JammedEnemyState requiredState = JammedEnemyState.NoCheck, Func<AIActor, MonsterHuntProgress, bool> validTargetCheck = null, List<GungeonFlags> rewardFlags = null, List<CustomDungeonFlags> customRewardFlags = null)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			string text = "#CUSTOMQUEST_PROCEDURAL_" + Guid.NewGuid().ToString().ToUpper() + "_" + Guid.NewGuid().ToString().ToUpper();
			string text2 = text + "_INTRO";
			string text3 = text + "_TARGET";
			Databases.Strings.Core.SetComplex(text2, questIntroConversation.ToArray());
			Databases.Strings.Core.Set(text3, targetEnemyName);
			return AddProceduralQuest((MonsterHuntQuest)(object)new CustomHuntQuest
			{
				QuestFlag = (GungeonFlags)0,
				QuestIntroString = text2,
				TargetStringKey = text3,
				ValidTargetMonsterGuids = targetEnemies.Convert((AIActor enemy) => enemy.EnemyGuid),
				FlagsToSetUponReward = ((rewardFlags != null) ? SaveTools.CloneList(rewardFlags) : new List<GungeonFlags>()),
				CustomFlagsToSetUponReward = ((customRewardFlags != null) ? SaveTools.CloneList(customRewardFlags) : new List<CustomDungeonFlags>()),
				NumberKillsRequired = numberKillsRequired,
				RequiredEnemyState = requiredState,
				ValidTargetCheck = validTargetCheck,
				CustomQuestFlag = CustomDungeonFlags.NONE
			});
		}

		public static MonsterHuntQuest AddQuest(CustomDungeonFlags questFlag, List<string> questIntroConversation, string targetEnemyName, List<string> targetEnemyGuids, int numberKillsRequired, List<GungeonFlags> rewardFlags = null, List<CustomDungeonFlags> customRewardFlags = null, JammedEnemyState requiredState = JammedEnemyState.NoCheck, Func<AIActor, MonsterHuntProgress, bool> validTargetCheck = null, int? index = null)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			string text = "#CUSTOMQUEST_" + questFlag.ToString() + "_" + Guid.NewGuid().ToString().ToUpper();
			string text2 = text + "_INTRO";
			string text3 = text + "_TARGET";
			Databases.Strings.Core.SetComplex(text2, questIntroConversation.ToArray());
			Databases.Strings.Core.Set(text3, targetEnemyName);
			return AddQuest((MonsterHuntQuest)(object)new CustomHuntQuest
			{
				QuestFlag = (GungeonFlags)0,
				QuestIntroString = text2,
				TargetStringKey = text3,
				ValidTargetMonsterGuids = SaveTools.CloneList(targetEnemyGuids),
				FlagsToSetUponReward = ((rewardFlags != null) ? SaveTools.CloneList(rewardFlags) : new List<GungeonFlags>()),
				CustomFlagsToSetUponReward = ((customRewardFlags != null) ? SaveTools.CloneList(customRewardFlags) : new List<CustomDungeonFlags>()),
				NumberKillsRequired = numberKillsRequired,
				RequiredEnemyState = requiredState,
				ValidTargetCheck = validTargetCheck,
				CustomQuestFlag = questFlag
			}, index);
		}

		public static MonsterHuntQuest AddQuest(GungeonFlags questFlag, List<string> questIntroConversation, string targetEnemyName, List<string> targetEnemyGuids, int numberKillsRequired, List<GungeonFlags> rewardFlags = null, List<CustomDungeonFlags> customRewardFlags = null, JammedEnemyState requiredState = JammedEnemyState.NoCheck, Func<AIActor, MonsterHuntProgress, bool> validTargetCheck = null, int? index = null)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			string text = "#CUSTOMQUEST_" + ((object)(GungeonFlags)(ref questFlag)).ToString() + "_" + Guid.NewGuid().ToString().ToUpper();
			string text2 = text + "_INTRO";
			string text3 = text + "_TARGET";
			Databases.Strings.Core.SetComplex(text2, questIntroConversation.ToArray());
			Databases.Strings.Core.Set(text3, targetEnemyName);
			return AddQuest((MonsterHuntQuest)(object)new CustomHuntQuest
			{
				QuestFlag = questFlag,
				QuestIntroString = text2,
				TargetStringKey = text3,
				ValidTargetMonsterGuids = SaveTools.CloneList(targetEnemyGuids),
				FlagsToSetUponReward = ((rewardFlags != null) ? SaveTools.CloneList(rewardFlags) : new List<GungeonFlags>()),
				CustomFlagsToSetUponReward = ((customRewardFlags != null) ? SaveTools.CloneList(customRewardFlags) : new List<CustomDungeonFlags>()),
				NumberKillsRequired = numberKillsRequired,
				RequiredEnemyState = requiredState,
				ValidTargetCheck = validTargetCheck,
				CustomQuestFlag = CustomDungeonFlags.NONE
			}, index);
		}

		public static MonsterHuntQuest AddQuest(CustomDungeonFlags questFlag, List<string> questIntroConversation, string targetEnemyName, List<AIActor> targetEnemies, int numberKillsRequired, List<GungeonFlags> rewardFlags = null, List<CustomDungeonFlags> customRewardFlags = null, JammedEnemyState requiredState = JammedEnemyState.NoCheck, Func<AIActor, MonsterHuntProgress, bool> validTargetCheck = null, int? index = null)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			string text = "#CUSTOMQUEST_" + questFlag.ToString() + "_" + Guid.NewGuid().ToString().ToUpper();
			string text2 = text + "_INTRO";
			string text3 = text + "_TARGET";
			Databases.Strings.Core.SetComplex(text2, questIntroConversation.ToArray());
			Databases.Strings.Core.Set(text3, targetEnemyName);
			return AddQuest((MonsterHuntQuest)(object)new CustomHuntQuest
			{
				QuestFlag = (GungeonFlags)0,
				QuestIntroString = text2,
				TargetStringKey = text3,
				ValidTargetMonsterGuids = targetEnemies.Convert((AIActor enemy) => enemy.EnemyGuid),
				FlagsToSetUponReward = ((rewardFlags != null) ? SaveTools.CloneList(rewardFlags) : new List<GungeonFlags>()),
				CustomFlagsToSetUponReward = ((customRewardFlags != null) ? SaveTools.CloneList(customRewardFlags) : new List<CustomDungeonFlags>()),
				NumberKillsRequired = numberKillsRequired,
				RequiredEnemyState = requiredState,
				ValidTargetCheck = validTargetCheck,
				CustomQuestFlag = questFlag
			}, index);
		}

		public static MonsterHuntQuest AddQuest(GungeonFlags questFlag, List<string> questIntroConversation, string targetEnemyName, List<AIActor> targetEnemies, int numberKillsRequired, List<GungeonFlags> rewardFlags = null, List<CustomDungeonFlags> customRewardFlags = null, JammedEnemyState requiredState = JammedEnemyState.NoCheck, Func<AIActor, MonsterHuntProgress, bool> validTargetCheck = null, int? index = null)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			string text = "#CUSTOMQUEST_" + ((object)(GungeonFlags)(ref questFlag)).ToString() + "_" + Guid.NewGuid().ToString().ToUpper();
			string text2 = text + "_INTRO";
			string text3 = text + "_TARGET";
			Databases.Strings.Core.SetComplex(text2, questIntroConversation.ToArray());
			Databases.Strings.Core.Set(text3, targetEnemyName);
			return AddQuest((MonsterHuntQuest)(object)new CustomHuntQuest
			{
				QuestFlag = questFlag,
				QuestIntroString = text2,
				TargetStringKey = text3,
				ValidTargetMonsterGuids = targetEnemies.Convert((AIActor enemy) => enemy.EnemyGuid),
				FlagsToSetUponReward = ((rewardFlags != null) ? SaveTools.CloneList(rewardFlags) : new List<GungeonFlags>()),
				CustomFlagsToSetUponReward = ((customRewardFlags != null) ? SaveTools.CloneList(customRewardFlags) : new List<CustomDungeonFlags>()),
				NumberKillsRequired = numberKillsRequired,
				RequiredEnemyState = requiredState,
				ValidTargetCheck = validTargetCheck,
				CustomQuestFlag = CustomDungeonFlags.NONE
			}, index);
		}

		public static MonsterHuntQuest AddQuest(MonsterHuntQuest quest, int? index = null)
		{
			if ((Object)(object)HuntData == (Object)null)
			{
				DoSetup();
			}
			if (!index.HasValue)
			{
				HuntData.OrderedQuests.Add(quest);
			}
			else if (index.Value < 0)
			{
				HuntData.OrderedQuests.Add(quest);
			}
			else
			{
				HuntData.OrderedQuests.InsertOrAdd(index.Value, quest);
			}
			if (GameStatsManager.HasInstance && GameStatsManager.Instance.huntProgress != null)
			{
				GameStatsManager.Instance.huntProgress.OnLoaded();
			}
			else
			{
				int? num = null;
				if (AdvancedGameStatsManager.HasInstance)
				{
					num = AdvancedGameStatsManager.Instance.cachedHuntIndex;
					AdvancedGameStatsManager.Save();
				}
				GameStatsManager.Load();
				if (num.HasValue && AdvancedGameStatsManager.HasInstance)
				{
					AdvancedGameStatsManager.Instance.cachedHuntIndex = num.Value;
				}
			}
			if (addedOrderedQuests == null)
			{
				addedOrderedQuests = new List<MonsterHuntQuest>();
			}
			addedOrderedQuests.Add(quest);
			return quest;
		}

		public static MonsterHuntQuest AddProceduralQuest(MonsterHuntQuest quest)
		{
			if ((Object)(object)HuntData == (Object)null)
			{
				DoSetup();
			}
			HuntData.ProceduralQuests.Add(quest);
			if (GameStatsManager.HasInstance && GameStatsManager.Instance.huntProgress != null)
			{
				GameStatsManager.Instance.huntProgress.OnLoaded();
			}
			else
			{
				int? num = null;
				if (AdvancedGameStatsManager.HasInstance)
				{
					num = AdvancedGameStatsManager.Instance.cachedHuntIndex;
					AdvancedGameStatsManager.Save();
				}
				GameStatsManager.Load();
				if (num.HasValue && AdvancedGameStatsManager.HasInstance)
				{
					AdvancedGameStatsManager.Instance.cachedHuntIndex = num.Value;
				}
			}
			if (addedProceduralQuests == null)
			{
				addedProceduralQuests = new List<MonsterHuntQuest>();
			}
			addedProceduralQuests.Add(quest);
			return quest;
		}
	}
	public class CustomDungeonFlagsComparer : IEqualityComparer<CustomDungeonFlags>
	{
		public bool Equals(CustomDungeonFlags x, CustomDungeonFlags y)
		{
			return x == y;
		}

		public int GetHashCode(CustomDungeonFlags obj)
		{
			return (int)obj;
		}
	}
	public class CustomTrackedMaximumsComparer : IEqualityComparer<CustomTrackedMaximums>
	{
		public bool Equals(CustomTrackedMaximums x, CustomTrackedMaximums y)
		{
			return x == y;
		}

		public int GetHashCode(CustomTrackedMaximums obj)
		{
			return (int)obj;
		}
	}
	public class CustomTrackedStatsComparer : IEqualityComparer<CustomTrackedStats>
	{
		public bool Equals(CustomTrackedStats x, CustomTrackedStats y)
		{
			return x == y;
		}

		public int GetHashCode(CustomTrackedStats obj)
		{
			return (int)obj;
		}
	}
	public enum CustomCharacterSpecificGungeonFlags
	{
		NONE,
		EXAMPLE_CHARACTER_SPECIFIC_FLAG,
		EXAMPLE_ENEMY_DEATH_CHARACTER_SPECIFIC_FLAG
	}
	public enum CustomDungeonFlags
	{
		NONE,
		DEFEAT_BISHOP,
		REEFER_PURCHASE
	}
	public enum CustomTrackedMaximums
	{
		EXAMPLE_MAXIMUM,
		MAXIMUM_HEALTH,
		MAXIMUM_DAMAGE,
		MAXIMUM_JAMMO
	}
	public enum CustomTrackedStats
	{
		EXAMPLE_STATS,
		JAMMOLET_CURSE,
		SEWING_KIT,
		BOUNTY_UNLOCK
	}
	public enum JammedEnemyState
	{
		NoCheck,
		Jammed,
		Unjammed
	}
	public static class SaveAPIManager
	{
		public delegate void OnActiveGameDataClearedDelegate(GameManager manager, bool destroyGameManager, bool endSession);

		private static Hook saveHook;

		private static Hook loadHook;

		private static Hook resetHook;

		private static Hook beginSessionHook;

		private static Hook endSessionHook;

		private static Hook clearAllStatsHook;

		private static Hook deleteMidGameSaveHook;

		private static Hook midgameSaveHook;

		private static Hook invalidateSaveHook;

		private static Hook revalidateSaveHook;

		private static Hook frameDelayedInitizlizationHook;

		private static Hook moveSessionStatsHook;

		private static Hook prerequisiteHook;

		private static Hook clearActiveGameDataHook;

		private static Hook aiactorRewardsHook;

		private static Hook aiactorEngagedHook;

		private static bool m_loaded;

		public static SaveType AdvancedGameSave;

		public static SaveType AdvancedMidGameSave;

		public static OnActiveGameDataClearedDelegate OnActiveGameDataCleared;

		private static bool FirstLoad;

		public static bool IsFirstLoad => FirstLoad;

		public static void Setup(string prefix)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected O, but got Unknown
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Expected O, but got Unknown
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Expected O, but got Unknown
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Expected O, but got Unknown
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Expected O, but got Unknown