Decompiled source of Knife to a Gunfight v2.2.1

plugins/Knives.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using Alexandria.BreakableAPI;
using Alexandria.CharacterAPI;
using Alexandria.DungeonAPI;
using Alexandria.ItemAPI;
using Alexandria.Misc;
using Alexandria.NPCAPI;
using BepInEx;
using Brave.BulletScript;
using Dungeonator;
using EnemyAPI;
using FullSerializer;
using Gungeon;
using GungeonAPI;
using HarmonyLib;
using HutongGames.PlayMaker;
using InControl;
using ItemAPI;
using Knives;
using LootTableAPI;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MonoMod.Utils;
using NpcApi;
using Pathfinding;
using SGUI;
using SaveAPI;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
public class AmmoRegenComp : MonoBehaviour
{
	public float postShotRestartDelay = 0f;

	public float intervalTime;

	public bool CombatRequired = false;

	public float AmmoPer;

	private Gun m_gun;

	private float m_ammoCounter;

	private float m_gameTimeOnDisable;

	public AmmoRegenComp()
	{
		AmmoPer = 0.5f;
		m_ammoCounter = 0f;
	}

	private void Start()
	{
		m_gun = ((Component)this).GetComponent<Gun>();
	}

	public void Update()
	{
		if (postShotRestartDelay <= 0f)
		{
			if (Object.op_Implicit((Object)(object)m_gun.CurrentOwner) && !m_gun.IsFiring && ((PlayerController)/*isinst with value type is only supported in some contexts*/).IsInCombat)
			{
				m_ammoCounter += BraveTime.DeltaTime * AmmoPer;
				if (m_ammoCounter > 1f)
				{
					int num = Mathf.FloorToInt(m_ammoCounter);
					m_ammoCounter -= num;
					m_gun.GainAmmo(num);
				}
			}
		}
		else
		{
			postShotRestartDelay -= Time.deltaTime;
		}
		if (m_gun.IsFiring)
		{
			postShotRestartDelay = 0.35f;
		}
	}
}
public class BeamSplittingModifier : MonoBehaviour
{
	private Dictionary<BasicBeamController, float> subBeams;

	public float distanceTilSplit;

	public int amtToSplitTo;

	public float splitAngles;

	public float dmgMultOnSplit;

	private float originalRange;

	private Projectile projectile;

	private BasicBeamController basicBeamController;

	private BeamController beamController;

	private PlayerController owner;

	public BeamSplittingModifier()
	{
		subBeams = new Dictionary<BasicBeamController, float>();
		distanceTilSplit = 7f;
		amtToSplitTo = 0;
		splitAngles = 39f;
		dmgMultOnSplit = 0.66f;
	}

	private void Start()
	{
		projectile = ((Component)this).GetComponent<Projectile>();
		beamController = ((Component)this).GetComponent<BeamController>();
		basicBeamController = ((Component)this).GetComponent<BasicBeamController>();
		if (projectile.Owner is PlayerController)
		{
			ref PlayerController reference = ref owner;
			GameActor obj = projectile.Owner;
			reference = (PlayerController)(object)((obj is PlayerController) ? obj : null);
		}
		if (projectile.baseData.range > distanceTilSplit)
		{
			originalRange = projectile.baseData.range;
			projectile.baseData.range = distanceTilSplit;
		}
		else
		{
			distanceTilSplit = projectile.baseData.range;
		}
	}

	private void ClearExtantSubBeams()
	{
		if (subBeams.Count <= 0)
		{
			return;
		}
		for (int num = subBeams.Count - 1; num >= 0; num--)
		{
			if (Object.op_Implicit((Object)(object)subBeams.ElementAt(num).Key) && Object.op_Implicit((Object)(object)((Component)subBeams.ElementAt(num).Key).gameObject))
			{
				((BeamController)subBeams.ElementAt(num).Key).CeaseAttack();
			}
		}
		subBeams.Clear();
	}

	private void CreateNewSubBeams()
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		ClearExtantSubBeams();
		float num = splitAngles / ((float)amtToSplitTo - 1f);
		float finalBoneDirection = BeamAPI.GetFinalBoneDirection(basicBeamController);
		float num2 = finalBoneDirection + splitAngles * 0.5f;
		int num3 = 0;
		for (int i = 0; i < amtToSplitTo; i++)
		{
			LinkedList<BeamBone> bones = basicBeamController.m_bones;
			LinkedListNode<BeamBone> linkedListNode = null;
			if (bones != null)
			{
				linkedListNode = bones.Last;
				Vector2 bonePosition = basicBeamController.GetBonePosition(linkedListNode.Value);
				float num4 = num2 - num * (float)num3;
				GameObject val = FakePrefab.Clone(((Component)projectile).gameObject);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogError((object)"BeamSplitComp: Cloned Beam Prefab was NULL!");
				}
				BeamController component = val.GetComponent<BeamController>();
				if ((Object)(object)component == (Object)null)
				{
					Debug.LogError((object)"BeamSplitComp: ControllerPrefab was NULL!");
				}
				if (component is BasicBeamController)
				{
					GameObject val2 = Object.Instantiate<GameObject>(((Component)component).gameObject);
					BasicBeamController component2 = val2.GetComponent<BasicBeamController>();
					component2.State = (BeamState)2;
					((BeamController)component2).HitsPlayers = false;
					((BeamController)component2).HitsEnemies = true;
					((BeamController)component2).Origin = bonePosition;
					((BeamController)component2).Direction = MathsAndLogicHelper.DegreeToVector2(num4);
					((BeamController)component2).usesChargeDelay = false;
					component2.muzzleAnimation = string.Empty;
					component2.chargeAnimation = string.Empty;
					component2.beamStartAnimation = string.Empty;
					((BraveBehaviour)component2).projectile.Owner = projectile.Owner;
					((BeamController)component2).Owner = ((BeamController)basicBeamController).Owner;
					((BeamController)component2).Gun = ((BeamController)basicBeamController).Gun;
					if (originalRange > 0f)
					{
						((BraveBehaviour)component2).projectile.baseData.range = originalRange;
					}
					ProjectileData baseData = ((BraveBehaviour)component2).projectile.baseData;
					baseData.damage *= dmgMultOnSplit;
					if (Object.op_Implicit((Object)(object)((Component)component2).GetComponent<BeamSplittingModifier>()))
					{
						Object.Destroy((Object)(object)((Component)component2).GetComponent<BeamSplittingModifier>());
					}
					subBeams.Add(component2, num * (float)num3);
				}
				else
				{
					Debug.LogError((object)"BeamSplitComp: Controller prefab was not beam????");
				}
				num3++;
				continue;
			}
			Debug.LogError((object)"Bones was NULL");
			break;
		}
	}

	private void Update()
	{
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		if (projectile.baseData.range > distanceTilSplit)
		{
			originalRange = projectile.baseData.range;
			projectile.baseData.range = distanceTilSplit;
		}
		if (basicBeamController.ApproximateDistance >= distanceTilSplit && subBeams.Count < amtToSplitTo)
		{
			CreateNewSubBeams();
		}
		if (basicBeamController.ApproximateDistance < distanceTilSplit && subBeams.Count > 0)
		{
			ClearExtantSubBeams();
		}
		float finalBoneDirection = BeamAPI.GetFinalBoneDirection(basicBeamController);
		float num = finalBoneDirection + splitAngles * 0.5f;
		if (subBeams.Count > 0)
		{
			for (int i = 0; i < subBeams.Count; i++)
			{
				BasicBeamController key = subBeams.ElementAt(i).Key;
				LinkedList<BeamBone> bones = basicBeamController.m_bones;
				LinkedListNode<BeamBone> last = bones.Last;
				Vector2 bonePosition = basicBeamController.GetBonePosition(last.Value);
				float value = subBeams.ElementAt(i).Value;
				((BeamController)key).Direction = MathsAndLogicHelper.DegreeToVector2(num - value);
				((BeamController)key).Origin = bonePosition;
				((BeamController)key).LateUpdatePosition(Vector2.op_Implicit(bonePosition));
			}
		}
	}

	private void OnDestroy()
	{
		ClearExtantSubBeams();
	}
}
public class MiniAttackBehaviour : AttackBehaviorBase
{
	private List<AIActor> roomEnemies = new List<AIActor>();

	private PlayerController Owner;

	public float TickDelay = 0f;

	public float DesiredDistance = 20f;

	private float attackTimer;

	private bool isInRange;

	private bool isFiring = false;

	public override BehaviorResult Update()
	{
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		((BehaviorBase)this).DecrementTimer(ref attackTimer, false);
		if ((Object)(object)Owner == (Object)null)
		{
			if (Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor) && Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor.CompanionOwner))
			{
				Owner = ((BehaviorBase)this).m_aiActor.CompanionOwner;
			}
			else
			{
				Owner = GameManager.Instance.BestActivePlayer;
			}
		}
		if (Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor) && (Object)(object)((BehaviorBase)this).m_aiActor.OverrideTarget == (Object)null)
		{
			PickNewTarget();
		}
		if (Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor) && Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor.OverrideTarget))
		{
			SpeculativeRigidbody overrideTarget = ((BehaviorBase)this).m_aiActor.OverrideTarget;
			isInRange = Vector2.Distance(((BraveBehaviour)((BehaviorBase)this).m_aiActor).specRigidbody.UnitCenter, overrideTarget.UnitCenter) <= DesiredDistance;
			if (isInRange)
			{
				if ((Object)(object)overrideTarget != (Object)null && attackTimer == 0f && !isFiring)
				{
					AkSoundEngine.PostEvent("Play_OBJ_mine_beep_01", ((Component)((BehaviorBase)this).m_aiActor).gameObject);
					((MonoBehaviour)((BehaviorBase)this).m_aiActor).StartCoroutine(fail());
					return (BehaviorResult)2;
				}
				return (BehaviorResult)0;
			}
			return (BehaviorResult)0;
		}
		return (BehaviorResult)0;
	}

	public override float GetMaxRange()
	{
		return 10f;
	}

	public override float GetMinReadyRange()
	{
		return 10f;
	}

	public override bool IsReady()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		AIActor aiActor = ((BehaviorBase)this).m_aiActor;
		bool flag;
		if ((Object)(object)aiActor == (Object)null)
		{
			flag = true;
		}
		else
		{
			SpeculativeRigidbody targetRigidbody = aiActor.TargetRigidbody;
			flag = !(((Object)(object)targetRigidbody != (Object)null) ? new Vector2?(targetRigidbody.UnitCenter) : null).HasValue;
		}
		return !flag && Vector2.Distance(((BraveBehaviour)((BehaviorBase)this).m_aiActor).specRigidbody.UnitCenter, ((BehaviorBase)this).m_aiActor.TargetRigidbody.UnitCenter) <= ((AttackBehaviorBase)this).GetMinReadyRange();
	}

	private void PickNewTarget()
	{
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)((BehaviorBase)this).m_aiActor != (Object)null))
		{
			return;
		}
		if ((Object)(object)Owner == (Object)null)
		{
			if (Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor) && Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor.CompanionOwner))
			{
				Owner = ((BehaviorBase)this).m_aiActor.CompanionOwner;
			}
			else
			{
				Owner = GameManager.Instance.BestActivePlayer;
			}
		}
		Owner.CurrentRoom.GetActiveEnemies((ActiveEnemyType)1, ref roomEnemies);
		for (int i = 0; i < roomEnemies.Count; i++)
		{
			AIActor val = roomEnemies[i];
			if (val.IsHarmlessEnemy || !val.IsNormalEnemy || ((BraveBehaviour)val).healthHaver.IsDead || (Object)(object)val == (Object)(object)((BehaviorBase)this).m_aiActor || val.EnemyGuid == "ba928393c8ed47819c2c5f593100a5bc" || !((BraveBehaviour)val).healthHaver.IsVulnerable || !((BehaviorBase)this).m_aiActor.HasLineOfSightToRigidbody(((BraveBehaviour)val).specRigidbody))
			{
				roomEnemies.Remove(val);
			}
		}
		if (roomEnemies.Count == 0)
		{
			((BehaviorBase)this).m_aiActor.OverrideTarget = null;
			return;
		}
		AIActor aiActor = ((BehaviorBase)this).m_aiActor;
		AIActor val2 = null;
		int num = 99999;
		for (int j = 0; j < roomEnemies.Count; j++)
		{
			if (Vector2.Distance(Vector2.op_Implicit(roomEnemies[j].Position), Vector2.op_Implicit(aiActor.Position)) < (float)num)
			{
				val2 = roomEnemies[j];
			}
		}
		aiActor.OverrideTarget = (((Object)(object)val2 != (Object)null) ? ((BraveBehaviour)val2).specRigidbody : null);
	}

	private IEnumerator fail()
	{
		isFiring = true;
		((BehaviorBase)this).m_aiActor.MovementSpeed = 0f;
		bool BadCode = true;
		float angletotarget = 0f;
		if (Object.op_Implicit((Object)(object)((BehaviorBase)this).m_aiActor.TargetRigidbody))
		{
			angletotarget = Vector2Extensions.ToAngle(((BraveBehaviour)((BehaviorBase)this).m_aiActor).transform.position.CalculateVectorBetween(((BraveBehaviour)((BehaviorBase)this).m_aiActor.OverrideTarget).transform.position));
		}
		if (angletotarget > 90f || angletotarget < -90f)
		{
			((BraveBehaviour)((BehaviorBase)this).m_aiActor).aiAnimator.PlayForDuration("attack_left", 0.5f, false, (string)null, -1f, false);
			while (((BraveBehaviour)((BehaviorBase)this).m_aiActor).aiAnimator.IsPlaying("attack_left"))
			{
				if (((BraveBehaviour)((BehaviorBase)this).m_aiActor).spriteAnimator.CurrentFrame == 0 && BadCode)
				{
					BadCode = false;
					dodshoot();
				}
				if (((BraveBehaviour)((BehaviorBase)this).m_aiActor).spriteAnimator.CurrentFrame == 2 && !BadCode)
				{
					BadCode = true;
				}
				yield return null;
			}
		}
		else
		{
			((BraveBehaviour)((BehaviorBase)this).m_aiActor).aiAnimator.PlayForDuration("attack_right", 0.5f, false, (string)null, -1f, false);
			while (((BraveBehaviour)((BehaviorBase)this).m_aiActor).aiAnimator.IsPlaying("attack_right"))
			{
				if (((BraveBehaviour)((BehaviorBase)this).m_aiActor).spriteAnimator.CurrentFrame == 0 && BadCode)
				{
					BadCode = false;
					dodshoot();
				}
				if (((BraveBehaviour)((BehaviorBase)this).m_aiActor).spriteAnimator.CurrentFrame == 2 && !BadCode)
				{
					BadCode = true;
				}
				yield return null;
			}
		}
		((BehaviorBase)this).m_aiActor.OverrideTarget = null;
		isFiring = false;
		attackTimer = TickDelay;
		((BehaviorBase)this).m_aiActor.MovementSpeed = 0f;
	}

	public void dodshoot()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)((BehaviorBase)this).m_aiActor.TargetRigidbody != (Object)null)
		{
			Projectile projectile = ((BraveBehaviour)((Gun)PickupObjectDatabase.GetById(15)).DefaultModule.projectiles[0]).projectile;
			GameObject gameObject = ((Component)projectile).gameObject;
			Vector3 val = Vector2.op_Implicit(((BraveBehaviour)((BehaviorBase)this).m_aiActor).sprite.WorldCenter);
			Vector2 val2 = ((BraveBehaviour)((BehaviorBase)this).m_aiActor.OverrideTarget).specRigidbody.HitboxPixelCollider.UnitCenter - ((BraveBehaviour)((BehaviorBase)this).m_aiActor).specRigidbody.UnitCenter;
			GameObject val3 = SpawnManager.SpawnProjectile(gameObject, val, Quaternion.Euler(0f, 0f, BraveMathCollege.Atan2Degrees(((Vector2)(ref val2)).normalized)), true);
			Projectile component = val3.GetComponent<Projectile>();
			if ((Object)(object)component != (Object)null)
			{
				component.AdditionalScaleMultiplier *= 0.3f;
				component.baseData.damage = 3f;
				component.Owner = (GameActor)(object)((BehaviorBase)this).m_aiActor;
				component.Shooter = ((BraveBehaviour)Owner).specRigidbody;
				component.collidesWithPlayer = false;
				ProjectileData baseData = component.baseData;
				baseData.speed *= 2f;
				AkSoundEngine.PostEvent("Play_WPN_earthwormgun_shot_01", ((BehaviorBase)this).m_gameObject);
				component.OnHitEnemy = (Action<Projectile, SpeculativeRigidbody, bool>)Delegate.Combine(component.OnHitEnemy, new Action<Projectile, SpeculativeRigidbody, bool>(onhitenemy));
			}
		}
		((BehaviorBase)this).m_aiActor.MovementSpeed = 0f;
		attackTimer = 1f;
	}

	private void onhitenemy(Projectile proj, SpeculativeRigidbody hit, bool fatal)
	{
		if (fatal && (Object)(object)((BehaviorBase)this).m_aiActor != (Object)null)
		{
			GameObjectExtensions.GetOrAddComponent<AiactorSpecialStates>(((Component)((BehaviorBase)this).m_aiActor).gameObject).GlobalKillsGotten++;
		}
	}
}
public class EmmisiveBeams : MonoBehaviour
{
	private BasicBeamController beamcont;

	public float EmissivePower;

	public float EmissiveColorPower;

	public EmmisiveBeams()
	{
		EmissivePower = 100f;
		EmissiveColorPower = 1.55f;
	}

	public void Start()
	{
		Transform val = ((Component)this).transform.Find("beam impact vfx");
		tk2dSprite component = ((Component)val).GetComponent<tk2dSprite>();
		if ((Object)(object)component != (Object)null)
		{
			((BraveBehaviour)component).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			((BraveBehaviour)component).renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_ON");
			((BraveBehaviour)component).renderer.material.SetFloat("_EmissivePower", EmissivePower);
			((BraveBehaviour)component).renderer.material.SetFloat("_EmissiveColorPower", EmissiveColorPower);
		}
		beamcont = ((Component)this).GetComponent<BasicBeamController>();
		BasicBeamController val2 = beamcont;
		((BraveBehaviour)val2).sprite.usesOverrideMaterial = true;
		BasicBeamController component2 = ((Component)val2).gameObject.GetComponent<BasicBeamController>();
		if ((Object)(object)component2 != (Object)null)
		{
			((BraveBehaviour)((BraveBehaviour)component2).sprite).renderer.material.shader = ShaderCache.Acquire("Brave/LitTk2dCustomFalloffTintableTiltedCutoutEmissive");
			((BraveBehaviour)((BraveBehaviour)component2).sprite).renderer.material.EnableKeyword("BRIGHTNESS_CLAMP_ON");
			((BraveBehaviour)((BraveBehaviour)component2).sprite).renderer.material.SetFloat("_EmissivePower", EmissivePower);
			((BraveBehaviour)((BraveBehaviour)component2).sprite).renderer.material.SetFloat("_EmissiveColorPower", EmissiveColorPower);
		}
	}
}
namespace SaveAPI
{
	[fsObject]
	public class AdvancedGameStats
	{
		[fsProperty]
		private Dictionary<CustomTrackedStats, float> stats;

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

		[fsProperty]
		public HashSet<CustomCharacterSpecificGungeonFlags> m_flags;

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

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

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

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

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

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

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

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

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

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

		[fsProperty]
		public HashSet<CustomDungeonFlags> m_flags;

		[fsProperty]
		public string midGameSaveGuid;

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

		private AdvancedGameStats m_sessionStats;

		private AdvancedGameStats m_savedSessionStats;

		private PlayableCharacters m_sessionCharacter;

		private int m_numCharacters;

		[fsIgnore]
		public int cachedHuntIndex;

		[fsIgnore]
		public SaveSlot cachedSaveSlot;

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

		public static bool HasInstance => m_instance != null;

		public static AdvancedGameStatsManager Instance => m_instance;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		[fsProperty]
		public string midGameSaveGuid;

		[fsProperty]
		public bool invalidated;

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

		public bool IsValid()
		{
			return !invalidated;
		}

		public void Invalidate()
		{
			invalidated = true;
		}

		public void Revalidate()
		{
			invalidated = false;
		}

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

			private MetaShopTier m_bottomTier;

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

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

			public MetaShopTier GetTopTier()
			{
				return m_topTier;
			}

			public MetaShopTier GetBottomTier()
			{
				return m_topTier;
			}

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

		public static MetaShopController BaseMetaShopController;

		public static GenericLootTable TrorcMetaShopItems;

		public static GenericLootTable GooptonMetaShopItems;

		public static GenericLootTable DougMetaShopItems;

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

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

		private static Hook pickupObjectEncounterableHook;

		private static Hook baseShopSetupHook;

		private static Hook metaShopSetupHook;

		private static Hook metaShopCurrentTierHook;

		private static Hook metaShopProximateTierHook;

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

		public static List<MetaShopTier> metaShopAddedTiers;

		private static bool m_loaded;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		public AdvancedPrerequisiteType advancedPrerequisiteType;

		public CustomDungeonFlags customFlagToCheck;

		public bool requireCustomFlag;

		public Type requiredPassiveFlag;

		public CustomTrackedMaximums customMaximumToCheck;

		public CustomTrackedStats customStatToCheck;

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

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

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

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

		[SerializeField]
		public JammedEnemyState RequiredEnemyState;

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

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

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

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

		private static Hook huntProgressLoadedHook;

		private static Hook huntProgressCompleteHook;

		private static Hook huntProgressQuestCompleteHook;

		private static Hook huntProgressNextQuestHook;

		private static Hook huntProgressProcessKillHook;

		private static Hook huntQuestCompleteHook;

		private static Hook huntQuestUnlockRewardsHook;

		public static MonsterHuntData HuntData;

		public static List<MonsterHuntQuest> addedOrderedQuests;

		public static List<MonsterHuntQuest> addedProceduralQuests;

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

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

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

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

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

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

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

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

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

		public static void HuntProgressLoadedHook(Action<MonsterHuntProgress> orig, MonsterHuntProgress self)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			if (GameManager.HasInstance)
			{
				if (GameManager.Instance.platformInterface == null)
				{
					if (PlatformInterfaceSteam.IsSteamBuild())
					{
						GameManager.Instance.platformInterface = (PlatformInterface)new PlatformInterfaceSteam();
					}
					else if (PlatformInterfaceGalaxy.IsGalaxyBuild())
					{
						GameManager.Instance.platformInterface = (PlatformInterface)new PlatformInterfaceGalaxy();
					}
					else
					{
						GameManager.Instance.platformInterface = (PlatformInterface)new PlatformInterfaceGenericPC();
					}
				}
				GameManager.Instance.platformInterface.Start();
			}
			FieldInfo field = typeof(GameStatsManager).GetField("s_frifleHuntFlags", BindingFlags.Static | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(GameStatsManager).GetField("s_pastFlags", BindingFlags.Static | BindingFlags.NonPublic);
			FieldInfo field3 = typeof(GameStatsManager).GetField("s_npcFoyerFlags", BindingFlags.Static | BindingFlags.NonPublic);
			if (field2.GetValue(null) == null)
			{
				List<GungeonFlags> list = new List<GungeonFlags>();
				list.Add((GungeonFlags)18001);
				list.Add((GungeonFlags)18002);
				list.Add((GungeonFlags)18003);
				list.Add((GungeonFlags)18004);
				field2.SetValue(null, list);
			}
			if (field3.GetValue(null) == null)
			{
				List<GungeonFlags> list2 = new List<GungeonFlags>();
				list2.Add((GungeonFlags)40005);
				list2.Add((GungeonFlags)27505);
				list2.Add((GungeonFlags)55505);
				list2.Add((GungeonFlags)24505);
				list2.Add((GungeonFlags)2003);
				list2.Add((GungeonFlags)45500);
				list2.Add((GungeonFlags)30005);
				list2.Add((GungeonFlags)25506);
				list2.Add((GungeonFlags)28501);
				list2.Add((GungeonFlags)35051);
				field3.SetValue(null, list2);
			}
			if (field.GetValue(null) == null)
			{
				List<GungeonFlags> list3 = new List<GungeonFlags>();
				list3.Add((GungeonFlags)35101);
				list3.Add((GungeonFlags)35102);
				list3.Add((GungeonFlags)35103);
				list3.Add((GungeonFlags)35104);
				list3.Add((GungeonFlags)35105);
				list3.Add((GungeonFlags)35106);
				list3.Add((GungeonFlags)35107);
				list3.Add((GungeonFlags)35108);
				list3.Add((GungeonFlags)35109);
				list3.Add((GungeonFlags)35110);
				list3.Add((GungeonFlags)35111);
				list3.Add((GungeonFlags)35112);
				list3.Add((GungeonFlags)35113);
				list3.Add((GungeonFlags)35114);
				list3.Add((GungeonFlags)35500);
				field.SetValue(null, list3);
			}
			MonsterHuntQuest val = null;
			bool flag = GameStatsManager.Instance.GetFlag((GungeonFlags)35500);
			foreach (Monste