Decompiled source of PerformanceEnhancedMenu v1.1.0

BepInEx/plugins/PerformanceEnhancedMenu.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Math;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("PerformanceEnhancedMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0.2+52ece9c713dd7b6ad79e997d9ebf8881aa8e519f")]
[assembly: AssemblyProduct("PerformanceEnhancedMenu")]
[assembly: AssemblyTitle("PerformanceEnhancedMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
	public const string AssemblySemFileVer = "0.0.1.0";

	public const string AssemblySemVer = "0.0.1.0";

	public const string BranchName = "master";

	public const string BuildMetaData = "";

	public const string CommitDate = "2025-11-27";

	public const string CommitsSinceVersionSource = "3";

	public const string EscapedBranchName = "master";

	public const string FullBuildMetaData = "Branch.master.Sha.52ece9c713dd7b6ad79e997d9ebf8881aa8e519f";

	public const string FullSemVer = "0.0.1-3";

	public const string InformationalVersion = "0.0.1-3+Branch.master.Sha.52ece9c713dd7b6ad79e997d9ebf8881aa8e519f";

	public const string Major = "0";

	public const string MajorMinorPatch = "0.0.1";

	public const string Minor = "0";

	public const string Patch = "1";

	public const string PreReleaseLabel = "";

	public const string PreReleaseLabelWithDash = "";

	public const string PreReleaseNumber = "3";

	public const string PreReleaseTag = "3";

	public const string PreReleaseTagWithDash = "-3";

	public const string SemVer = "0.0.1-3";

	public const string Sha = "52ece9c713dd7b6ad79e997d9ebf8881aa8e519f";

	public const string ShortSha = "52ece9c";

	public const string UncommittedChanges = "9";

	public const string VersionSourceSha = "";

	public const string WeightedPreReleaseNumber = "55003";
}
namespace PerformanceEnhancedMenu
{
	public static class CellTouchingPatches
	{
		public static class GetConnectedPrismCountRecursivePatch
		{
			public static MethodBase TargetMethod()
			{
				return AccessTools.Method(AccessTools.TypeByName("UpgradeProperty_MiniCannon_Prism"), "GetConnectedPrismCountRecursive", new Type[2]
				{
					typeof(IUpgradable),
					typeof(UpgradeInstance)
				}, (Type[])null);
			}

			public static bool Prefix(IUpgradable prefab, UpgradeInstance upgrade, ref int __result)
			{
				if (StatCalcPatches.prismConnectedCounts.TryGetValue(upgrade.InstanceID, out var value))
				{
					__result = value;
					return false;
				}
				return true;
			}
		}

		public static class GetNumCellsTouchingThisPatch
		{
			public static MethodBase TargetMethod()
			{
				return AccessTools.Method(typeof(UpgradeProperty), "GetNumCellsTouchingThis", new Type[3]
				{
					typeof(IUpgradable),
					typeof(UpgradeInstance),
					StatCalcPatches.rarityFlagsType
				}, (Type[])null);
			}

			public static bool Prefix(IUpgradable prefab, UpgradeInstance upgrade, object rarities, ref int __result)
			{
				if (StatCalcPatches.rarityTouchingCounts.TryGetValue(upgrade.InstanceID, out (int, int, int, int) value))
				{
					if (rarities.Equals(StatCalcPatches.rarityFlagsStandard))
					{
						(__result, _, _, _) = value;
					}
					else if (rarities.Equals(StatCalcPatches.rarityFlagsRare))
					{
						__result = value.Item2;
					}
					else if (rarities.Equals(StatCalcPatches.rarityFlagsEpic))
					{
						__result = value.Item3;
					}
					else
					{
						if (!rarities.Equals(StatCalcPatches.rarityFlagsExotic))
						{
							return true;
						}
						__result = value.Item4;
					}
					return false;
				}
				return true;
			}
		}

		public static class GetNumRaritiesTouchingThisPatch
		{
			public static bool Prefix(IUpgradable prefab, UpgradeInstance upgrade, ref int __result)
			{
				if (StatCalcPatches.numRaritiesTouching.TryGetValue(upgrade.InstanceID, out var value))
				{
					__result = value;
					return false;
				}
				return true;
			}
		}

		public static class GetNumCellsTouchingThisNonRarityPatch
		{
			public static bool Prefix(IUpgradable prefab, UpgradeInstance upgrade, ref int __result)
			{
				if (StatCalcPatches.numCellsTouching.TryGetValue(upgrade.InstanceID, out var value))
				{
					__result = value;
					return false;
				}
				return true;
			}
		}

		public static class GetNumEmptyCellsTouchingThisPatch
		{
			public static bool Prefix(IUpgradable prefab, UpgradeInstance upgrade, ref int __result)
			{
				if (StatCalcPatches.numEmptyCellsTouching.TryGetValue(upgrade.InstanceID, out var value))
				{
					__result = value;
					return false;
				}
				return true;
			}
		}

		public static class GetNumUniqueUpgradesTouchingThisPatch
		{
			public static bool Prefix(IUpgradable prefab, UpgradeInstance upgrade, ref int __result)
			{
				if (StatCalcPatches.numUniqueUpgradesTouching.TryGetValue(upgrade.InstanceID, out var value))
				{
					__result = value;
					return false;
				}
				return true;
			}
		}
	}
	public static class GeneralPatches
	{
		public static class EquipUpgradePatch
		{
			public static MethodBase TargetMethod()
			{
				return AccessTools.Method(typeof(GearData), "EquipUpgrade", new Type[4]
				{
					typeof(UpgradeInstance),
					typeof(sbyte),
					typeof(sbyte),
					typeof(byte)
				}, (Type[])null);
			}

			public static void Postfix(GearData __instance, UpgradeInstance upgrade, sbyte x, sbyte y, byte rotation)
			{
				if (!StatCalcPatches.skipRecompute)
				{
					StatCalcPatches.ClearCaches();
					StatCalcPatches.RecomputeTotals(__instance);
				}
			}
		}

		public static class UnequipUpgradePatch
		{
			public static MethodBase TargetMethod()
			{
				return AccessTools.Method(typeof(GearData), "UnequipUpgrade", new Type[1] { typeof(UpgradeInstance) }, (Type[])null);
			}

			public static void Postfix(GearData __instance, UpgradeInstance upgrade)
			{
				StatCalcPatches.prismConnectedCounts.Remove(upgrade.InstanceID);
				StatCalcPatches.rarityTouchingCounts.Remove(upgrade.InstanceID);
				if (!StatCalcPatches.skipRecompute)
				{
					StatCalcPatches.ClearCaches();
					StatCalcPatches.RecomputeTotals(__instance);
				}
			}
		}

		public static class GetEquippedUpgradePatch
		{
			public static bool Prefix(IUpgradable gear, int x, int y, ref UpgradeInstance __result)
			{
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Expected O, but got Unknown
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				int iD = gear.Info.ID;
				if (!StatCalcPatches.upgradeGridCache.TryGetValue(iD, out var value))
				{
					int num = default(int);
					int num2 = default(int);
					gear.Info.GetUpgradeGridSize(ref num, ref num2);
					value = new UpgradeInstance[num, num2];
					GearData gearData = PlayerData.GetGearData(gear);
					foreach (object item in (IList)StatCalcPatches.equippedUpgradesField.GetValue(gearData))
					{
						UpgradeInstance val = (UpgradeInstance)StatCalcPatches.getUpgradeMethod.Invoke(item, null);
						if (val == null)
						{
							continue;
						}
						EquippedCellsEnumerator equippedCells = val.GetEquippedCells(gear);
						try
						{
							while (((EquippedCellsEnumerator)(ref equippedCells)).MoveNext())
							{
								value[((EquippedCellsEnumerator)(ref equippedCells)).X, ((EquippedCellsEnumerator)(ref equippedCells)).Y] = val;
							}
						}
						finally
						{
							((IDisposable)(EquippedCellsEnumerator)(ref equippedCells)).Dispose();
						}
					}
					StatCalcPatches.upgradeGridCache[iD] = value;
				}
				__result = value[x, y];
				return false;
			}
		}
	}
	public static class GlobblerPatches
	{
		public static class GlobblerRarityStatsPatch
		{
			public static Type Type = AccessTools.TypeByName("UpgradeProperty_Globbler_RarityStats");

			public static MethodBase TargetApply()
			{
				return AccessTools.Method(Type, "Apply", new Type[3]
				{
					typeof(IGear),
					typeof(UpgradeInstance),
					typeof(Random).MakeByRefType()
				}, (Type[])null);
			}

			public static bool ApplyPrefix(object __instance, IGear gear, UpgradeInstance upgrade, ref Random rand)
			{
				//IL_0027: 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)
				Globbler val = (Globbler)(object)((gear is Globbler) ? gear : null);
				if ((Object)(object)val == (Object)null)
				{
					return true;
				}
				Range<float> val2 = (Range<float>)AccessTools.Field(Type, "efficiency").GetValue(__instance);
				int num = (int)AccessTools.Field(Type, "globblometer").GetValue(__instance);
				float num2 = (float)AccessTools.Field(Type, "reloadSpeed").GetValue(__instance);
				float num3 = (float)AccessTools.Field(Type, "fireRate").GetValue(__instance);
				float num4 = (float)AccessTools.Field(Type, "damage").GetValue(__instance);
				float value = val2.GetValue(ref rand);
				int num5 = (StatCalcPatches.rarityTouchingCounts.ContainsKey(upgrade.InstanceID) ? StatCalcPatches.rarityTouchingCounts[upgrade.InstanceID].std : ((int)StatCalcPatches.getNumTouchingMethod.Invoke(null, new object[3]
				{
					gear,
					upgrade,
					StatCalcPatches.rarityFlagsStandard
				})));
				int num6 = (StatCalcPatches.rarityTouchingCounts.ContainsKey(upgrade.InstanceID) ? StatCalcPatches.rarityTouchingCounts[upgrade.InstanceID].rare : ((int)StatCalcPatches.getNumTouchingMethod.Invoke(null, new object[3]
				{
					gear,
					upgrade,
					StatCalcPatches.rarityFlagsRare
				})));
				int num7 = (StatCalcPatches.rarityTouchingCounts.ContainsKey(upgrade.InstanceID) ? StatCalcPatches.rarityTouchingCounts[upgrade.InstanceID].epic : ((int)StatCalcPatches.getNumTouchingMethod.Invoke(null, new object[3]
				{
					gear,
					upgrade,
					StatCalcPatches.rarityFlagsEpic
				})));
				int num8 = (StatCalcPatches.rarityTouchingCounts.ContainsKey(upgrade.InstanceID) ? StatCalcPatches.rarityTouchingCounts[upgrade.InstanceID].exo : ((int)StatCalcPatches.getNumTouchingMethod.Invoke(null, new object[3]
				{
					gear,
					upgrade,
					StatCalcPatches.rarityFlagsExotic
				})));
				val.GlobblerData.globblometer += Mathf.CeilToInt((float)(num5 * num) * value);
				((Gun)val).GunData.reloadDuration *= 1f / (1f + (float)num6 * num2 * value);
				((Gun)val).GunData.fireInterval *= 1f / (1f + (float)num7 * num3 * value);
				((Gun)val).GunData.damage *= 1f + (float)num8 * num4 * value;
				StatCalcPatches.rarityTouchingCounts[upgrade.InstanceID] = (num5, num6, num7, num8);
				return false;
			}

			public static MethodBase TargetModifyProperties()
			{
				Type type = typeof(string).MakeByRefType();
				Type type2 = AccessTools.TypeByName("Pigeon.Math.Random");
				return AccessTools.Method(Type, "ModifyProperties", new Type[4]
				{
					type,
					type2,
					typeof(IUpgradable),
					typeof(UpgradeInstance)
				}, (Type[])null);
			}

			public static bool ModifyPropertiesPrefix(object __instance, ref string properties, Random rand, IUpgradable gear, UpgradeInstance upgrade)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				if (upgrade == null)
				{
					return true;
				}
				if (StatCalcPatches.rarityTouchingCounts.TryGetValue(upgrade.InstanceID, out (int, int, int, int) value))
				{
					Range<float> val = (Range<float>)AccessTools.Field(Type, "efficiency").GetValue(__instance);
					int num = (int)AccessTools.Field(Type, "globblometer").GetValue(__instance);
					float num2 = (float)AccessTools.Field(Type, "reloadSpeed").GetValue(__instance);
					float num3 = (float)AccessTools.Field(Type, "fireRate").GetValue(__instance);
					float num4 = (float)AccessTools.Field(Type, "damage").GetValue(__instance);
					float value2 = val.GetValue(ref rand);
					string text = (string)StatCalcPatches.textBlocksGetStringMethod.Invoke(null, new object[1] { "globblometer" });
					float num5 = Mathf.CeilToInt((float)(value.Item1 * num) * value2);
					bool flag = value.Item1 > 0;
					object[] array = new object[5]
					{
						properties,
						text,
						num5,
						flag,
						StatCalcPatches.overrideAdd
					};
					StatCalcPatches.addDynamicPropMethod.Invoke(null, array);
					properties = (string)array[0];
					string text2 = (string)StatCalcPatches.textBlocksGetStringMethod.Invoke(null, new object[1] { "reloadspeed" });
					float num6 = 1f + (float)value.Item2 * num2 * value2;
					bool flag2 = value.Item2 > 0;
					object[] array2 = new object[5]
					{
						properties,
						text2,
						num6,
						flag2,
						StatCalcPatches.overrideMultiply
					};
					StatCalcPatches.addDynamicPropMethod.Invoke(null, array2);
					properties = (string)array2[0];
					string text3 = (string)StatCalcPatches.textBlocksGetStringMethod.Invoke(null, new object[1] { "firerate" });
					float num7 = 1f + (float)value.Item3 * num3 * value2;
					bool flag3 = value.Item3 > 0;
					object[] array3 = new object[5]
					{
						properties,
						text3,
						num7,
						flag3,
						StatCalcPatches.overrideMultiply
					};
					StatCalcPatches.addDynamicPropMethod.Invoke(null, array3);
					properties = (string)array3[0];
					string text4 = (string)StatCalcPatches.textBlocksGetStringMethod.Invoke(null, new object[1] { "damage" });
					float num8 = 1f + (float)value.Item4 * num4 * value2;
					bool flag4 = value.Item4 > 0;
					object[] array4 = new object[5]
					{
						properties,
						text4,
						num8,
						flag4,
						StatCalcPatches.overrideMultiply
					};
					StatCalcPatches.addDynamicPropMethod.Invoke(null, array4);
					properties = (string)array4[0];
					return false;
				}
				return true;
			}
		}

		public static class GlobblerGlobblometerSpeedPatch
		{
			public static Type Type = AccessTools.TypeByName("UpgradeProperty_Globbler_GlobblometerSpeed");

			public static MethodBase TargetModifyProperties()
			{
				Type type = typeof(string).MakeByRefType();
				Type type2 = AccessTools.TypeByName("Pigeon.Math.Random");
				return AccessTools.Method(Type, "ModifyProperties", new Type[4]
				{
					type,
					type2,
					typeof(IUpgradable),
					typeof(UpgradeInstance)
				}, (Type[])null);
			}

			public static bool ModifyPropertiesPrefix(object __instance, ref string properties, Random rand, IUpgradable gear, UpgradeInstance upgrade)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				if (!(gear is Globbler))
				{
					return true;
				}
				float value = ((Range<float>)AccessTools.Field(Type, "speed").GetValue(__instance)).GetValue(ref rand);
				int globblerTotalGlobblometer = StatCalcPatches.globblerTotalGlobblometer;
				string text = (string)StatCalcPatches.textBlocksGetStringMethod.Invoke(null, new object[1] { "add_s" });
				float num = (float)globblerTotalGlobblometer * value;
				bool flag = globblerTotalGlobblometer > 0;
				object[] array = new object[5]
				{
					properties,
					text,
					num,
					flag,
					StatCalcPatches.overrideAdd
				};
				StatCalcPatches.addDynamicPropMethod.Invoke(null, array);
				properties = (string)array[0];
				return false;
			}
		}

		public static class GlobblerGlobblometerAmmoPatch
		{
			public static Type Type = AccessTools.TypeByName("UpgradeProperty_Globbler_GlobblometerAmmo");

			public static MethodBase TargetApply()
			{
				return AccessTools.Method(Type, "Apply", new Type[3]
				{
					typeof(IGear),
					typeof(UpgradeInstance),
					typeof(Random).MakeByRefType()
				}, (Type[])null);
			}

			public static bool ApplyPrefix(object __instance, IGear gear, UpgradeInstance upgrade, ref Random rand)
			{
				//IL_0027: 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)
				Globbler val = (Globbler)(object)((gear is Globbler) ? gear : null);
				if ((Object)(object)val == (Object)null)
				{
					return true;
				}
				float value = ((Range<float>)AccessTools.Field(Type, "ammo").GetValue(__instance)).GetValue(ref rand);
				int globblerTotalGlobblometer = StatCalcPatches.globblerTotalGlobblometer;
				((Gun)val).GunData.magazineSize += Mathf.RoundToInt(value * (float)globblerTotalGlobblometer);
				return false;
			}

			public static MethodBase TargetModifyProperties()
			{
				Type type = typeof(string).MakeByRefType();
				Type type2 = AccessTools.TypeByName("Pigeon.Math.Random");
				return AccessTools.Method(Type, "ModifyProperties", new Type[4]
				{
					type,
					type2,
					typeof(IUpgradable),
					typeof(UpgradeInstance)
				}, (Type[])null);
			}

			public static bool ModifyPropertiesPrefix(object __instance, ref string properties, Random rand, IUpgradable gear, UpgradeInstance upgrade)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				if (!(gear is Globbler))
				{
					return true;
				}
				float value = ((Range<float>)AccessTools.Field(Type, "ammo").GetValue(__instance)).GetValue(ref rand);
				int globblerTotalGlobblometer = StatCalcPatches.globblerTotalGlobblometer;
				string text = (string)StatCalcPatches.textBlocksGetStringMethod.Invoke(null, new object[1] { "ammo" });
				int num = Mathf.RoundToInt((float)globblerTotalGlobblometer * value);
				bool flag = globblerTotalGlobblometer > 0;
				object[] array = new object[5]
				{
					properties,
					text,
					num,
					flag,
					StatCalcPatches.overrideAdd
				};
				StatCalcPatches.addDynamicPropMethod.Invoke(null, array);
				properties = (string)array[0];
				return false;
			}
		}
	}
	public static class MiniCannonPatches
	{
		public static class MiniCannonPrismPatch
		{
			public static Type Type = AccessTools.TypeByName("UpgradeProperty_MiniCannon_Prism");

			public static MethodInfo GetConnectedMethod = AccessTools.Method(Type, "GetConnectedPrismCountRecursive", new Type[2]
			{
				typeof(IUpgradable),
				typeof(UpgradeInstance)
			}, (Type[])null);

			public static MethodBase TargetApply()
			{
				return AccessTools.Method(Type, "Apply", new Type[3]
				{
					typeof(IGear),
					typeof(UpgradeInstance),
					typeof(Random).MakeByRefType()
				}, (Type[])null);
			}

			public static bool ApplyPrefix(object __instance, IGear gear, UpgradeInstance upgrade, ref Random rand)
			{
				//IL_0027: 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_0042: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Expected I4, but got Unknown
				//IL_00e3: 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)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				MiniCannon val = (MiniCannon)(object)((gear is MiniCannon) ? gear : null);
				if ((Object)(object)val == (Object)null)
				{
					return true;
				}
				Rarity val2 = (Rarity)AccessTools.Field(Type, "rarity").GetValue(__instance);
				Range<float> val3 = (Range<float>)AccessTools.Field(Type, "value").GetValue(__instance);
				int num = (StatCalcPatches.prismConnectedCounts.ContainsKey(upgrade.InstanceID) ? StatCalcPatches.prismConnectedCounts[upgrade.InstanceID] : ((int)GetConnectedMethod.Invoke(null, new object[2] { gear, upgrade })));
				float value = val3.GetValue(ref rand);
				float num2 = 1f + (float)num * value;
				switch ((int)val2)
				{
				case 0:
					((Gun)val).GunData.rangeData.maxDamageRange *= num2;
					break;
				case 1:
				{
					ref Vector2 spreadSize = ref ((Gun)val).GunData.spreadData.spreadSize;
					spreadSize *= num2;
					break;
				}
				case 2:
					((Gun)val).GunData.fireInterval *= 1f / num2;
					break;
				case 3:
					((Gun)val).GunData.damage *= num2;
					break;
				}
				StatCalcPatches.prismConnectedCounts[upgrade.InstanceID] = num;
				return false;
			}

			public static MethodBase TargetModifyProperties()
			{
				Type type = typeof(string).MakeByRefType();
				Type type2 = AccessTools.TypeByName("Pigeon.Math.Random");
				return AccessTools.Method(Type, "ModifyProperties", new Type[4]
				{
					type,
					type2,
					typeof(IUpgradable),
					typeof(UpgradeInstance)
				}, (Type[])null);
			}

			public static bool ModifyPropertiesPrefix(object __instance, ref string properties, Random rand, IUpgradable gear, UpgradeInstance upgrade)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: 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_0053: 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_0070: Expected I4, but got Unknown
				if (upgrade == null)
				{
					return true;
				}
				if (StatCalcPatches.prismConnectedCounts.TryGetValue(upgrade.InstanceID, out var value))
				{
					Range<float> val = (Range<float>)AccessTools.Field(Type, "value").GetValue(__instance);
					Rarity val2 = (Rarity)AccessTools.Field(Type, "rarity").GetValue(__instance);
					float value2 = val.GetValue(ref rand);
					string text = (int)val2 switch
					{
						0 => "range", 
						1 => "spread", 
						2 => "firerate", 
						_ => "damage", 
					};
					string text2 = (string)StatCalcPatches.textBlocksGetStringMethod.Invoke(null, new object[1] { text });
					float num = 1f + (float)value * value2;
					bool flag = value > 0;
					object[] array = new object[5]
					{
						properties,
						text2,
						num,
						flag,
						StatCalcPatches.overrideMultiply
					};
					StatCalcPatches.addDynamicPropMethod.Invoke(null, array);
					properties = (string)array[0];
					return false;
				}
				return true;
			}
		}
	}
	[BepInPlugin("sparroh.performanceenhancedmenu", "PerformanceEnhancedMenu", "1.0.1")]
	[MycoMod(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "sparroh.performanceenhancedmenu";

		public const string PluginName = "PerformanceEnhancedMenu";

		public const string PluginVersion = "1.0.1";

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("sparroh.performanceenhancedmenu");
			MethodBase methodBase = GeneralPatches.EquipUpgradePatch.TargetMethod();
			if (methodBase != null)
			{
				val.Patch(methodBase, (HarmonyMethod)null, new HarmonyMethod(typeof(GeneralPatches.EquipUpgradePatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			methodBase = GeneralPatches.UnequipUpgradePatch.TargetMethod();
			if (methodBase != null)
			{
				val.Patch(methodBase, (HarmonyMethod)null, new HarmonyMethod(typeof(GeneralPatches.UnequipUpgradePatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			methodBase = CellTouchingPatches.GetConnectedPrismCountRecursivePatch.TargetMethod();
			if (methodBase != null)
			{
				val.Patch(methodBase, new HarmonyMethod(typeof(CellTouchingPatches.GetConnectedPrismCountRecursivePatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			methodBase = CellTouchingPatches.GetNumCellsTouchingThisPatch.TargetMethod();
			if (methodBase != null)
			{
				val.Patch(methodBase, new HarmonyMethod(typeof(CellTouchingPatches.GetNumCellsTouchingThisPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}
	}
	public static class StatCalcPatches
	{
		internal static Dictionary<long, string> statListCache;

		internal static Dictionary<long, string> displayPropertiesCache;

		internal static string tempOldProperties;

		internal static int globblerTotalGlobblometer;

		internal static Dictionary<int, int> prismConnectedCounts;

		internal static Dictionary<int, (int std, int rare, int epic, int exo)> rarityTouchingCounts;

		internal static Dictionary<int, UpgradeInstance[,]> upgradeGridCache;

		internal static Dictionary<int, int> numRaritiesTouching;

		internal static Dictionary<int, int> numCellsTouching;

		internal static Dictionary<int, int> numEmptyCellsTouching;

		internal static Dictionary<int, int> numUniqueUpgradesTouching;

		internal static MethodInfo addDynamicPropMethod;

		internal static MethodInfo textBlocksGetStringMethod;

		internal static Type overrideType;

		internal static object overrideMultiply;

		internal static object overrideAdd;

		internal static Type rarityFlagsType;

		internal static object rarityFlagsStandard;

		internal static object rarityFlagsRare;

		internal static object rarityFlagsEpic;

		internal static object rarityFlagsExotic;

		internal static MethodInfo getNumTouchingMethod;

		internal static Type iGlobblometerPropertyType;

		internal static MethodInfo modifyGlobblometerMethod;

		internal static Type upgradeEquipDataType;

		internal static MethodInfo getUpgradeMethod;

		internal static FieldInfo equippedUpgradesField;

		internal static bool skipRecompute;

		static StatCalcPatches()
		{
			statListCache = new Dictionary<long, string>();
			displayPropertiesCache = new Dictionary<long, string>();
			prismConnectedCounts = new Dictionary<int, int>();
			rarityTouchingCounts = new Dictionary<int, (int, int, int, int)>();
			upgradeGridCache = new Dictionary<int, UpgradeInstance[,]>();
			numRaritiesTouching = new Dictionary<int, int>();
			numCellsTouching = new Dictionary<int, int>();
			numEmptyCellsTouching = new Dictionary<int, int>();
			numUniqueUpgradesTouching = new Dictionary<int, int>();
			equippedUpgradesField = null;
			skipRecompute = false;
			try
			{
				addDynamicPropMethod = AccessTools.Method(typeof(UpgradeProperty), "AddDynamicProperty", new Type[5]
				{
					typeof(string).MakeByRefType(),
					typeof(string),
					typeof(float),
					typeof(bool),
					AccessTools.TypeByName("OverrideType")
				}, (Type[])null);
				textBlocksGetStringMethod = AccessTools.Method(typeof(TextBlocks), "GetString", new Type[1] { typeof(string) }, (Type[])null);
				overrideType = AccessTools.TypeByName("OverrideType");
				overrideMultiply = Enum.Parse(overrideType, "Multiply");
				overrideAdd = Enum.Parse(overrideType, "Add");
				rarityFlagsType = AccessTools.TypeByName("RarityFlags");
				rarityFlagsStandard = Enum.Parse(rarityFlagsType, "Standard");
				rarityFlagsRare = Enum.Parse(rarityFlagsType, "Rare");
				rarityFlagsEpic = Enum.Parse(rarityFlagsType, "Epic");
				rarityFlagsExotic = Enum.Parse(rarityFlagsType, "Exotic");
				getNumTouchingMethod = AccessTools.Method(typeof(UpgradeProperty), "GetNumCellsTouchingThis", new Type[3]
				{
					typeof(IUpgradable),
					typeof(UpgradeInstance),
					rarityFlagsType
				}, (Type[])null);
				iGlobblometerPropertyType = AccessTools.TypeByName("IGlobblometerProperty");
				modifyGlobblometerMethod = AccessTools.Method(iGlobblometerPropertyType, "ModifyGlobblometer", new Type[4]
				{
					typeof(int).MakeByRefType(),
					typeof(Random),
					typeof(IUpgradable),
					typeof(UpgradeInstance)
				}, (Type[])null);
				upgradeEquipDataType = AccessTools.Inner(typeof(PlayerData), "UpgradeEquipData");
				getUpgradeMethod = AccessTools.Method(upgradeEquipDataType, "GetUpgrade", (Type[])null, (Type[])null);
				equippedUpgradesField = AccessTools.Field(typeof(GearData), "equippedUpgrades");
			}
			catch (Exception)
			{
			}
		}

		internal static void RecomputeTotals(GearData gearData)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Expected O, but got Unknown
			rarityTouchingCounts.Clear();
			UpgradePropertyList properties;
			if (gearData.Gear is Globbler)
			{
				int num = 0;
				List<UpgradeInstance> list = new List<UpgradeInstance>();
				IList obj = (IList)equippedUpgradesField.GetValue(gearData);
				List<object> list2 = new List<object>();
				foreach (object item5 in obj)
				{
					list2.Add(item5);
				}
				Random val2 = default(Random);
				foreach (object item6 in list2)
				{
					UpgradeInstance val = (UpgradeInstance)getUpgradeMethod.Invoke(item6, null);
					((Random)(ref val2))..ctor(val.Seed);
					bool flag = false;
					Upgrade upgrade = val.Upgrade;
					GenericGunUpgrade val3 = (GenericGunUpgrade)(object)((upgrade is GenericGunUpgrade) ? upgrade : null);
					if (val3 != null)
					{
						properties = ((Upgrade)val3).Properties;
						if (((UpgradePropertyList)(ref properties)).HasProperties)
						{
							UpgradePropertyList properties2 = ((Upgrade)val3).Properties;
							for (int i = 0; i < ((UpgradePropertyList)(ref properties2)).Count; i++)
							{
								UpgradeProperty val4 = ((UpgradePropertyList)(ref properties2))[i];
								if (((object)val4).GetType().FullName == "UpgradeProperty_Globbler_RarityStats")
								{
									flag = true;
								}
								if (iGlobblometerPropertyType.IsAssignableFrom(((object)val4).GetType()))
								{
									object[] array = new object[4] { num, val2, gearData.Gear, val };
									modifyGlobblometerMethod.Invoke(val4, array);
									num = (int)array[0];
								}
							}
						}
					}
					if (flag)
					{
						list.Add(val);
					}
					if (iGlobblometerPropertyType.IsAssignableFrom(((object)val.Upgrade).GetType()))
					{
						object[] array2 = new object[4] { num, val2, gearData.Gear, val };
						modifyGlobblometerMethod.Invoke(val.Upgrade, array2);
						num = (int)array2[0];
					}
				}
				if (list.Count > 0)
				{
					foreach (UpgradeInstance item7 in list)
					{
						int item = (int)getNumTouchingMethod.Invoke(null, new object[3] { gearData.Gear, item7, rarityFlagsStandard });
						int item2 = (int)getNumTouchingMethod.Invoke(null, new object[3] { gearData.Gear, item7, rarityFlagsRare });
						int item3 = (int)getNumTouchingMethod.Invoke(null, new object[3] { gearData.Gear, item7, rarityFlagsEpic });
						int item4 = (int)getNumTouchingMethod.Invoke(null, new object[3] { gearData.Gear, item7, rarityFlagsExotic });
						rarityTouchingCounts[item7.InstanceID] = (item, item2, item3, item4);
					}
				}
				globblerTotalGlobblometer = num;
			}
			if (!(gearData.Gear is MiniCannon))
			{
				return;
			}
			prismConnectedCounts.Clear();
			Dictionary<UpgradeInstance, List<UpgradeInstance>> dictionary = new Dictionary<UpgradeInstance, List<UpgradeInstance>>();
			List<UpgradeInstance> list3 = new List<UpgradeInstance>();
			Dictionary<int, HashSet<(int, int)>> dictionary2 = new Dictionary<int, HashSet<(int, int)>>();
			IList obj2 = (IList)equippedUpgradesField.GetValue(gearData);
			List<object> list4 = new List<object>();
			foreach (object item8 in obj2)
			{
				list4.Add(item8);
			}
			foreach (object item9 in list4)
			{
				UpgradeInstance val5 = (UpgradeInstance)getUpgradeMethod.Invoke(item9, null);
				bool flag2 = false;
				Upgrade upgrade2 = val5.Upgrade;
				GenericGunUpgrade val6 = (GenericGunUpgrade)(object)((upgrade2 is GenericGunUpgrade) ? upgrade2 : null);
				if (val6 != null)
				{
					properties = ((Upgrade)val6).Properties;
					if (((UpgradePropertyList)(ref properties)).HasProperties)
					{
						UpgradePropertyList properties3 = ((Upgrade)val6).Properties;
						for (int j = 0; j < ((UpgradePropertyList)(ref properties3)).Count; j++)
						{
							if (((object)((UpgradePropertyList)(ref properties3))[j]).GetType().FullName == "UpgradeProperty_MiniCannon_Prism")
							{
								flag2 = true;
								break;
							}
						}
					}
				}
				if (flag2)
				{
					list3.Add(val5);
					dictionary[val5] = new List<UpgradeInstance>();
				}
			}
			MethodInfo methodInfo = AccessTools.Method(typeof(PlayerData), "GetSurroundingCells", new Type[3]
			{
				typeof(IUpgradable),
				typeof(UpgradeInstance),
				typeof(HashSet<(int, int)>).MakeByRefType()
			}, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(PlayerData), "GetEquippedUpgrade", new Type[3]
			{
				typeof(IUpgradable),
				typeof(int),
				typeof(int)
			}, (Type[])null);
			foreach (UpgradeInstance item10 in list3)
			{
				HashSet<(int, int)> hashSet = new HashSet<(int, int)>();
				object[] array3 = new object[3] { gearData.Gear, item10, hashSet };
				methodInfo.Invoke(null, array3);
				hashSet = (HashSet<(int, int)>)array3[2];
				dictionary2[item10.InstanceID] = hashSet;
			}
			foreach (UpgradeInstance item11 in list3)
			{
				foreach (var item12 in dictionary2[item11.InstanceID])
				{
					UpgradeInstance val7 = (UpgradeInstance)methodInfo2.Invoke(null, new object[3] { gearData.Gear, item12.Item1, item12.Item2 });
					if (val7 != null && dictionary.ContainsKey(val7))
					{
						dictionary[item11].Add(val7);
					}
				}
			}
			HashSet<UpgradeInstance> hashSet2 = new HashSet<UpgradeInstance>();
			foreach (UpgradeInstance item13 in list3)
			{
				if (hashSet2.Contains(item13))
				{
					continue;
				}
				List<UpgradeInstance> list5 = DFS(dictionary, item13, hashSet2);
				int count = list5.Count;
				foreach (UpgradeInstance item14 in list5)
				{
					prismConnectedCounts[item14.InstanceID] = count;
				}
			}
		}

		internal static List<UpgradeInstance> DFS(Dictionary<UpgradeInstance, List<UpgradeInstance>> graph, UpgradeInstance node, HashSet<UpgradeInstance> visited)
		{
			List<UpgradeInstance> list = new List<UpgradeInstance>();
			Stack<UpgradeInstance> stack = new Stack<UpgradeInstance>();
			stack.Push(node);
			while (stack.Count > 0)
			{
				UpgradeInstance val = stack.Pop();
				if (!visited.Add(val))
				{
					continue;
				}
				list.Add(val);
				foreach (UpgradeInstance item in graph[val])
				{
					if (!visited.Contains(item))
					{
						stack.Push(item);
					}
				}
			}
			return list;
		}

		internal static void ClearCaches()
		{
			statListCache.Clear();
			displayPropertiesCache.Clear();
			upgradeGridCache.Clear();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "PerformanceEnhancedMenu";

		public const string PLUGIN_NAME = "PerformanceEnhancedMenu";

		public const string PLUGIN_VERSION = "0.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}