Decompiled source of MetaLimits v1.0.6

plugins/MetaLimits.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Alexandria.Misc;
using BepInEx;
using Dungeonator;
using Gunfiguration;
using HarmonyLib;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using UnityEngine;

[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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MetaLimits;

public static class MetaConfig
{
	public static Gunfig _Gunfig = null;

	internal const string PILOTPAST_LABEL = "The Pilot's Affinity";

	private static readonly List<string> PILOTPAST_OPTIONS = new List<string>();

	private static readonly List<string> PILOTPAST_DESCRIPTIONS = new List<string>();

	internal const string MARINEPAST_LABEL = "The Marine's Affinity";

	private static readonly List<string> MARINEPAST_OPTIONS = new List<string>();

	private static readonly List<string> MARINEPAST_DESCRIPTIONS = new List<string>();

	internal const string CONVICTPAST_LABEL = "The Convict's Affinity";

	private static readonly List<string> CONVICTPAST_OPTIONS = new List<string>();

	private static readonly List<string> CONVICTPAST_DESCRIPTIONS = new List<string>();

	internal const string HUNTERPAST_LABEL = "The Hunter's Affinity";

	private static readonly List<string> HUNTERPAST_OPTIONS = new List<string>();

	private static readonly List<string> HUNTERPAST_DESCRIPTIONS = new List<string>();

	internal const string BULLETPAST_LABEL = "The Bullet's Affinity";

	private static readonly List<string> BULLETPAST_OPTIONS = new List<string>();

	private static readonly List<string> BULLETPAST_DESCRIPTIONS = new List<string>();

	internal const string ROBOTPAST_LABEL = "The Robot's Affinity";

	private static readonly List<string> ROBOTPAST_OPTIONS = new List<string>();

	private static readonly List<string> ROBOTPAST_DESCRIPTIONS = new List<string>();

	internal const string PARADOXPAST_LABEL = "The Paradox's Affinity";

	private static readonly List<string> PARADOXPAST_OPTIONS = new List<string>();

	private static readonly List<string> PARADOXPAST_DESCRIPTIONS = new List<string>();

	internal const string SLINGERPAST_LABEL = "The Slinger's Affinity";

	private static readonly List<string> SLINGERPAST_OPTIONS = new List<string>();

	private static readonly List<string> SLINGERPAST_DESCRIPTIONS = new List<string>();

	internal const string COOPCHEST_LABEL = "The Cultist's Affinity";

	private static readonly List<string> COOPCHEST_OPTIONS = new List<string>();

	private static readonly List<string> COOPCHEST_DESCRIPTIONS = new List<string>();

	internal const string STARTCHEST_LABEL = "The Gungeon's Affinity";

	private static readonly List<string> STARTCHEST_OPTIONS = new List<string>();

	private static readonly List<string> STARTCHEST_DESCRIPTIONS = new List<string>();

	internal const string MULTI_LABEL = "Bowler's Affinity";

	private static readonly List<string> MULTI_OPTIONS = new List<string>();

	private static readonly List<string> MULTI_DESCRIPTIONS = new List<string>();

	internal const string MAGNIFICENCE_LABEL = "Frifle and Mauser's Affinity";

	private static readonly List<string> MAGNIFICENCE_OPTIONS = new List<string>();

	private static readonly List<string> MAGNIFICENCE_DESCRIPTIONS = new List<string>();

	internal const string SYNERGYCHEST_LABEL = "Sorceress's Affinity";

	private static readonly List<string> SYNERGYCHEST_OPTIONS = new List<string>();

	private static readonly List<string> SYNERGYCHEST_DESCRIPTIONS = new List<string>();

	internal const string SYNERGYFACTOR_LABEL = "Tinker's Affinity";

	private static readonly List<string> SYNERGYFACTOR_OPTIONS = new List<string>();

	private static readonly List<string> SYNERGYFACTOR_DESCRIPTIONS = new List<string>();

	internal const string SYNERGYFUSE_LABEL = "Tonic's Affinity";

	private static readonly List<string> SYNERGYFUSE_OPTIONS = new List<string>();

	private static readonly List<string> SYNERGYFUSE_DESCRIPTIONS = new List<string>();

	internal const string SYNERGYCHESTSPAWN_LABEL = "Advanced Dragun's Affinity";

	private static readonly List<string> SYNERGYCHESTSPAWN_OPTIONS = new List<string>();

	private static readonly List<string> SYNERGYCHESTSPAWN_DESCRIPTIONS = new List<string>();

	internal const string CAP_LABEL = "The Bosses' Affinity";

	private static readonly List<string> CAP_OPTIONS = new List<string>();

	private static readonly List<string> CAP_DESCRIPTIONS = new List<string>();

	internal const string RAT_LABEL = "Resourceful Rat's Affinity";

	private static readonly List<string> RAT_OPTIONS = new List<string>();

	private static readonly List<string> RAT_DESCRIPTIONS = new List<string>();

	private static void BuildOptions()
	{
		//IL_0195: 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_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_0694: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0734: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0812: Unknown result type (might be due to invalid IL or missing references)
		//IL_0829: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a32: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
		//IL_110b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b42: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b86: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c0e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c53: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c97: Unknown result type (might be due to invalid IL or missing references)
		//IL_135c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cdb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d1d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d5f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d76: Unknown result type (might be due to invalid IL or missing references)
		Color val = default(Color);
		((Color)(ref val))..ctor(1f, 0.4f, 0f);
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(1f, 0.7f, 4f);
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(0f, 0.6f, 0.4f);
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(0.5f, 0.5f, 1f);
		Color val5 = default(Color);
		((Color)(ref val5))..ctor(1f, 0.5f, 0.7f);
		Color val6 = default(Color);
		((Color)(ref val6))..ctor(0f, 1f, 0.8f);
		Color val7 = default(Color);
		((Color)(ref val7))..ctor(0.5f, 0.5f, 0.8f);
		Color val8 = default(Color);
		((Color)(ref val8))..ctor(0.8f, 0.4f, 0f);
		Color val9 = default(Color);
		((Color)(ref val9))..ctor(0.1f, 0.3f, 1f);
		Color val10 = default(Color);
		((Color)(ref val10))..ctor(0.7f, 0.9f, 0.8f);
		Color val11 = default(Color);
		((Color)(ref val11))..ctor(0.1f, 0.7f, 0.8f);
		Color val12 = default(Color);
		((Color)(ref val12))..ctor(0.6f, 0f, 0f);
		Color val13 = default(Color);
		((Color)(ref val13))..ctor(1f, 0f, 0.4f);
		Color val14 = default(Color);
		((Color)(ref val14))..ctor(0.3f, 0.4f, 0.55f);
		Color val15 = default(Color);
		((Color)(ref val15))..ctor(0.3f, 0.5f, 0.15f);
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)18001))
		{
			PILOTPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			PILOTPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Mimic chests spawn 2.25% of the time. Increased with curse."));
			PILOTPAST_OPTIONS.Add(GunfigHelpers.WithColor("More Mimics", val5));
			PILOTPAST_DESCRIPTIONS.Add(GunfigHelpers.WithColor("Mimic chests spawn an additive 10% of the time.", val5));
		}
		else
		{
			PILOTPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			PILOTPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Pilot's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)18003))
		{
			MARINEPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			MARINEPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Normal ammo drop chance."));
			MARINEPAST_OPTIONS.Add(GunfigHelpers.WithColor("Ample Ammo", val3));
			MARINEPAST_DESCRIPTIONS.Add(GunfigHelpers.WithColor("Increases ammo drop chance by a multiplicative  125%", val3));
		}
		else
		{
			MARINEPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			MARINEPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Marine's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)18002))
		{
			CONVICTPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			CONVICTPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Normal boss Hegemony drops."));
			CONVICTPAST_OPTIONS.Add(GunfigHelpers.Green("Hearty Hegemony"));
			CONVICTPAST_DESCRIPTIONS.Add(GunfigHelpers.Green("Bosses drop 1 additional base Hegemony."));
		}
		else
		{
			CONVICTPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			CONVICTPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Convict's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)18004))
		{
			HUNTERPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			HUNTERPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Room rewards are about 9% likely every room clear without getting a reward."));
			HUNTERPAST_OPTIONS.Add(GunfigHelpers.WithColor("Refreshed Rewards", val));
			HUNTERPAST_DESCRIPTIONS.Add(GunfigHelpers.WithColor("Incremental room reward chance increased by an additive 2%", val));
		}
		else
		{
			HUNTERPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			HUNTERPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Hunter's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)18006))
		{
			BULLETPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			BULLETPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Start with 0 curse and coolness."));
			BULLETPAST_OPTIONS.Add(GunfigHelpers.WithColor("Cure Curse", val13));
			BULLETPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Picking up health or armor removes 1 curse point one time per run."));
			BULLETPAST_OPTIONS.Add(GunfigHelpers.Cyan("Cause Coolness"));
			BULLETPAST_DESCRIPTIONS.Add(GunfigHelpers.Cyan("Start with 1 coolness."));
		}
		else
		{
			BULLETPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			BULLETPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Bullet's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)18005))
		{
			ROBOTPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			ROBOTPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Base starting armor."));
			ROBOTPAST_OPTIONS.Add(GunfigHelpers.Blue("Additional Armor"));
			ROBOTPAST_DESCRIPTIONS.Add(GunfigHelpers.Blue("Start with 1 additional point of armor."));
		}
		else
		{
			ROBOTPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			ROBOTPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Robot's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)10504))
		{
			PARADOXPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			PARADOXPAST_DESCRIPTIONS.Add(GunfigHelpers.White("Glitch chest appearance rate of 0.1%"));
			PARADOXPAST_OPTIONS.Add(GunfigHelpers.Magenta("Gather Glitches"));
			PARADOXPAST_DESCRIPTIONS.Add(GunfigHelpers.Magenta("Glitch chest appearance rate increased to 0.6%"));
		}
		else
		{
			PARADOXPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			PARADOXPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Paradox's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)52001))
		{
			SLINGERPAST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			SLINGERPAST_DESCRIPTIONS.Add(GunfigHelpers.White("The Paradox and The Slinger cost full Hegemony prices."));
			SLINGERPAST_OPTIONS.Add(GunfigHelpers.Green("Fast Fingers"));
			SLINGERPAST_DESCRIPTIONS.Add(GunfigHelpers.Green("Steal back some Hegemony from The Paradox and The Slinger on the character select screen."));
		}
		else
		{
			SLINGERPAST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			SLINGERPAST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Slinger's Past."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)100000))
		{
			COOPCHEST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			COOPCHEST_DESCRIPTIONS.Add(GunfigHelpers.White("Only spawn one copy of initial chests."));
			COOPCHEST_OPTIONS.Add(GunfigHelpers.WithColor("The Power of Friendship", val13));
			COOPCHEST_DESCRIPTIONS.Add(GunfigHelpers.WithColor("Spawn a duplicate chest at the start of Co-op Mode.", val13));
		}
		else
		{
			COOPCHEST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			COOPCHEST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete a Co-op Run."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)10500))
		{
			STARTCHEST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			STARTCHEST_DESCRIPTIONS.Add(GunfigHelpers.White("No starting chest."));
			STARTCHEST_OPTIONS.Add(GunfigHelpers.WithColor("Starter Chest", val));
			STARTCHEST_DESCRIPTIONS.Add(GunfigHelpers.White("Start with a D rank chest."));
			if (GameStatsManager.Instance.GetFlag((GungeonFlags)18001) || GameStatsManager.Instance.GetFlag((GungeonFlags)18003) || GameStatsManager.Instance.GetFlag((GungeonFlags)18002) || GameStatsManager.Instance.GetFlag((GungeonFlags)18004) || GameStatsManager.Instance.GetFlag((GungeonFlags)100000) || GameStatsManager.Instance.GetFlag((GungeonFlags)18005))
			{
				STARTCHEST_OPTIONS.Add(GunfigHelpers.WithColor("Evolved Chest", val14));
				STARTCHEST_DESCRIPTIONS.Add(GunfigHelpers.White("Start with a C rank chest."));
				if (GameStatsManager.Instance.GetFlag((GungeonFlags)19000))
				{
					STARTCHEST_OPTIONS.Add(GunfigHelpers.WithColor("Final Chest", val15));
					STARTCHEST_DESCRIPTIONS.Add(GunfigHelpers.WithColor("Start with a B rank chest.", val15));
				}
				else
				{
					STARTCHEST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
					STARTCHEST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Lich."));
				}
			}
			else
			{
				STARTCHEST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
				STARTCHEST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill any vanilla Past."));
			}
		}
		else
		{
			STARTCHEST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			STARTCHEST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Dragun."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)57503))
		{
			MULTI_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			MULTI_DESCRIPTIONS.Add(GunfigHelpers.White("Your initial chest drops one item."));
			MULTI_OPTIONS.Add(GunfigHelpers.Magenta("Rainbow Blessing"));
			MULTI_DESCRIPTIONS.Add(GunfigHelpers.Magenta("Your initial chest has multiple options."));
		}
		else
		{
			MULTI_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			MULTI_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete a Rainbow Run."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)35101))
		{
			MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling A/S items after the first are 80%/95%/98.6%/99%"));
			MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence I", val4));
			MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 70%/95%/98.6%/99%"));
			if (GameStatsManager.Instance.GetFlag((GungeonFlags)35102))
			{
				MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence II Dawn of Souls", val5));
				MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 60%/95%/98.6%/99%"));
				if (GameStatsManager.Instance.GetFlag((GungeonFlags)35103))
				{
					MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence III 3D", val6));
					MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 60%/80%/98.6%/99%"));
					if (GameStatsManager.Instance.GetFlag((GungeonFlags)35104))
					{
						MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.Blue("Magnificence IV The After Years"));
						MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 60%/80%/90%/99%"));
						if (GameStatsManager.Instance.GetFlag((GungeonFlags)35105))
						{
							MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence V Advance", val7));
							MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 50%/80%/90%/99%"));
							if (GameStatsManager.Instance.GetFlag((GungeonFlags)35106))
							{
								MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.Red("Magnificence VI Pixel Remaster"));
								MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 50%/70%/90%/99%"));
								if (GameStatsManager.Instance.GetFlag((GungeonFlags)35107))
								{
									MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence VII Remake", val3));
									MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 50%/70%/80%/99%"));
									if (GameStatsManager.Instance.GetFlag((GungeonFlags)35108))
									{
										MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence VIII Remastered", val8));
										MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 50%/70%/80%/90%"));
										if (GameStatsManager.Instance.GetFlag((GungeonFlags)35109))
										{
											MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.Yellow("Magnificence IX Steam Version"));
											MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 40%/70%/80%/90%"));
											if (GameStatsManager.Instance.GetFlag((GungeonFlags)35110))
											{
												MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence X HD", val9));
												MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 40%/60%/80%/90%"));
												if (GameStatsManager.Instance.GetFlag((GungeonFlags)35111))
												{
													MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence XI Online", val4));
													MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 40%/60%/70%/90%"));
													if (GameStatsManager.Instance.GetFlag((GungeonFlags)35112))
													{
														MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence XII The Zodiac Age", val2));
														MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 40%/60%/70%/80%"));
														if (GameStatsManager.Instance.GetFlag((GungeonFlags)35113))
														{
															MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence XIII Lightning Returns", val10));
															MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 40%/50%/70%/80%"));
															if (GameStatsManager.Instance.GetFlag((GungeonFlags)35114))
															{
																MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence XIV A Realm Reborn", val11));
																MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.White("Chances of rerolling after the first are 40%/50%/60%/80%"));
																if (GameStatsManager.Instance.GetFlag((GungeonFlags)35500))
																{
																	MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.WithColor("Magnificence XV Royal Edition", val12));
																	MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.WithColor("Chances of rerolling after the first are 30%/40%/50%/70%", val12));
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			if (!GameStatsManager.Instance.GetFlag((GungeonFlags)35500))
			{
				MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
				if (GameStatsManager.Instance.GetFlag((GungeonFlags)35114))
				{
					MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete the final hunt."));
				}
				else
				{
					MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete the next hunt."));
				}
			}
		}
		else
		{
			MAGNIFICENCE_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			MAGNIFICENCE_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete a hunt."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)55515))
		{
			SYNERGYCHEST_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			SYNERGYCHEST_DESCRIPTIONS.Add(GunfigHelpers.White("Synergy chests have about a 50% chance of success."));
			SYNERGYCHEST_OPTIONS.Add(GunfigHelpers.Green("Blessed Synergy"));
			SYNERGYCHEST_DESCRIPTIONS.Add(GunfigHelpers.Green("Synergy chests have an 80% chance of success."));
		}
		else
		{
			SYNERGYCHEST_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			SYNERGYCHEST_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete a Blessed Run."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)30100))
		{
			SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.White("First and second synergies receive boosted find rates."));
			SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.Yellow("AMPLIFIED"));
			SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.White("Second synergy rate is raised further."));
			if (GameStatsManager.Instance.GetFlag((GungeonFlags)30200))
			{
				SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.Red("Cadence"));
				SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.White("Synergy Factor is doubled along with previous tiers."));
				if (GameStatsManager.Instance.GetFlag((GungeonFlags)30300))
				{
					SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.WithColor("SYNCHRONY", val6));
					SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.White("Third synergy also receives a boosted rate."));
					if (GameStatsManager.Instance.GetFlag((GungeonFlags)30400))
					{
						SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.Cyan("Hatsune Miku"));
						SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.Cyan("Synergy Factor is tripled along with previous tiers."));
					}
					else
					{
						SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
						SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.Gray("Build the last Elevator Shortcut."));
					}
				}
				else
				{
					SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
					SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.Gray("Build the next Elevator Shortcut."));
				}
			}
			else
			{
				SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
				SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.Gray("Build the next Elevator Shortcut."));
			}
		}
		else
		{
			SYNERGYFACTOR_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			SYNERGYFACTOR_DESCRIPTIONS.Add(GunfigHelpers.Gray("Build an Elevator Shortcut."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)57003))
		{
			SYNERGYFUSE_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			SYNERGYFUSE_DESCRIPTIONS.Add(GunfigHelpers.White("Natural synergy chests always have a fuse."));
			SYNERGYFUSE_OPTIONS.Add(GunfigHelpers.WithColor("Faster than Fuses", val));
			SYNERGYFUSE_DESCRIPTIONS.Add(GunfigHelpers.White("Synergy chests have a regular fuse rate. Carries over to next unlock tier."));
			if (GameStatsManager.Instance.GetPlayerStatValue((TrackedStats)25) >= 500f || GameStatsManager.Instance.GetFlag((GungeonFlags)57010))
			{
				SYNERGYFUSE_OPTIONS.Add(GunfigHelpers.Green("Better than Bonus Stages"));
				SYNERGYFUSE_DESCRIPTIONS.Add(GunfigHelpers.Yellow("Super Tonic is unlocked."));
			}
			else
			{
				SYNERGYFUSE_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
				SYNERGYFUSE_DESCRIPTIONS.Add(GunfigHelpers.Gray("Have at least 500 Hegemony and do a double dodge roll (if you feel like it)."));
			}
		}
		else
		{
			SYNERGYFUSE_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			SYNERGYFUSE_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete a Turbo Run."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)19001))
		{
			SYNERGYCHESTSPAWN_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			SYNERGYCHESTSPAWN_DESCRIPTIONS.Add(GunfigHelpers.White("Synergy chests have a 5% chance to spawn."));
			SYNERGYCHESTSPAWN_OPTIONS.Add(GunfigHelpers.Magenta("Synergized Synergy"));
			SYNERGYCHESTSPAWN_DESCRIPTIONS.Add(GunfigHelpers.Magenta("Synergy chests have an 10% chance to spawn."));
		}
		else
		{
			SYNERGYCHESTSPAWN_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			SYNERGYCHESTSPAWN_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Advanced Dragun."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)19700))
		{
			CAP_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			CAP_DESCRIPTIONS.Add(GunfigHelpers.White("Normal Boss DPS Cap."));
			CAP_OPTIONS.Add(GunfigHelpers.Red("Bosses Busted"));
			CAP_DESCRIPTIONS.Add(GunfigHelpers.Red("Boss DPS Cap increased by 25%"));
		}
		else
		{
			CAP_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			CAP_DESCRIPTIONS.Add(GunfigHelpers.Gray("Complete a Boss Rush."));
		}
		if (GameStatsManager.Instance.GetFlag((GungeonFlags)20121))
		{
			RAT_OPTIONS.Add(GunfigHelpers.White("Vanilla"));
			RAT_DESCRIPTIONS.Add(GunfigHelpers.White("The Resourceful Rat will steal unattended items."));
			RAT_OPTIONS.Add(GunfigHelpers.WithColor("RATDIE", val3));
			RAT_DESCRIPTIONS.Add(GunfigHelpers.WithColor("The Resourceful Rat will leave your items alone.", val3));
		}
		else
		{
			RAT_OPTIONS.Add(GunfigHelpers.Gray("Locked"));
			RAT_DESCRIPTIONS.Add(GunfigHelpers.Gray("Kill the Resourceful Rat."));
		}
	}

	internal static void Init()
	{
		_Gunfig = Gunfig.Get(GunfigHelpers.Cyan("MetaLimits"));
		BuildOptions();
		_Gunfig.AddScrollBox("The Pilot's Affinity", PILOTPAST_OPTIONS, (string)null, (Action<string, string>)null, PILOTPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Marine's Affinity", MARINEPAST_OPTIONS, (string)null, (Action<string, string>)null, MARINEPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Convict's Affinity", CONVICTPAST_OPTIONS, (string)null, (Action<string, string>)null, CONVICTPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Hunter's Affinity", HUNTERPAST_OPTIONS, (string)null, (Action<string, string>)null, HUNTERPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Bullet's Affinity", BULLETPAST_OPTIONS, (string)null, (Action<string, string>)null, BULLETPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Robot's Affinity", ROBOTPAST_OPTIONS, (string)null, (Action<string, string>)null, ROBOTPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Paradox's Affinity", PARADOXPAST_OPTIONS, (string)null, (Action<string, string>)null, PARADOXPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Slinger's Affinity", SLINGERPAST_OPTIONS, (string)null, (Action<string, string>)null, SLINGERPAST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Cultist's Affinity", COOPCHEST_OPTIONS, (string)null, (Action<string, string>)null, COOPCHEST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Gungeon's Affinity", STARTCHEST_OPTIONS, (string)null, (Action<string, string>)null, STARTCHEST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("Bowler's Affinity", MULTI_OPTIONS, (string)null, (Action<string, string>)null, MULTI_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("Frifle and Mauser's Affinity", MAGNIFICENCE_OPTIONS, (string)null, (Action<string, string>)null, MAGNIFICENCE_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("Tinker's Affinity", SYNERGYFACTOR_OPTIONS, (string)null, (Action<string, string>)null, SYNERGYFACTOR_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("Sorceress's Affinity", SYNERGYCHEST_OPTIONS, (string)null, (Action<string, string>)null, SYNERGYCHEST_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("Tonic's Affinity", SYNERGYFUSE_OPTIONS, (string)null, (Action<string, string>)null, SYNERGYFUSE_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("Advanced Dragun's Affinity", SYNERGYCHESTSPAWN_OPTIONS, (string)null, (Action<string, string>)null, SYNERGYCHESTSPAWN_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("The Bosses' Affinity", CAP_OPTIONS, (string)null, (Action<string, string>)null, CAP_DESCRIPTIONS, (Update)1);
		_Gunfig.AddScrollBox("Resourceful Rat's Affinity", RAT_OPTIONS, (string)null, (Action<string, string>)null, RAT_DESCRIPTIONS, (Update)1);
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("bassforte.etg.metalimits", "MetaLimits", "1.0.6")]
public class MetaLimitsModule : BaseUnityPlugin
{
	[HarmonyPatch(typeof(SharedDungeonSettings), "RandomShouldBecomeMimic")]
	private class SharedDungeonSettingsPatch
	{
		[HarmonyILManipulator]
		private static void RandomShouldBecomeMimicIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchMul(instr),
				(Instruction instr) => ILPatternMatchingExt.MatchAdd(instr)
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("MimicChestRate"));
			}
		}
	}

	[HarmonyPatch(typeof(LootEngine), "DoAmmoClipCheck", new Type[] { typeof(float) })]
	private class DoAmmoClipCheckPatch
	{
		[HarmonyILManipulator]
		private static void GenerateContentsIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0)
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("AmmoMultValue"));
			}
		}
	}

	[HarmonyPatch(typeof(AIActor), "HandleLootPinata")]
	private class HandleLootPinataPatch
	{
		[HarmonyILManipulator]
		private static void LootPinataIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 1)
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("BossHege"));
			}
		}
	}

	[HarmonyPatch(typeof(Dungeon), "InformRoomCleared")]
	private class InformRoomClearedPatch
	{
		private static void Postfix()
		{
			if (MetaConfig._Gunfig.Value("The Hunter's Affinity") == "Refreshed Rewards")
			{
				PlayerController primaryPlayer = GameManager.Instance.PrimaryPlayer;
				primaryPlayer.AdditionalChestSpawnChance += 0.02f;
			}
		}
	}

	[HarmonyPatch(typeof(Chest), "Initialize")]
	private class InitializePatch
	{
		[HarmonyILManipulator]
		private static void InitializeIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchLdcR4(instr, 0.001f)
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("GlitchChestRate"));
			}
		}
	}

	[HarmonyPatch(typeof(FoyerCharacterSelectFlag), "OnSelectedCharacterCallback")]
	private class OnSelectedCharacterCallbackPatch
	{
		[HarmonyILManipulator]
		private static void GenerateContentsIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchLdcR4(instr, -5f)
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("CharPayUpdate"));
			}
		}
	}

	[HarmonyPatch(typeof(FoyerCharacterSelectFlag), "OnSelectedCharacterCallback")]
	private class OnSelectedCharacterCallback2Patch
	{
		[HarmonyILManipulator]
		private static void GenerateContentsIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchLdcR4(instr, -7f)
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("CharPayUpdate"));
			}
		}
	}

	[HarmonyPatch(typeof(Dungeon), "FloorReached")]
	private class FloorReachedPatch
	{
		private static void Postfix()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Invalid comparison between Unknown and I4
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			GameManager instance = GameManager.Instance;
			if ((int)instance.CurrentLevelOverrideState != 5 && (int)instance.CurrentLevelOverrideState != 1 && (int)instance.CurrentLevelOverrideState != 2 && !GameStatsManager.Instance.rainbowRunToggled && startChest)
			{
				if (GameStatsManager.Instance.GetSessionStatValue((TrackedStats)23) < 0.1f)
				{
					SpawnInitialChest();
				}
				if (GameStatsManager.Instance.GetSessionStatValue((TrackedStats)23) < 0.1f && (int)instance.CurrentGameType == 1 && MetaConfig._Gunfig.Value("The Cultist's Affinity") == "The Power of Friendship")
				{
					SpawnInitialChest();
				}
			}
			if (GameStatsManager.Instance.IsRainbowRun && (int)instance.CurrentGameType == 1 && MetaConfig._Gunfig.Value("The Cultist's Affinity") == "The Power of Friendship")
			{
				SpawnCoopRainbow();
			}
		}
	}

	[HarmonyPatch(typeof(MagnificenceConstants), "ModifyQualityByMagnificence")]
	private class MagnificenceConstantsPatch
	{
		[HarmonyILManipulator]
		private static void ModifyQualityByMagnificenceIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt<Mathf>(instr, "Clamp01")
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("AssignMagnificenceValue"));
			}
		}
	}

	[HarmonyPatch(typeof(Chest), "SpewContentsOntoGround")]
	public class SpewContentsOntoGroundPatch
	{
		private static bool Prefix(Chest __instance, List<Transform> spawnTransforms)
		{
			//IL_0036: 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)
			if (__instance.IsRainbowChest && (GameStatsManager.Instance.IsRainbowRun || MetaConfig._Gunfig.Value("Bowler's Affinity") == "Rainbow Blessing") && Vector3Extensions.GetAbsoluteRoom(((BraveBehaviour)__instance).transform.position) == GameManager.Instance.Dungeon.data.Entrance)
			{
				List<DebrisObject> list = new List<DebrisObject>();
				for (int i = 0; i < __instance.contents.Count; i++)
				{
					List<GameObject> list2 = new List<GameObject>();
					list2.Add(((Component)__instance.contents[i]).gameObject);
					List<DebrisObject> list3 = LootEngine.SpewLoot(list2, spawnTransforms[i].position);
					list.AddRange(list3);
					for (int j = 0; j < list3.Count; j++)
					{
						if (Object.op_Implicit((Object)(object)list3[j]))
						{
							list3[j].PreventFallingInPits = true;
						}
						if (!((Object)(object)((Component)list3[j]).GetComponent<Gun>() != (Object)null) && !((Object)(object)((Component)list3[j]).GetComponent<CurrencyPickup>() != (Object)null) && (Object)(object)((BraveBehaviour)list3[j]).specRigidbody != (Object)null)
						{
							((BraveBehaviour)list3[j]).specRigidbody.CollideWithOthers = false;
							DebrisObject val = list3[j];
							val.OnTouchedGround = (Action<DebrisObject>)Delegate.Combine(val.OnTouchedGround, new Action<DebrisObject>(__instance.BecomeViableItem));
						}
					}
				}
				((MonoBehaviour)GameManager.Instance.Dungeon).StartCoroutine(__instance.HandleRainbowRunLootProcessing(list));
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Chest), "GenerateContents")]
	private class GenerateContentsPatch
	{
		[HarmonyILManipulator]
		private static void GenerateContentsIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchCallOrCallvirt<Mathf>(instr, "Clamp")
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("AssignSynergyChestValue"));
			}
		}
	}

	[HarmonyPatch(typeof(SynergyFactorConstants), "GetSynergyFactor")]
	private class SynergyFactorPatch
	{
		[HarmonyILManipulator]
		private static void ModifyGetSynergyFactor(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, 3)
			}))
			{
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("MultSynergyFactor"));
			}
		}
	}

	[HarmonyPatch(typeof(Chest), "RoomEntered")]
	private class RoomEnteredPatch
	{
		[HarmonyILManipulator]
		private static void GenerateContentsIL(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0041: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction instr) => ILPatternMatchingExt.MatchLdcR4(instr, 1f)
			}))
			{
				val.Emit(OpCodes.Ldloc_0);
				val.Emit(OpCodes.Call, (MethodBase)typeof(MetaLimitsModule).GetMethod("SynergyFuseValue"));
				int index = val.Index;
				val.Index = index + 1;
				val.Emit(OpCodes.Pop);
			}
		}
	}

	[HarmonyPatch(typeof(FloorRewardData), "GetTargetQualityFromChances")]
	private class GetTargetQualityFromChancesPatch
	{
		private static void Postfix(FloorRewardData __instance)
		{
			if (MetaConfig._Gunfig.Value("Advanced Dragun's Affinity") == "Synergized Synergy")
			{
				GameManager.Instance.RewardManager.GlobalSynerchestChance = 0.1f;
			}
			__instance.S_Shop_Chance = 1000f;
			currMagnificence = __instance.DetermineCurrentMagnificence(false);
		}
	}

	[HarmonyPatch(typeof(HealthHaver), "Start")]
	private class HealthHaverStartPatch
	{
		private static void Postfix(HealthHaver __instance)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			float num = 1f;
			if (MetaConfig._Gunfig.Value("The Bosses' Affinity") == "Bosses Busted")
			{
				num = 1.25f;
			}
			GameLevelDefinition lastLoadedLevelDefinition = GameManager.Instance.GetLastLoadedLevelDefinition();
			if (__instance.IsBoss && !__instance.IsSubboss && lastLoadedLevelDefinition.bossDpsCap > 0f)
			{
				float num2 = 1f;
				if ((int)GameManager.Instance.CurrentGameType == 1)
				{
					num2 = (GameManager.Instance.COOP_ENEMY_HEALTH_MULTIPLIER + 2f) / 2f;
				}
				__instance.m_bossDpsCap = lastLoadedLevelDefinition.bossDpsCap * num2 * num;
			}
		}
	}

	[HarmonyPatch(typeof(PickupObject), "ShouldBeTakenByRat")]
	private class ShouldBeTakenByRatPatch
	{
		private static bool Prefix(ref bool __result)
		{
			if (MetaConfig._Gunfig.Value("Resourceful Rat's Affinity") == "RATDIE")
			{
				__result = false;
				return false;
			}
			return true;
		}
	}

	public const string GUID = "bassforte.etg.metalimits";

	public const string NAME = "MetaLimits";

	public const string VERSION = "1.0.6";

	public const string TEXT_COLOR = "#00FFFF";

	internal static float currMagnificence = 0f;

	internal static bool configStarted = false;

	internal static bool curseCure1 = true;

	internal static bool curseCure2 = true;

	internal static bool CostsFlag = true;

	public static bool startChest = true;

	public void Start()
	{
		ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
	}

	public void GMStart(GameManager g)
	{
		Log("MetaLimits v1.0.6 started successfully.", "#00FFFF");
		MetaConfig.Init();
		configStarted = true;
		CustomActions.OnRunStart = (Action<PlayerController, PlayerController, GameMode>)Delegate.Combine(CustomActions.OnRunStart, new Action<PlayerController, PlayerController, GameMode>(initialTonic));
		CustomActions.OnRunStart = (Action<PlayerController, PlayerController, GameMode>)Delegate.Combine(CustomActions.OnRunStart, new Action<PlayerController, PlayerController, GameMode>(initialCoolness));
		CustomActions.OnRunStart = (Action<PlayerController, PlayerController, GameMode>)Delegate.Combine(CustomActions.OnRunStart, new Action<PlayerController, PlayerController, GameMode>(InitialArmor));
		CustomActions.OnRunStart = (Action<PlayerController, PlayerController, GameMode>)Delegate.Combine(CustomActions.OnRunStart, new Action<PlayerController, PlayerController, GameMode>(InitialCurseArmor));
		CustomActions.OnAnyPlayerCollectedHealth = (Action<HealthPickup, PlayerController>)Delegate.Combine(CustomActions.OnAnyPlayerCollectedHealth, new Action<HealthPickup, PlayerController>(CureCurse));
	}

	internal void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("bassforte.etg.metalimits");
		val.PatchAll();
	}

	public static float MimicChestRate(float curr)
	{
		if (MetaConfig._Gunfig.Value("The Pilot's Affinity") == "More Mimics")
		{
			return curr += 0.1f;
		}
		return curr;
	}

	public static float AmmoMultValue(float curr)
	{
		if (MetaConfig._Gunfig.Value("The Marine's Affinity") == "Ample Ammo")
		{
			curr *= 1.25f;
		}
		return curr;
	}

	public static int BossHege(int curr)
	{
		if (MetaConfig._Gunfig.Value("The Convict's Affinity") == "Hearty Hegemony")
		{
			curr++;
		}
		return curr;
	}

	private static void InitialCurseArmor(PlayerController arg1, PlayerController arg2, GameMode arg3)
	{
		curseCure1 = true;
		curseCure2 = true;
	}

	private static void CureCurse(HealthPickup arg1, PlayerController player)
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		if (MetaConfig._Gunfig.Value("The Bullet's Affinity") == "Cure Curse" && player.stats.GetStatValue((StatType)14) >= 1f)
		{
			if (curseCure1 && (Object)(object)player == (Object)(object)GameManager.Instance.PrimaryPlayer)
			{
				curseCure1 = false;
				StatModifier val = new StatModifier();
				val.amount = -1f;
				val.modifyType = (ModifyMethod)0;
				val.statToBoost = (StatType)14;
				player.ownerlessStatModifiers.Add(val);
				player.stats.RecalculateStats(player, false, false);
			}
			if (curseCure2 && (Object)(object)player == (Object)(object)GameManager.Instance.SecondaryPlayer)
			{
				curseCure2 = false;
				StatModifier val2 = new StatModifier();
				val2.amount = -1f;
				val2.modifyType = (ModifyMethod)0;
				val2.statToBoost = (StatType)14;
				player.ownerlessStatModifiers.Add(val2);
				player.stats.RecalculateStats(player, false, false);
			}
		}
	}

	private static void initialCoolness(PlayerController arg1, PlayerController arg2, GameMode arg3)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Invalid comparison between Unknown and I4
		if (MetaConfig._Gunfig.Value("The Bullet's Affinity") == "Cause Coolness")
		{
			StatModifier val = new StatModifier();
			val.amount = 1f;
			val.modifyType = (ModifyMethod)0;
			val.statToBoost = (StatType)4;
			GameManager.Instance.PrimaryPlayer.ownerlessStatModifiers.Add(val);
			GameManager.Instance.PrimaryPlayer.stats.RecalculateStats(GameManager.Instance.PrimaryPlayer, false, false);
			if ((int)GameManager.Instance.CurrentGameType == 1)
			{
				GameManager.Instance.SecondaryPlayer.ownerlessStatModifiers.Add(val);
				GameManager.Instance.SecondaryPlayer.stats.RecalculateStats(GameManager.Instance.SecondaryPlayer, false, false);
			}
		}
	}

	private static void InitialArmor(PlayerController arg1, PlayerController arg2, GameMode arg3)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Invalid comparison between Unknown and I4
		if (MetaConfig._Gunfig.Value("The Robot's Affinity") == "Additional Armor")
		{
			HealthHaver healthHaver = ((BraveBehaviour)GameManager.Instance.PrimaryPlayer).healthHaver;
			healthHaver.Armor += 1f;
			if ((int)GameManager.Instance.CurrentGameType == 1)
			{
				HealthHaver healthHaver2 = ((BraveBehaviour)GameManager.Instance.SecondaryPlayer).healthHaver;
				healthHaver2.Armor += 1f;
			}
		}
	}

	public static float GlitchChestRate(float curr)
	{
		if (MetaConfig._Gunfig.Value("The Paradox's Affinity") == "Gather Glitches")
		{
			return 0.006f;
		}
		return curr;
	}

	public static float CharPayUpdate(float curr)
	{
		if (MetaConfig._Gunfig.Value("The Slinger's Affinity") == "Fast Fingers")
		{
			if (curr == -5f)
			{
				return -2f;
			}
			if (curr == -7f)
			{
				return -3f;
			}
		}
		return curr;
	}

	public static void initialTonic(PlayerController arg1, PlayerController arg2, GameMode arg3)
	{
		if (MetaConfig._Gunfig.Value("Tonic's Affinity") == "Better than Bonus Stages")
		{
			GameStatsManager.Instance.SetFlag((GungeonFlags)57010, true);
		}
	}

	private static void SpawnCoopRainbow()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		bool flag = default(bool);
		Chest val = Chest.Spawn(GameManager.Instance.RewardManager.A_Chest, GameManager.Instance.Dungeon.data.Entrance.GetCenteredVisibleClearSpot(2, 2, ref flag, false));
		val.m_isMimic = false;
		val.IsRainbowChest = true;
		val.BecomeRainbowChest();
	}

	public static float AssignMagnificenceValue(float curr)
	{
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Vanilla" || MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Locked")
		{
			return curr;
		}
		float num = 0.8f;
		float num2 = 0.95f;
		float num3 = 0.986f;
		float num4 = 0.99f;
		int num5 = 0;
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence I")
		{
			num5 = 1;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence II Dawn of Souls")
		{
			num5 = 2;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence III 3D")
		{
			num5 = 3;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence IV The After Years")
		{
			num5 = 4;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence V Advance")
		{
			num5 = 5;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence VI Pixel Remaster")
		{
			num5 = 6;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence VII Remake")
		{
			num5 = 7;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence VIII Remastered")
		{
			num5 = 8;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence IX Steam Version")
		{
			num5 = 9;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence X HD")
		{
			num5 = 10;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence XI Online")
		{
			num5 = 11;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence XII The Zodiac Age")
		{
			num5 = 12;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence XIII Lightning Returns")
		{
			num5 = 13;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence XIV A Realm Reborn")
		{
			num5 = 14;
		}
		if (MetaConfig._Gunfig.Value("Frifle and Mauser's Affinity") == "Magnificence XV Royal Edition")
		{
			num5 = 15;
		}
		if (num5 >= 1)
		{
			num = 0.7f;
		}
		if (num5 >= 2)
		{
			num = 0.6f;
		}
		if (num5 >= 3)
		{
			num2 = 0.8f;
		}
		if (num5 >= 4)
		{
			num3 = 0.9f;
		}
		if (num5 >= 5)
		{
			num = 0.5f;
		}
		if (num5 >= 6)
		{
			num2 = 0.7f;
		}
		if (num5 >= 7)
		{
			num3 = 0.8f;
		}
		if (num5 >= 8)
		{
			num4 = 0.9f;
		}
		if (num5 >= 9)
		{
			num = 0.4f;
		}
		if (num5 >= 10)
		{
			num2 = 0.6f;
		}
		if (num5 >= 11)
		{
			num3 = 0.7f;
		}
		if (num5 >= 12)
		{
			num4 = 0.8f;
		}
		if (num5 >= 13)
		{
			num2 = 0.5f;
		}
		if (num5 >= 14)
		{
			num3 = 0.6f;
		}
		if (num5 >= 15)
		{
			num = 0.3f;
			num2 = 0.4f;
			num3 = 0.5f;
			num4 = 0.7f;
		}
		if (currMagnificence == 1f)
		{
			return 1f - num;
		}
		if (currMagnificence == 2f)
		{
			return 1f - num2;
		}
		if (currMagnificence == 3f)
		{
			return 1f - num3;
		}
		if (currMagnificence == 4f)
		{
			return 1f - num4;
		}
		return 1f - (1f - num4) / 2f;
	}

	private static void SpawnInitialChest()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		Chest val = null;
		bool flag = default(bool);
		if (MetaConfig._Gunfig.Value("The Gungeon's Affinity") == "Starter Chest")
		{
			val = Chest.Spawn(GameManager.Instance.RewardManager.D_Chest, GameManager.Instance.Dungeon.data.Entrance.GetCenteredVisibleClearSpot(2, 2, ref flag, false));
		}
		if (MetaConfig._Gunfig.Value("The Gungeon's Affinity") == "Evolved Chest")
		{
			val = Chest.Spawn(GameManager.Instance.RewardManager.C_Chest, GameManager.Instance.Dungeon.data.Entrance.GetCenteredVisibleClearSpot(2, 2, ref flag, false));
		}
		if (MetaConfig._Gunfig.Value("The Gungeon's Affinity") == "Final Chest")
		{
			val = Chest.Spawn(GameManager.Instance.RewardManager.B_Chest, GameManager.Instance.Dungeon.data.Entrance.GetCenteredVisibleClearSpot(2, 2, ref flag, false));
		}
		if ((Object)(object)val != (Object)null)
		{
			val.lootTable.Common_Chance = 0f;
			val.m_isMimic = false;
			val.IsLocked = false;
			if (MetaConfig._Gunfig.Value("Bowler's Affinity") == "Rainbow Blessing")
			{
				BecomeBlessedChest(val);
			}
		}
	}

	public static void BecomeBlessedChest(Chest chest)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Expected O, but got Unknown
		chest.IsRainbowChest = true;
		chest.lootTable.canDropMultipleItems = true;
		chest.lootTable.multipleItemDropChances = new WeightedIntCollection();
		chest.lootTable.multipleItemDropChances.elements = (WeightedInt[])(object)new WeightedInt[1];
		chest.lootTable.overrideItemLootTables = new List<GenericLootTable>();
		chest.lootTable.lootTable = GameManager.Instance.RewardManager.GunsLootTable;
		chest.lootTable.overrideItemLootTables.Add(GameManager.Instance.RewardManager.GunsLootTable);
		chest.lootTable.overrideItemLootTables.Add(GameManager.Instance.RewardManager.ItemsLootTable);
		chest.lootTable.overrideItemLootTables.Add(GameManager.Instance.RewardManager.GunsLootTable);
		WeightedInt val = new WeightedInt();
		val.weight = 1f;
		val.additionalPrerequisites = (DungeonPrerequisite[])(object)new DungeonPrerequisite[0];
		chest.lootTable.multipleItemDropChances.elements[0] = val;
		chest.lootTable.onlyOneGunCanDrop = false;
		((BraveBehaviour)chest).sprite.usesOverrideMaterial = true;
		tk2dSpriteAnimationClip clipByName = ((BraveBehaviour)chest).spriteAnimator.GetClipByName(chest.spawnAnimName);
		((BraveBehaviour)chest).sprite.SetSprite(clipByName.frames[clipByName.frames.Length - 1].spriteId);
		((BraveBehaviour)((BraveBehaviour)chest).sprite).renderer.material.shader = ShaderCache.Acquire("Brave/Internal/RainbowChestShader");
		if (chest.spawnAnimName.StartsWith("wood_"))
		{
			((BraveBehaviour)((BraveBehaviour)chest).sprite).renderer.material.SetFloat("_HueTestValue", -4f);
			val.value = 3;
		}
		if (chest.spawnAnimName.StartsWith("silver_"))
		{
			((BraveBehaviour)((BraveBehaviour)chest).sprite).renderer.material.SetFloat("_HueTestValue", -0.2f);
			chest.lootTable.C_Chance = 0.75f;
			chest.lootTable.D_Chance = 0.25f;
			val.value = 4;
			chest.lootTable.overrideItemLootTables.Add(GameManager.Instance.RewardManager.ItemsLootTable);
		}
		if (chest.spawnAnimName.StartsWith("green_"))
		{
			((BraveBehaviour)((BraveBehaviour)chest).sprite).renderer.material.SetFloat("_HueTestValue", -0.6f);
			chest.lootTable.B_Chance = 0.6f;
			chest.lootTable.C_Chance = 0.2f;
			chest.lootTable.D_Chance = 0.2f;
			val.value = 5;
			chest.lootTable.overrideItemLootTables.Add(GameManager.Instance.RewardManager.GunsLootTable);
		}
	}

	public static float AssignSynergyChestValue(float curr)
	{
		if (MetaConfig._Gunfig.Value("Sorceress's Affinity") == "Blessed Synergy")
		{
			return 0.2f;
		}
		return curr;
	}

	public static float MultSynergyFactor(float curr)
	{
		if (MetaConfig._Gunfig.Value("Tinker's Affinity") == "Vanilla")
		{
			return curr;
		}
		int numberOfSynergiesEncounteredThisRun = GameStatsManager.Instance.GetNumberOfSynergiesEncounteredThisRun();
		float num = 1f;
		curr -= 1f;
		int num2 = 0;
		if (MetaConfig._Gunfig.Value("Tinker's Affinity") == "Cadence")
		{
			num2 = 1;
		}
		if (MetaConfig._Gunfig.Value("Tinker's Affinity") == "SYNCHRONY")
		{
			num2 = 2;
		}
		if (MetaConfig._Gunfig.Value("Tinker's Affinity") == "Hatsune Miku")
		{
			num2 = 3;
		}
		if (numberOfSynergiesEncounteredThisRun == 1)
		{
			num = 5f;
		}
		if (numberOfSynergiesEncounteredThisRun == 2 && num2 > 1)
		{
			num = 15f;
		}
		if (num2 == 1 || num2 == 2)
		{
			num *= 2f;
		}
		if (num2 == 3)
		{
			num *= 3f;
		}
		return 1f + curr * num;
	}

	public static float SynergyFuseValue(float curr)
	{
		if (MetaConfig._Gunfig.Value("Tonic's Affinity") == "Cut Fuses" || MetaConfig._Gunfig.Value("Tonic's Affinity") == "Better than Bonus Stages")
		{
			return curr;
		}
		return 1f;
	}

	public static void Log(string text, string color = "#FFFFFF")
	{
		ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
	}
}