Decompiled source of GungeonCraft v1.21.0

GungeonCraft.dll

Decompiled 16 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Alexandria.BreakableAPI;
using Alexandria.CharacterAPI;
using Alexandria.CustomDodgeRollAPI;
using Alexandria.DungeonAPI;
using Alexandria.EnemyAPI;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using Alexandria.NPCAPI;
using Alexandria.cAPI;
using BepInEx;
using Brave.BulletScript;
using BraveDynamicTree;
using Dungeonator;
using FullInspector;
using FullSerializer;
using Gunfiguration;
using Gungeon;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using InControl;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using Mono.Collections.Generic;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using Pathfinding;
using SGUI;
using SaveAPI;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using tk2dRuntime.TileMap;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SaveAPI
{
	public class SpecialPickupObject : MonoBehaviour
	{
		public CustomDungeonFlags CustomSaveFlagToSetOnAcquisition;
	}
	public static class SaveTools
	{
		public static bool IsReallyCompleted(this MonsterHuntQuest quest)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			bool flag = true;
			foreach (GungeonFlags item in quest.FlagsToSetUponReward)
			{
				if ((int)item != 0 && !GameStatsManager.Instance.GetFlag(item))
				{
					flag = false;
					break;
				}
			}
			if (quest is CustomHuntQuest customHuntQuest)
			{
				if (flag)
				{
					foreach (CustomDungeonFlags item2 in customHuntQuest.CustomFlagsToSetUponReward)
					{
						if (item2 != 0 && !AdvancedGameStatsManager.Instance.GetFlag(item2))
						{
							flag = false;
							break;
						}
					}
				}
				bool flag2 = false;
				if ((int)quest.QuestFlag != 0)
				{
					flag2 = GameStatsManager.Instance.GetFlag(quest.QuestFlag);
				}
				else if (customHuntQuest.CustomQuestFlag != 0)
				{
					flag2 = AdvancedGameStatsManager.Instance.GetFlag(customHuntQuest.CustomQuestFlag);
				}
				return flag2 && flag;
			}
			return GameStatsManager.Instance.GetFlag(quest.QuestFlag) && flag;
		}

		public static void SafeMove(string oldPath, string newPath, bool allowOverwritting = false)
		{
			if (File.Exists(oldPath) && (allowOverwritting || !File.Exists(newPath)))
			{
				string text = SaveManager.ReadAllText(oldPath);
				try
				{
					SaveManager.WriteAllText(newPath, text);
				}
				catch (Exception ex)
				{
					Debug.LogErrorFormat("Failed to move {0} to {1}: {2}", new object[3] { oldPath, newPath, ex });
					return;
				}
				try
				{
					File.Delete(oldPath);
				}
				catch (Exception ex2)
				{
					Debug.LogErrorFormat("Failed to delete old file {0}: {1}", new object[3] { oldPath, newPath, ex2 });
					return;
				}
				if (File.Exists(oldPath + ".bak"))
				{
					File.Delete(oldPath + ".bak");
				}
			}
		}

		public static List<T2> Convert<T, T2>(this List<T> self, Func<T, T2> convertor)
		{
			List<T2> list = new List<T2>();
			foreach (T item in self)
			{
				list.Add(convertor(item));
			}
			return list;
		}

		public static bool SetsCustomFlagOnDeath(this AIActor enemy)
		{
			if ((Object)(object)((Component)enemy).GetComponent<SpecialAIActor>() != (Object)null)
			{
				return ((Component)enemy).GetComponent<SpecialAIActor>().SetsCustomFlagOnDeath;
			}
			return false;
		}

		public static CustomDungeonFlags GetCustomFlagToSetOnDeath(this AIActor enemy)
		{
			if (!((Object)(object)((Component)enemy).GetComponent<SpecialAIActor>() != (Object)null) || !((Component)enemy).GetComponent<SpecialAIActor>().SetsCustomFlagOnDeath)
			{
				return CustomDungeonFlags.NONE;
			}
			return ((Component)enemy).GetComponent<SpecialAIActor>().CustomFlagToSetOnDeath;
		}

		public static void SetCustomFlagToSetOnDeath(this AIActor enemy, CustomDungeonFlags flag)
		{
			SpecialAIActor orAddComponent = GameObjectExtensions.GetOrAddComponent<SpecialAIActor>(((Component)enemy).gameObject);
			if (flag == CustomDungeonFlags.NONE)
			{
				orAddComponent.SetsCustomFlagOnDeath = false;
			}
			else if (flag != 0)
			{
				orAddComponent.SetsCustomFlagOnDeath = true;
			}
			orAddComponent.CustomFlagToSetOnDeath = flag;
		}

		public static bool SetsCustomFlagOnActivation(this AIActor enemy)
		{
			if ((Object)(object)((Component)enemy).GetComponent<SpecialAIActor>() != (Object)null)
			{
				return ((Component)enemy).GetComponent<SpecialAIActor>().SetsCustomFlagOnActivation;
			}
			return false;
		}

		public static CustomDungeonFlags GetCustomFlagToSetOnActivation(this AIActor enemy)
		{
			if (!((Object)(object)((Component)enemy).GetComponent<SpecialAIActor>() != (Object)null) || !((Component)enemy).GetComponent<SpecialAIActor>().SetsCustomFlagOnActivation)
			{
				return CustomDungeonFlags.NONE;
			}
			return ((Component)enemy).GetComponent<SpecialAIActor>().CustomFlagToSetOnActivation;
		}

		public static void SetCustomFlagToSetOnActivation(this AIActor enemy, CustomDungeonFlags flag)
		{
			SpecialAIActor orAddComponent = GameObjectExtensions.GetOrAddComponent<SpecialAIActor>(((Component)enemy).gameObject);
			if (flag == CustomDungeonFlags.NONE)
			{
				orAddComponent.SetsCustomFlagOnActivation = false;
			}
			else if (flag != 0)
			{
				orAddComponent.SetsCustomFlagOnActivation = true;
			}
			orAddComponent.CustomFlagToSetOnActivation = flag;
		}

		public static bool SetsCustomCharacterSpecificFlagOnDeath(this AIActor enemy)
		{
			if ((Object)(object)((Component)enemy).GetComponent<SpecialAIActor>() != (Object)null)
			{
				return ((Component)enemy).GetComponent<SpecialAIActor>().SetsCustomCharacterSpecificFlagOnDeath;
			}
			return false;
		}

		public static CustomCharacterSpecificGungeonFlags GetCustomCharacterSpecificFlagToSetOnDeath(this AIActor enemy)
		{
			if (!((Object)(object)((Component)enemy).GetComponent<SpecialAIActor>() != (Object)null) || !((Component)enemy).GetComponent<SpecialAIActor>().SetsCustomCharacterSpecificFlagOnDeath)
			{
				return CustomCharacterSpecificGungeonFlags.NONE;
			}
			return ((Component)enemy).GetComponent<SpecialAIActor>().CustomCharacterSpecificFlagToSetOnDeath;
		}

		public static void SetCustomCharacterSpecificFlagToSetOnDeath(this AIActor enemy, CustomCharacterSpecificGungeonFlags flag)
		{
			SpecialAIActor orAddComponent = GameObjectExtensions.GetOrAddComponent<SpecialAIActor>(((Component)enemy).gameObject);
			if (flag == CustomCharacterSpecificGungeonFlags.NONE)
			{
				orAddComponent.SetsCustomCharacterSpecificFlagOnDeath = false;
			}
			else if (flag != 0)
			{
				orAddComponent.SetsCustomCharacterSpecificFlagOnDeath = true;
			}
			orAddComponent.CustomCharacterSpecificFlagToSetOnDeath = flag;
		}

		public static string PathCombine(string a, string b, string c)
		{
			return Path.Combine(Path.Combine(a, b), c);
		}

		public static DungeonPrerequisite SetupUnlockOnFlag(this PickupObject self, GungeonFlags flag, bool requiredFlagValue)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnFlag(flag, requiredFlagValue);
		}

		public static DungeonPrerequisite SetupUnlockOnFlag(this EncounterTrackable self, GungeonFlags flag, bool requiredFlagValue)
		{
			//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_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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0020: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)4,
				saveFlagToCheck = flag,
				requireFlag = requiredFlagValue
			});
		}

		public static DungeonPrerequisite SetupUnlockOnStat(this PickupObject self, TrackedStats stat, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnStat(stat, comparisonValue, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnStat(this EncounterTrackable self, TrackedStats stat, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//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_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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0027: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)1,
				statToCheck = stat,
				prerequisiteOperation = comparisonOperation,
				comparisonValue = comparisonValue
			});
		}

		public static DungeonPrerequisite SetupUnlockOnMaximum(this PickupObject self, TrackedMaximums maximum, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnMaximum(maximum, comparisonValue, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnMaximum(this EncounterTrackable self, TrackedMaximums maximum, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//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_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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0027: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)6,
				maxToCheck = maximum,
				prerequisiteOperation = comparisonOperation,
				comparisonValue = comparisonValue
			});
		}

		public static DungeonPrerequisite SetupUnlockOnEncounter(this PickupObject self, string encounterObjectGuid, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnEncounter(encounterObjectGuid, requiredNumberOfEncounters, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnEncounter(this EncounterTrackable self, string encounterObjectGuid, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//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_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_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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)0,
				encounteredObjectGuid = encounterObjectGuid,
				requiredNumberOfEncounters = requiredNumberOfEncounters,
				prerequisiteOperation = comparisonOperation
			});
		}

		public static DungeonPrerequisite SetupUnlockOnEncounter(this PickupObject self, PrototypeDungeonRoom encounterRoom, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnEncounter(encounterRoom, requiredNumberOfEncounters, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnEncounter(this EncounterTrackable self, PrototypeDungeonRoom encounterRoom, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//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_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_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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)0,
				encounteredRoom = encounterRoom,
				requiredNumberOfEncounters = requiredNumberOfEncounters,
				prerequisiteOperation = comparisonOperation
			});
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrFlag(this PickupObject self, GungeonFlags flag, bool requiredFlagValue, string encounterObjectGuid, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_0016: 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)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnEncounterOrFlag(flag, requiredFlagValue, encounterObjectGuid, requiredNumberOfEncounters, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrFlag(this EncounterTrackable self, GungeonFlags flag, bool requiredFlagValue, string encounterObjectGuid, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//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_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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_002b: 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_0037: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)7,
				saveFlagToCheck = flag,
				requireFlag = requiredFlagValue,
				encounteredObjectGuid = encounterObjectGuid,
				requiredNumberOfEncounters = requiredNumberOfEncounters,
				prerequisiteOperation = comparisonOperation
			});
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrFlag(this PickupObject self, GungeonFlags flag, bool requiredFlagValue, PrototypeDungeonRoom encounterRoom, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_0016: 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)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnEncounterOrFlag(flag, requiredFlagValue, encounterRoom, requiredNumberOfEncounters, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrFlag(this EncounterTrackable self, GungeonFlags flag, bool requiredFlagValue, PrototypeDungeonRoom encounterRoom, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//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_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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_002b: 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_0037: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)7,
				saveFlagToCheck = flag,
				requireFlag = requiredFlagValue,
				encounteredRoom = encounterRoom,
				requiredNumberOfEncounters = requiredNumberOfEncounters,
				prerequisiteOperation = comparisonOperation
			});
		}

		public static DungeonPrerequisite SetupUnlockOnTileset(this PickupObject self, ValidTilesets requiredTileset, bool requiredTilesetValue)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnTileset(requiredTileset, requiredTilesetValue);
		}

		public static DungeonPrerequisite SetupUnlockOnTileset(this EncounterTrackable self, ValidTilesets requiredTileset, bool requiredTilesetValue)
		{
			//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_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_0014: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)3,
				requireTileset = requiredTilesetValue,
				requiredTileset = requiredTileset
			});
		}

		public static DungeonPrerequisite SetupUnlockOnCharacter(this PickupObject self, PlayableCharacters requiredCharacter, bool requiredCharacterValue)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnCharacter(requiredCharacter, requiredCharacterValue);
		}

		public static DungeonPrerequisite SetupUnlockOnCharacter(this EncounterTrackable self, PlayableCharacters requiredCharacter, bool requiredCharacterValue)
		{
			//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_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_0014: 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			return self.AddPrerequisite(new DungeonPrerequisite
			{
				prerequisiteType = (PrerequisiteType)2,
				requireCharacter = requiredCharacterValue,
				requiredCharacter = requiredCharacter
			});
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrCustomFlag(this PickupObject self, CustomDungeonFlags flag, bool requiredFlagValue, string encounterObjectGuid, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnEncounterOrCustomFlag(flag, requiredFlagValue, encounterObjectGuid, requiredNumberOfEncounters, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrCustomFlag(this EncounterTrackable self, CustomDungeonFlags flag, bool requiredFlagValue, string encounterObjectGuid, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_002b: 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)
			return (DungeonPrerequisite)(object)self.AddPrerequisite(new CustomDungeonPrerequisite
			{
				advancedPrerequisiteType = CustomDungeonPrerequisite.AdvancedPrerequisiteType.ENCOUNTER_OR_CUSTOM_FLAG,
				customFlagToCheck = flag,
				requireCustomFlag = requiredFlagValue,
				encounteredObjectGuid = encounterObjectGuid,
				requiredNumberOfEncounters = requiredNumberOfEncounters,
				prerequisiteOperation = comparisonOperation
			});
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrCustomFlag(this PickupObject self, CustomDungeonFlags flag, bool requiredFlagValue, PrototypeDungeonRoom encounterRoom, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnEncounterOrCustomFlag(flag, requiredFlagValue, encounterRoom, requiredNumberOfEncounters, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnEncounterOrCustomFlag(this EncounterTrackable self, CustomDungeonFlags flag, bool requiredFlagValue, PrototypeDungeonRoom encounterRoom, int requiredNumberOfEncounters, PrerequisiteOperation comparisonOperation)
		{
			//IL_002b: 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)
			return (DungeonPrerequisite)(object)self.AddPrerequisite(new CustomDungeonPrerequisite
			{
				advancedPrerequisiteType = CustomDungeonPrerequisite.AdvancedPrerequisiteType.ENCOUNTER_OR_CUSTOM_FLAG,
				customFlagToCheck = flag,
				requireCustomFlag = requiredFlagValue,
				encounteredRoom = encounterRoom,
				requiredNumberOfEncounters = requiredNumberOfEncounters,
				prerequisiteOperation = comparisonOperation
			});
		}

		public static DungeonPrerequisite SetupUnlockOnCustomFlag(this PickupObject self, CustomDungeonFlags flag, bool requiredFlagValue)
		{
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnCustomFlag(flag, requiredFlagValue);
		}

		public static DungeonPrerequisite SetupUnlockOnCustomFlag(this EncounterTrackable self, CustomDungeonFlags flag, bool requiredFlagValue)
		{
			return (DungeonPrerequisite)(object)self.AddPrerequisite(new CustomDungeonPrerequisite
			{
				advancedPrerequisiteType = CustomDungeonPrerequisite.AdvancedPrerequisiteType.CUSTOM_FLAG,
				requireCustomFlag = requiredFlagValue,
				customFlagToCheck = flag
			});
		}

		public static DungeonPrerequisite SetupUnlockOnCustomStat(this PickupObject self, CustomTrackedStats stat, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnCustomStat(stat, comparisonValue, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnCustomStat(this EncounterTrackable self, CustomTrackedStats stat, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return (DungeonPrerequisite)(object)self.AddPrerequisite(new CustomDungeonPrerequisite
			{
				advancedPrerequisiteType = CustomDungeonPrerequisite.AdvancedPrerequisiteType.CUSTOM_STAT_COMPARISION,
				customStatToCheck = stat,
				prerequisiteOperation = comparisonOperation,
				comparisonValue = comparisonValue
			});
		}

		public static DungeonPrerequisite SetupUnlockOnCustomMaximum(this PickupObject self, CustomTrackedMaximums maximum, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnCustomMaximum(maximum, comparisonValue, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnCustomMaximum(this EncounterTrackable self, CustomTrackedMaximums maximum, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return (DungeonPrerequisite)(object)self.AddPrerequisite(new CustomDungeonPrerequisite
			{
				advancedPrerequisiteType = CustomDungeonPrerequisite.AdvancedPrerequisiteType.CUSTOM_MAXIMUM_COMPARISON,
				customMaximumToCheck = maximum,
				prerequisiteOperation = comparisonOperation,
				comparisonValue = comparisonValue
			});
		}

		public static DungeonPrerequisite SetupUnlockOnPastsBeaten(this PickupObject self, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((BraveBehaviour)self).encounterTrackable == (Object)null)
			{
				return null;
			}
			return ((BraveBehaviour)self).encounterTrackable.SetupUnlockOnPastsBeaten(comparisonValue, comparisonOperation);
		}

		public static DungeonPrerequisite SetupUnlockOnPastsBeaten(this EncounterTrackable self, float comparisonValue, PrerequisiteOperation comparisonOperation)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return (DungeonPrerequisite)(object)self.AddPrerequisite(new CustomDungeonPrerequisite
			{
				advancedPrerequisiteType = CustomDungeonPrerequisite.AdvancedPrerequisiteType.NUMBER_PASTS_COMPLETED_BETTER,
				prerequisiteOperation = comparisonOperation,
				comparisonValue = comparisonValue
			});
		}

		public static T AddPrerequisite<T>(this PickupObject self, T prereq) where T : DungeonPrerequisite
		{
			return (T)(object)self.AddPrerequisite((DungeonPrerequisite)(object)prereq);
		}

		public static T AddPrerequisite<T>(this EncounterTrackable self, T prereq) where T : DungeonPrerequisite
		{
			return (T)(object)self.AddPrerequisite((DungeonPrerequisite)(object)prereq);
		}

		public static DungeonPrerequisite AddPrerequisite(this PickupObject self, DungeonPrerequisite prereq)
		{
			return ((BraveBehaviour)self).encounterTrackable.AddPrerequisite(prereq);
		}

		public static DungeonPrerequisite AddPrerequisite(this EncounterTrackable self, DungeonPrerequisite prereq)
		{
			if (!string.IsNullOrEmpty(self.ProxyEncounterGuid))
			{
				self.ProxyEncounterGuid = "";
			}
			if (self.prerequisites == null)
			{
				self.prerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[1] { prereq };
			}
			else
			{
				self.prerequisites = self.prerequisites.Concat((IEnumerable<DungeonPrerequisite>)(object)new DungeonPrerequisite[1] { prereq }).ToArray();
			}
			EncounterDatabaseEntry entry = EncounterDatabase.GetEntry(self.EncounterGuid);
			if (!string.IsNullOrEmpty(entry.ProxyEncounterGuid))
			{
				entry.ProxyEncounterGuid = "";
			}
			if (entry.prerequisites == null)
			{
				entry.prerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[1] { prereq };
			}
			else
			{
				entry.prerequisites = entry.prerequisites.Concat((IEnumerable<DungeonPrerequisite>)(object)new DungeonPrerequisite[1] { prereq }).ToArray();
			}
			return prereq;
		}

		public static string ListToString<T>(List<T> list)
		{
			string text = "(";
			for (int i = 0; i < list.Count; i++)
			{
				string text2 = list[i].ToString();
				text += text2;
				if (i < list.Count - 1)
				{
					text += ", ";
				}
			}
			return text + ")";
		}

		public static void InsertOrAdd<T>(this List<T> self, int index, T toAdd)
		{
			if (index < 0 || index > self.Count)
			{
				self.Add(toAdd);
			}
			else
			{
				self.Insert(index, toAdd);
			}
		}

		public static void LogSmart(string text, bool debuglog = false)
		{
			if (ETGModConsole.Instance != null)
			{
				ETGModConsole.Log((object)text, debuglog);
			}
			else
			{
				Debug.Log((object)text);
			}
		}

		public static List<T> CloneList<T>(List<T> orig)
		{
			List<T> list = new List<T>();
			for (int i = 0; i < orig.Count; i++)
			{
				list.Add(orig[i]);
			}
			return list;
		}

		public static T LoadAssetFromAnywhere<T>(string path) where T : Object
		{
			string[] obj = new string[30]
			{
				"brave_resources_001", "dungeon_scene_001", "encounters_base_001", "enemies_base_001", "flows_base_001", "foyer_001", "foyer_002", "foyer_003", "shared_auto_001", "shared_auto_002",
				"shared_base_001", "dungeons/base_bullethell", "dungeons/base_castle", "dungeons/base_catacombs", "dungeons/base_cathedral", "dungeons/base_forge", "dungeons/base_foyer", "dungeons/base_gungeon", "dungeons/base_mines", "dungeons/base_nakatomi",
				"dungeons/base_resourcefulrat", "dungeons/base_sewer", "dungeons/base_tutorial", "dungeons/finalscenario_bullet", "dungeons/finalscenario_convict", "dungeons/finalscenario_coop", "dungeons/finalscenario_guide", "dungeons/finalscenario_pilot", "dungeons/finalscenario_robot", "dungeons/finalscenario_soldier"
			};
			T val = default(T);
			string[] array = obj;
			foreach (string text in array)
			{
				try
				{
					val = ResourceManager.LoadAssetBundle(text).LoadAsset<T>(path);
				}
				catch
				{
				}
				if ((Object)(object)val != (Object)null)
				{
					break;
				}
			}
			return val;
		}

		public static void SetComplex(this StringDBTable self, string key, params string[] values)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			StringCollection val = (StringCollection)new ComplexStringCollection();
			foreach (string text in values)
			{
				val.AddString(text, 1f);
			}
			self[key] = val;
		}

		public static bool IsEnemyStateValid(AIActor enemy, JammedEnemyState requiredState)
		{
			return requiredState switch
			{
				JammedEnemyState.NoCheck => true, 
				JammedEnemyState.Unjammed => !enemy.IsBlackPhantom, 
				JammedEnemyState.Jammed => enemy.IsBlackPhantom, 
				_ => false, 
			};
		}
	}
	public enum JammedEnemyState
	{
		NoCheck,
		Jammed,
		Unjammed
	}
	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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: 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_0019: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			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;
			if (self.ActiveQuest == null)
			{
				_ = self.ActiveQuest;
			}
			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;
				return result;
			}
			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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_006f: 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)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			_ = self.ActiveQuest;
			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;
			_ = self.ActiveQuest;
		}

		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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			_ = self.ActiveQuest;
			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.IsReallyCompleted())
				{
					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);
			_ = self.ActiveQuest;
		}

		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_0084: 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.Enemies.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_0084: 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.Enemies.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_0079: 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.Enemies.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_0078: 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)
			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.Enemies.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_0079: 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.Enemies.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_0078: 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)
			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.Enemies.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 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 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_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_0023: 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_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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0065: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Expected O, but got Unknown
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Expected O, but got Unknown
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Expected O, but got Unknown
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Expected O, but got Unknown
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Expected O, but got Unknown
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Expected O, but got Unknown
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Expected O, but got Unknown
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Expected O, but got Unknown
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Expected O, but got Unknown
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Expected O, but got Unknown
			if (!m_loaded)
			{
				AdvancedGameSave = new SaveType
				{
					filePattern = "Slot{0}." + prefix + "Save",
					encrypted = true,
					backupCount = 3,
					backupPattern = "Slot{0}." + prefix + "Backup.{1}",
					backupMinTimeMin = 45,
					legacyFilePattern = prefix + "GameStatsSlot{0}.txt"
				};
				AdvancedMidGameSave = new SaveType
				{
					filePattern = "Active{0}." + prefix + "Game",
					legacyFilePattern = prefix + "ActiveSlot{0}.txt",
					encrypted = true,
					backupCount = 0,
					backupPattern = "Active{0}." + prefix + "Backup.{1}",
					backupMinTimeMin = 60
				};
				for (int i = 0; i < 3; i++)
				{
					SaveSlot val = (SaveSlot)i;
					SaveTools.SafeMove(Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.legacyFilePattern, val)), Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.filePattern, val)));
					SaveTools.SafeMove(Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.filePattern, val)), Path.Combine(SaveManager.OldSavePath, string.Format(AdvancedGameSave.filePattern, val)));
					SaveTools.SafeMove(SaveTools.PathCombine(SaveManager.SavePath, "01", string.Format(AdvancedGameSave.filePattern, val)), Path.Combine(SaveManager.SavePath, string.Format(AdvancedGameSave.filePattern, val)), allowOverwritting: true);
				}
				saveHook = new Hook((MethodBase)typeof(GameStatsManager).GetMethod("Save", BindingFlags.Static | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("SaveHook"));
				loadHook = new Hook((MethodBase)typeof(GameStatsManager).GetMethod("Load", BindingFlags.Static | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("LoadHook"));
				resetHook = new Hook((MethodBase)typeof(GameStatsManager).GetMethod("DANGEROUS_ResetAllStats", BindingFlags.Static | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("ResetHook"));
				beginSessionHook = new Hook((MethodBase)typeof(GameStatsManager).GetMethod("BeginNewSession", BindingFlags.Instance | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("BeginSessionHook"));
				endSessionHook = new Hook((MethodBase)typeof(GameStatsManager).GetMethod("EndSession", BindingFlags.Instance | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("EndSessionHook"));
				clearAllStatsHook = new Hook((MethodBase)typeof(GameStatsManager).GetMethod("ClearAllStatsGlobal", BindingFlags.Instance | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("ClearAllStatsHook"));
				deleteMidGameSaveHook = new Hook((MethodBase)typeof(SaveManager).GetMethod("DeleteCurrentSlotMidGameSave", BindingFlags.Static | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("DeleteMidGameSaveHook"));
				midgameSaveHook = new Hook((MethodBase)typeof(GameManager).GetMethod("DoMidgameSave", BindingFlags.Static | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("MidgameSaveHook"));
				invalidateSaveHook = new Hook((MethodBase)typeof(GameManager).GetMethod("InvalidateMidgameSave", BindingFlags.Static | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("InvalidateSaveHook"));
				revalidateSaveHook = new Hook((MethodBase)typeof(GameManager).GetMethod("RevalidateMidgameSave", BindingFlags.Static | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("RevalidateSaveHook"));
				frameDelayedInitizlizationHook = new Hook((MethodBase)typeof(Dungeon).GetMethod("FrameDelayedMidgameInitialization", BindingFlags.Instance | BindingFlags.NonPublic), typeof(SaveAPIManager).GetMethod("FrameDelayedInitizlizationHook"));
				moveSessionStatsHook = new Hook((MethodBase)typeof(GameStatsManager).GetMethod("MoveSessionStatsToSavedSessionStats", BindingFlags.Instance | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("MoveSessionStatsHook"));
				prerequisiteHook = new Hook((MethodBase)typeof(DungeonPrerequisite).GetMethod("CheckConditionsFulfilled", BindingFlags.Instance | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("PrerequisiteHook"));
				clearActiveGameDataHook = new Hook((MethodBase)typeof(GameManager).GetMethod("ClearActiveGameData", BindingFlags.Instance | BindingFlags.Public), typeof(SaveAPIManager).GetMethod("ClearActiveGameDataHook"));
				aiactorRewardsHook = new Hook((MethodBase)typeof(AIActor).GetMethod("HandleRewards", BindingFlags.Instance | BindingFlags.NonPublic), typeof(SaveAPIManager).GetMethod("AIActorRewardsHook"));
				aiactorEngagedHook = new Hook((MethodBase)typeof(AIActor).GetMethod("OnEngaged", BindingFlags.Instance | BindingFlags.NonPublic), typeof(SaveAPIManager).GetMethod("AIActorEngagedHook"));
				LoadGameStatsFirstLoad();
				BreachShopTool.DoSetup();
				m_loaded = true;
			}
		}

		public static void Reload(string prefix)
		{
			Unload();
			Setup(prefix);
		}

		private static void LoadGameStatsFirstLoad()
		{
			bool firstLoad = FirstLoad;
			FirstLoad = true;
			GameStatsManager.Load();
			FirstLoad = firstLoad;
		}

		public static void Unload()
		{
			if (m_loaded)
			{
				AdvancedGameSave = null;
				AdvancedMidGameSave = null;
				Hook obj = saveHook;
				if (obj != null)
				{
					obj.Dispose();
				}
				Hook obj2 = loadHook;
				if (obj2 != null)
				{
					obj2.Dispose();
				}
				Hook obj3 = resetHook;
				if (obj3 != null)
				{
					obj3.Dispose();
				}
				Hook obj4 = beginSessionHook;
				if (obj4 != null)
				{
					obj4.Dispose();
				}
				Hook obj5 = endSessionHook;
				if (obj5 != null)
				{
					obj5.Dispose();
				}
				Hook obj6 = clearAllStatsHook;
				if (obj6 != null)
				{
					obj6.Dispose();
				}
				Hook obj7 = deleteMidGameSaveHook;
				if (obj7 != null)
				{
					obj7.Dispose();
				}
				Hook obj8 = midgameSaveHook;
				if (obj8 != null)
				{
					obj8.Dispose();
				}
				Hook obj9 = invalidateSaveHook;
				if (obj9 != null)
				{
					obj9.Dispose();
				}
				Hook obj10 = revalidateSaveHook;
				if (obj10 != null)
				{
					obj10.Dispose();
				}
				Hook obj11 = frameDelayedInitizlizationHook;
				if (obj11 != null)
				{
					obj11.Dispose();
				}
				Hook obj12 = moveSessionStatsHook;
				if (obj12 != null)
				{
					obj12.Dispose();
				}
				Hook obj13 = prerequisiteHook;
				if (obj13 != null)
				{
					obj13.Dispose();
				}
				Hook obj14 = clearActiveGameDataHook;
				if (obj14 != null)
				{
					obj14.Dispose();
				}
				Hook obj15 = aiactorRewardsHook;
				if (obj15 != null)
				{
					obj15.Dispose();
				}
				Hook obj16 = aiactorEngagedHook;
				if (obj16 != null)
				{
					obj16.Dispose();
				}
				CustomHuntQuests.Unload();
				AdvancedGameStatsManager.Save();
				AdvancedGameStatsManager.Unload();
				BreachShopTool.Unload();
				m_loaded = false;
			}
		}

		public static bool GetFlag(CustomDungeonFlags flag)
		{
			if (!AdvancedGameStatsManager.HasInstance)
			{
				return false;
			}
			return AdvancedGameStatsManager.Instance.GetFlag(flag);
		}

		public static float GetPlayerStatValue(CustomTrackedStats stat)
		{
			if (!AdvancedGameStatsManager.HasInstance)
			{
				return 0f;
			}
			return AdvancedGameStatsManager.Instance.GetPlayerStatValue(stat);
		}

		public static float GetSessionStatValue(CustomTrackedStats stat)
		{
			if (AdvancedGameStatsManager.HasInstance && AdvancedGameStatsManager.Instance.IsInSession)
			{
				return AdvancedGameStatsManager.Instance.GetSessionStatValue(stat);
			}
			return 0f;
		}

		public static float GetCharacterStatValue(PlayableCharacters character, CustomTrackedStats stat)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (AdvancedGameStatsManager.HasInstance)
			{
				return AdvancedGameStatsManager.Instance.GetCharacterStatValue(character, stat);
			}
			return 0f;
		}

		public static float GetCharacterStatValue(CustomTrackedStats stat)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				if (GameManager.HasInstance && (Object)(object)GameManager.Instance.PrimaryPlayer != (Object)null)
				{
					return AdvancedGameStatsManager.Instance.GetCharacterStatValue(stat);
				}
				return AdvancedGameStatsManager.Instance.GetCharacterStatValue((PlayableCharacters)0, stat);
			}
			return 0f;
		}

		public static bool GetCharacterSpecificFlag(CustomCharacterSpecificGungeonFlags flag)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				if (AdvancedGameStatsManager.Instance.IsInSession)
				{
					return AdvancedGameStatsManager.Instance.GetCharacterSpecificFlag(flag);
				}
				return AdvancedGameStatsManager.Instance.GetCharacterSpecificFlag((PlayableCharacters)0, flag);
			}
			return false;
		}

		public static bool GetCharacterSpecificFlag(PlayableCharacters character, CustomCharacterSpecificGungeonFlags flag)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (AdvancedGameStatsManager.HasInstance)
			{
				return AdvancedGameStatsManager.Instance.GetCharacterSpecificFlag(character, flag);
			}
			return false;
		}

		public static float GetPlayerMaximum(CustomTrackedMaximums maximum)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				return AdvancedGameStatsManager.Instance.GetPlayerMaximum(maximum);
			}
			return 0f;
		}

		public static void SetFlag(CustomDungeonFlags flag, bool value)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				AdvancedGameStatsManager.Instance.SetFlag(flag, value);
			}
		}

		public static void SetStat(CustomTrackedStats stat, float value)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				AdvancedGameStatsManager.Instance.SetStat(stat, value);
			}
		}

		public static void RegisterStatChange(CustomTrackedStats stat, float value)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				AdvancedGameStatsManager.Instance.RegisterStatChange(stat, value);
			}
		}

		public static void UpdateMaximum(CustomTrackedMaximums maximum, float value)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				AdvancedGameStatsManager.Instance.UpdateMaximum(maximum, value);
			}
		}

		public static void SetCharacterSpecificFlag(CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			if (AdvancedGameStatsManager.HasInstance)
			{
				AdvancedGameStatsManager.Instance.SetCharacterSpecificFlag(flag, value);
			}
		}

		public static void SetCharacterSpecificFlag(PlayableCharacters character, CustomCharacterSpecificGungeonFlags flag, bool value)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (AdvancedGameStatsManager.HasInstance)
			{
				AdvancedGameStatsManager.Instance.SetCharacterSpecificFlag(character, flag, value);
			}
		}

		public static void AIActorEngagedHook(Action<AIActor, bool> orig, AIActor self, bool isReinforcement)
		{
			if (!self.HasBeenEngaged && self.SetsCustomFlagOnActivation())
			{
				AdvancedGameStatsManager.Instance.SetFlag(self.GetCustomFlagToSetOnActivation(), value: true);
			}
			orig(self, isReinforcement);
		}

		public static void AIActorRewardsHook(Action<AIActor> orig, AIActor self)
		{
			if (!(bool)typeof(AIActor).GetField("m_hasGivenRewards", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(self) && !self.IsTransmogrified)
			{
				if (self.SetsCustomFlagOnDeath())
				{
					AdvancedGameStatsManager.Instance.SetFlag(self.GetCustomFlagToSetOnDeath(), value: true);
				}
				if (self.SetsCustomCharacterSpecificFlagOnDeath())
				{
					AdvancedGameStatsManager.Instance.SetCharacterSpecificFlag(self.GetCustomCharacterSpecificFlagToSetOnDeath(), value: true);
				}
			}
			orig(self);
		}

		public static bool SaveHook(Func<bool> orig)
		{
			bool result = orig();
			AdvancedGameStatsManager.Save();
			return result;
		}

		public static void LoadHook(Action orig)
		{
			AdvancedGameStatsManager.Load();
			orig();
		}

		public static void ResetHook(Action orig)
		{
			AdvancedGameStatsManager.DANGEROUS_ResetAllStats();
			orig();
		}

		public static void BeginSessionHook(Action<GameStatsManager, PlayerController> orig, GameStatsManager self, PlayerController player)
		{
			orig(self, player);
			AdvancedGameStatsManager.Instance.BeginNewSession(player);
		}

		public static void EndSessionHook(Action<GameStatsManager, bool, bool> orig, GameStatsManager self, bool recordSessionStats, bool decrementDifferentiator = true)
		{
			orig(self, recordSessionStats, decrementDifferentiator);
			AdvancedGameStatsManager.Instance.EndSession(recordSessionStats);
		}

		public static void ClearAllStatsHook(Action<GameStatsManager> orig, GameStatsManager self)
		{
			orig(self);
			AdvancedGameStatsManager.Instance.ClearAllStatsGlobal();
		}

		public static void DeleteMidGameSaveHook(Action<SaveSlot?> orig, SaveSlot? overrideSaveSlot)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			orig(overrideSaveSlot);
			if (AdvancedGameStatsManager.HasInstance)
			{
				AdvancedGameStatsManager.Instance.midGameSaveGuid = null;
			}
			string path = string.Format(SaveManager.MidGameSave.filePattern, (!overrideSaveSlot.HasValue) ? SaveManager.CurrentSaveSlot : overrideSaveSlot.Value);
			string path2 = Path.Combine(SaveManager.SavePath, path);
			if (File.Exists(path2))
			{
				File.Delete(path2);
			}
		}

		public static void MidgameSaveHook(Action<ValidTilesets> orig, ValidTilesets tileset)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			AdvancedGameStatsManager.DoMidgameSave();
			orig(tileset);
		}

		public static void InvalidateSaveHook(Action<bool> orig, bool savestats)
		{
			AdvancedGameStatsManager.InvalidateMidgameSave(saveStats: false);
			orig(savestats);
		}

		public static void RevalidateSaveHook(Action orig)
		{
			AdvancedGameStatsManager.RevalidateMidgameSave(saveStats: false);
			orig();
		}

		public static IEnumerator FrameDelayedInitizlizationHook(Func<Dungeon, MidGameSaveData, IEnumerator> orig, Dungeon self, MidGameSaveData data)
		{
			yield return orig(self, data);
			if (AdvancedGameStatsManager.VerifyAndLoadMidgameSave(out var midgameSave))
			{
				midgameSave.LoadDataFromMidGameSave();
			}
		}

		public static GameStats MoveSessionStatsHook(Func<GameStatsManager, GameStats> orig, GameStatsManager self)
		{
			AdvancedGameStatsManager.Instance.MoveSessionStatsToSavedSessionStats();
			return orig(self);
		}

		public static bool PrerequisiteHook(Func<DungeonPrerequisite, bool> orig, DungeonPrerequisite self)
		{
			if (self is CustomDungeonPrerequisite)
			{
				return (self as CustomDungeonPrerequisite).CheckConditionsFulfilled();
			}
			return orig(self);
		}

		public static void ClearActiveGameDataHook(Action<GameManager, bool, bool> orig, GameManager self, bool destroyGameManager, bool endSession)
		{
			orig(self, destroyGameManager, endSession);
			OnActiveGameDataCleared?.Invoke(self, destroyGameManager, endSession);
		}
	}
	public class SpecialAIActor : MonoBehaviour
	{
		public bool SetsCustomFlagOnActivation;

		public CustomDungeonFlags CustomFlagToSetOnActivation;

		public bool SetsCustomFlagOnDeath;

		public CustomDungeonFlags CustomFlagToSetOnDeath;

		public bool SetsCustomCharacterSpecificFlagOnDeath;

		public CustomCharacterSpecificGungeonFlags CustomCharacterSpecificFlagToSetOnDeath;
	}
	[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;
			}
		}
	}
	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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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;
			}
			if (self.metaShopTiers.IndexOf(val) >= self.metaShopTiers.IndexOf(val2))
			{
				return val2;
			}
			return val;
		}

		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;
			}
			if (self.metaShopTiers.IndexOf(val) >= self.metaShopTiers.IndexOf(val2))
			{
				return val2;
			}
			return val;
		}

		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_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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)
		{
			if ((Object)(object)PickupObjectDatabase.GetById(shopItemId) != (Object)null)
			{
				return PickupObjectDatabase.GetById(shopItemId).PrerequisitesMet();
			}
			return false;
		}

		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))
				{
					EncounterTrackable encounterTrackable = ((BraveBehaviour)val).encounterTrackable;
					if (Object.op_Implicit((Object)(object)encounterTrackable) && encounterTrackable.journalData.PrimaryDisplayName.Equals(blueprintTrackable.journalData.PrimaryDisplayName, StringComparison.OrdinalIgnoreCase) && encounterTrackable.journalData.NotificationPanelDescription.Equals(blueprintTrackable.journalData.NotificationPanelDescription, StringComparison.OrdinalIgnoreCase) && encounterTrackable.journalData.AmmonomiconFullEntry.Equals(blueprintTrackable.journalData.AmmonomiconFullEntry, StringComparison.OrdinalIgnoreCase) && encounterTrackable.journalData.AmmonomiconSprite.Equals(blueprintTrackable.journalData.AmmonomiconSprite, StringComparison.OrdinalIgnoreCase))
					{
						return val;
					}
				}
			}
			return null;
		}

		public static WeightedGameObject AddItemToTrorcMetaShop(this PickupObject po, int cost, int? index = null)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0046: Expected O, but got Unknown
			if ((Object)(object)TrorcMetaShopItems == (Object)null)
			{