Decompiled source of PotentialQualityCompat v1.1.0

PotentialQualityCompat.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ArtifactOfPotential;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ItemQualities;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PotentialQualityCompat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b6f78e7beab67b8cce83364e550be9959c4bc6e1")]
[assembly: AssemblyProduct("PotentialQualityCompat")]
[assembly: AssemblyTitle("PotentialQualityCompat")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PotentialQualityCompat
{
	[BepInPlugin("lz.PotentialQualityCompat", "PotentialQualityCompat", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private delegate CreatePickupInfo CreatePickupInfoBasicFn(UniquePickup pickup, Vector3 position, Xoroshiro128Plus rng, PickupDropTable dropTable);

		private delegate CreatePickupInfo CreatePickupInfoNoTableFn(UniquePickup pickup, Vector3 position, Xoroshiro128Plus rng);

		public const string PluginGUID = "lz.PotentialQualityCompat";

		public const string PluginName = "PotentialQualityCompat";

		public const string PluginVersion = "1.1.0";

		public const string PotentialGUID = "zombieseatflesh7.ArtifactOfPotential";

		public const string QualityGUID = "com.Gorakh.ItemQualities";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> MatchQuality;

		internal static ConfigEntry<bool> QualityChestOptions;

		private static readonly List<Hook> _hooks = new List<Hook>();

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			MatchQuality = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Match Quality", true, "If the item a Potential wraps has a quality tier, raise the other options to that same tier.");
			QualityChestOptions = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Quality Chest Options", true, "Give quality chests and the quality equipment barrel a Potential picker; all options share the drop's quality tier.");
			SacrificeQualityChance.Init(((BaseUnityPlugin)this).Config);
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				RiskOfOptionsCompat.Init();
			}
			if (!TryHook("CreatePickupInfo_Basic", "CreatePickupInfo_Basic_Detour"))
			{
				Log.LogError((object)"This Artifact of Potential version is not supported. Compat disabled.");
				return;
			}
			TryHook("CreatePickupInfo_Random", "CreatePickupInfo_Random_Detour");
			TryHook("CreatePickupInfo_Boss", "CreatePickupInfo_Boss_Detour");
		}

		private bool TryHook(string targetName, string detourName)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			MethodInfo method = typeof(PotentialArtifact).GetMethod(targetName, BindingFlags.Static | BindingFlags.NonPublic);
			if (method == null)
			{
				Log.LogWarning((object)("PotentialArtifact." + targetName + " not found; that drop source keeps Potential's default behavior."));
				return false;
			}
			_hooks.Add(new Hook((MethodBase)method, typeof(Plugin).GetMethod(detourName, BindingFlags.Static | BindingFlags.NonPublic)));
			Log.LogInfo((object)("Hooked Artifact of Potential's " + targetName + "."));
			return true;
		}

		public void OnDestroy()
		{
			foreach (Hook hook in _hooks)
			{
				hook.Dispose();
			}
			_hooks.Clear();
			SacrificeQualityChance.Dispose();
		}

		private static CreatePickupInfo CreatePickupInfo_Basic_Detour(CreatePickupInfoBasicFn orig, UniquePickup pickup, Vector3 position, Xoroshiro128Plus rng, PickupDropTable dropTable)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			CreatePickupInfo info = orig(pickup, position, rng, dropTable);
			PostProcess(ref info, pickup, rng, dropTable);
			return info;
		}

		private static CreatePickupInfo CreatePickupInfo_Random_Detour(CreatePickupInfoNoTableFn orig, UniquePickup pickup, Vector3 position, Xoroshiro128Plus rng)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			CreatePickupInfo info = orig(pickup, position, rng);
			PostProcess(ref info, pickup, rng, null);
			return info;
		}

		private static CreatePickupInfo CreatePickupInfo_Boss_Detour(CreatePickupInfoNoTableFn orig, UniquePickup pickup, Vector3 position, Xoroshiro128Plus rng)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			CreatePickupInfo info = orig(pickup, position, rng);
			PostProcess(ref info, pickup, rng, null);
			return info;
		}

		private static void PostProcess(ref CreatePickupInfo info, UniquePickup pickup, Xoroshiro128Plus rng, PickupDropTable dropTable)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_0044: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				QualityTier qualityTier = QualityCatalog.GetQualityTier(pickup.pickupIndex);
				if (info.pickerOptions == null)
				{
					if (QualityChestOptions.Value)
					{
						QualityPickupDropTable val = (QualityPickupDropTable)(object)((dropTable is QualityPickupDropTable) ? dropTable : null);
						if (val != null)
						{
							BuildQualityChestOptions(ref info, pickup, qualityTier, rng, val);
						}
					}
				}
				else if (MatchQuality.Value && (int)qualityTier != -1)
				{
					ReplaceCopiesOfMain(info.pickerOptions, pickup, rng);
					RaiseOptionsToQuality(info.pickerOptions, pickup, qualityTier);
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void ReplaceCopiesOfMain(Option[] options, UniquePickup mainPickup, Xoroshiro128Plus rng)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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)
			PickupIndex val = BaseOf(mainPickup.pickupIndex);
			HashSet<PickupIndex> hashSet = new HashSet<PickupIndex>();
			bool flag = false;
			for (int i = 0; i < options.Length; i++)
			{
				PickupIndex val2 = BaseOf(options[i].pickup.pickupIndex);
				if (i > 0 && val2 == val)
				{
					flag = true;
				}
				hashSet.Add(val2);
			}
			if (!flag)
			{
				return;
			}
			List<PickupIndex> dropList = GetDropList(GetPotentialTier(mainPickup.pickupIndex));
			if (dropList == null)
			{
				return;
			}
			List<PickupIndex> list = new List<PickupIndex>();
			foreach (PickupIndex item in dropList)
			{
				if (!hashSet.Contains(item) && IsPickupEnabled(item))
				{
					list.Add(item);
				}
			}
			Xoroshiro128Plus val3 = new Xoroshiro128Plus(rng.nextUlong);
			for (int j = 1; j < options.Length; j++)
			{
				if (list.Count <= 0)
				{
					break;
				}
				if (!(BaseOf(options[j].pickup.pickupIndex) != val))
				{
					int index = val3.RangeInt(0, list.Count);
					Option val4 = options[j];
					val4.pickup = ((UniquePickup)(ref val4.pickup)).WithPickupIndex(list[index]);
					options[j] = val4;
					list.RemoveAt(index);
				}
			}
		}

		private static void RaiseOptionsToQuality(Option[] options, UniquePickup mainPickup, QualityTier quality)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			PickupIndex val = BaseOf(mainPickup.pickupIndex);
			for (int i = 0; i < options.Length; i++)
			{
				Option val2 = options[i];
				PickupIndex pickupIndex = val2.pickup.pickupIndex;
				if (((PickupIndex)(ref pickupIndex)).isValid && !(BaseOf(pickupIndex) == val) && QualityCatalog.GetQualityTier(pickupIndex) < quality)
				{
					PickupIndex pickupIndexOfQuality = QualityCatalog.GetPickupIndexOfQuality(pickupIndex, quality);
					if (!(pickupIndexOfQuality == pickupIndex) && IsPickupEnabled(pickupIndexOfQuality))
					{
						val2.pickup = ((UniquePickup)(ref val2.pickup)).WithPickupIndex(pickupIndexOfQuality);
						options[i] = val2;
					}
				}
			}
		}

		private static void BuildQualityChestOptions(ref CreatePickupInfo info, UniquePickup mainPickup, QualityTier quality, Xoroshiro128Plus rng, QualityPickupDropTable dropTable)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			int potentialTier = GetPotentialTier(mainPickup.pickupIndex);
			List<PickupIndex> dropList = GetDropList(potentialTier);
			if (dropList == null)
			{
				return;
			}
			int num = Settings.GetChoiceCountByTier(potentialTier) - 1;
			if (num <= 0)
			{
				return;
			}
			PickupIndex val = BaseOf(mainPickup.pickupIndex);
			List<PickupIndex> list = new List<PickupIndex>();
			foreach (PickupIndex item2 in dropList)
			{
				if (!(item2 == val) && (!dropTable.IsFilterRequired() || dropTable.PassesFilter(item2)))
				{
					PickupIndex val2 = (((int)quality == -1) ? item2 : QualityCatalog.GetPickupIndexOfQuality(item2, quality));
					if (((int)quality == -1 || !(val2 == item2)) && IsPickupEnabled(val2))
					{
						list.Add(val2);
					}
				}
			}
			num = Math.Min(num, list.Count);
			if (num > 0)
			{
				Xoroshiro128Plus val3 = new Xoroshiro128Plus(rng.nextUlong);
				List<UniquePickup> list2 = new List<UniquePickup>(num + 1) { mainPickup };
				UniquePickup item = default(UniquePickup);
				for (int i = 0; i < num; i++)
				{
					int num2 = val3.RangeInt(i, list.Count);
					List<PickupIndex> list3 = list;
					int index = i;
					int index2 = num2;
					PickupIndex value = list[num2];
					PickupIndex value2 = list[i];
					list3[index] = value;
					list[index2] = value2;
					((UniquePickup)(ref item))..ctor(list[i]);
					item.decayValue = mainPickup.decayValue;
					list2.Add(item);
				}
				info.pickerOptions = PickupPickerController.GenerateOptionsFromList<List<UniquePickup>>(list2);
				info.prefabOverride = ((list2.Count > 3) ? PotentialArtifact.commandCubePrefab : PotentialArtifact.voidPotentialPrefab);
			}
		}

		private static PickupIndex BaseOf(PickupIndex pickupIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return QualityCatalog.GetPickupIndexOfQuality(pickupIndex, (QualityTier)(-1));
		}

		private static bool IsPickupEnabled(PickupIndex pickupIndex)
		{
			//IL_001f: 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_0032: Invalid comparison between Unknown and I4
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			RuleBook val = (Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.ruleBook : null);
			if (val == null)
			{
				return true;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
			if (pickupDef == null)
			{
				return false;
			}
			if ((int)pickupDef.itemIndex != -1)
			{
				RuleDef val2 = RuleCatalog.FindRuleDef("Items." + ((Object)ItemCatalog.GetItemDef(pickupDef.itemIndex)).name);
				RuleChoiceDef val3 = ((val2 != null) ? val.GetRuleChoice(val2) : null);
				if (val3 != null)
				{
					return val3.itemIndex == pickupDef.itemIndex;
				}
				return true;
			}
			if ((int)pickupDef.equipmentIndex != -1)
			{
				RuleDef val4 = RuleCatalog.FindRuleDef("Equipments." + ((Object)EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex)).name);
				RuleChoiceDef val5 = ((val4 != null) ? val.GetRuleChoice(val4) : null);
				if (val5 != null)
				{
					return val5.equipmentIndex == pickupDef.equipmentIndex;
				}
				return true;
			}
			return true;
		}

		private static int GetPotentialTier(PickupIndex pickupIndex)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected I4, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex);
			if (pickupDef == null)
			{
				return 0;
			}
			ItemTier itemTier = pickupDef.itemTier;
			switch ((int)itemTier)
			{
			default:
				if ((int)itemTier != 1000)
				{
					break;
				}
				return 12;
			case 0:
				return 1;
			case 1:
				return 2;
			case 2:
				return 3;
			case 4:
				return 5;
			case 3:
				return 6;
			case 6:
				return 7;
			case 7:
				return 8;
			case 8:
				return 9;
			case 9:
				return 10;
			case 10:
				return 11;
			case 5:
				break;
			}
			if (!pickupDef.isLunar)
			{
				return 4;
			}
			return 6;
		}

		private static List<PickupIndex> GetDropList(int tier)
		{
			Run instance = Run.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return null;
			}
			return tier switch
			{
				1 => instance.availableTier1DropList, 
				2 => instance.availableTier2DropList, 
				3 => instance.availableTier3DropList, 
				4 => instance.availableEquipmentDropList, 
				5 => instance.availableBossDropList, 
				7 => instance.availableVoidTier1DropList, 
				8 => instance.availableVoidTier2DropList, 
				9 => instance.availableVoidTier3DropList, 
				10 => instance.availableVoidBossDropList, 
				_ => null, 
			};
		}
	}
	internal static class RiskOfOptionsCompat
	{
		internal const string GUID = "com.rune580.riskofoptions";

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void Init()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Artifact of Potential + Quality compatibility.", "lz.PotentialQualityCompat", "PotentialQualityCompat");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Plugin.MatchQuality), "lz.PotentialQualityCompat", "PotentialQualityCompat");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(Plugin.QualityChestOptions), "lz.PotentialQualityCompat", "PotentialQualityCompat");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(SacrificeQualityChance.Enabled), "lz.PotentialQualityCompat", "PotentialQualityCompat");
			ModSettingsManager.AddOption((BaseOption)new SliderOption(SacrificeQualityChance.Chance, new SliderConfig
			{
				min = 0f,
				max = 100f,
				FormatString = "{0:0.#}%"
			}), "lz.PotentialQualityCompat", "PotentialQualityCompat");
		}
	}
	internal static class SacrificeQualityChance
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__PatchRollQuality;

			public static Func<float, float> <1>__GetChance;
		}

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> Chance;

		private static ILHook _rollQualityHook;

		internal static void Init(ConfigFile config)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			Enabled = config.Bind<bool>("Sacrifice", "Use Sacrifice Quality Chance", true, "While the Artifact of Sacrifice is on, use 'Sacrifice Quality Chance' instead of Quality's 'Global Quality Chance'.");
			Chance = config.Bind<float>("Sacrifice", "Sacrifice Quality Chance", 20f, new ConfigDescription("% chance for an item to roll a quality tier while the Artifact of Sacrifice is on (Quality's default outside Sacrifice is 4).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			MethodInfo methodInfo = typeof(QualityCatalog).Assembly.GetType("ItemQualities.DropTableQualityHandler")?.GetMethod("RollQuality", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (methodInfo == null)
			{
				Plugin.Log.LogWarning((object)"Quality's DropTableQualityHandler.RollQuality not found; Sacrifice Quality Chance disabled.");
				return;
			}
			object obj = <>O.<0>__PatchRollQuality;
			if (obj == null)
			{
				Manipulator val = PatchRollQuality;
				<>O.<0>__PatchRollQuality = val;
				obj = (object)val;
			}
			_rollQualityHook = new ILHook((MethodBase)methodInfo, (Manipulator)obj);
		}

		internal static void Dispose()
		{
			ILHook rollQualityHook = _rollQualityHook;
			if (rollQualityHook != null)
			{
				rollQualityHook.Dispose();
			}
			_rollQualityHook = null;
		}

		private static void PatchRollQuality(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			MethodReference val2 = default(MethodReference);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(General), "get_GlobalQualityChance"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val2) && ((MemberReference)val2).Name == "get_Value"
			}))
			{
				Plugin.Log.LogWarning((object)"Could not find the Global Quality Chance read in RollQuality; Sacrifice Quality Chance disabled.");
				return;
			}
			val.EmitDelegate<Func<float, float>>((Func<float, float>)GetChance);
			Plugin.Log.LogInfo((object)"Hooked Quality's RollQuality for Sacrifice Quality Chance.");
		}

		private static float GetChance(float globalChance)
		{
			if (!Enabled.Value || !IsSacrificeActive())
			{
				return globalChance;
			}
			return Chance.Value;
		}

		private static bool IsSacrificeActive()
		{
			RunArtifactManager instance = RunArtifactManager.instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				return instance.IsArtifactEnabled(Artifacts.sacrificeArtifactDef);
			}
			return false;
		}
	}
}