Decompiled source of Artifact of Potential v1.3.0

ArtifactOfPotential/ArtifactOfPotential.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Artifacts;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Artifacts;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArtifactOfPotential")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d8a1a9d7cf46c179cd69f667d980808937d21f70")]
[assembly: AssemblyProduct("ArtifactOfPotential")]
[assembly: AssemblyTitle("ArtifactOfPotential")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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;
		}
	}
}
namespace ArtifactOfPotential
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("zombieseatflesh7.ArtifactOfPotential", "ArtifactOfPotential", "1.3.0")]
	public class ArtifactOfPotential : BaseUnityPlugin
	{
		public const string PluginGUID = "zombieseatflesh7.ArtifactOfPotential";

		public const string PluginAuthor = "zombieseatflesh7";

		public const string PluginName = "ArtifactOfPotential";

		public const string PluginVersion = "1.3.0";

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			PInfo = ((BaseUnityPlugin)this).Info;
			InitConfig();
			Asset.Init();
			PotentialArtifact.Init();
		}

		private void InitConfig()
		{
			Settings.AnyTierMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Any Tier Mode", "Any Tier Mode", false, "Similar to Simulacrum. An alternate mode where the options you choose from can be of different tiers, as long as that tier CAN be dropped. Affects: chests, shrines, etc. Ignores: multishops, lunar pods, boss events, etc. Synergizes with Eulogy Zero. Does not affect void items.");
			Settings.AnyTierModeChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Any Tier Mode", "Any Tier Mode - Choice Count", 3, "The number of choices you get from void potentials when \"Any Tier Mode\" is enabled. Does not affect void items.");
			Settings.AnyTierModeVoid = ((BaseUnityPlugin)this).Config.Bind<bool>("Any Tier Mode", "Any Tier Mode - Void", true, "Similar to Any Tier Mode, but only affects void items.");
			Settings.AnyTierModeVoidChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Any Tier Mode", "Any Tier Mode - Void - Choice Count", 3, "The number of choices you get from void tier void potentials when \"Any Tier Mode - Void\" is enabled. Only affects void items.");
			Settings.ChestsAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Chests", true, "Whether or not chests should drop void potentials.");
			Settings.ShrineOfChanceAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Shrines of chance", true, "Whether or not shrines of chance should drop void potentials.");
			Settings.HiddenMultishopsAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Mystery Multishops", true, "Whether or not mystery multishops should drop void potentials. Works even if the \"Multishops\" config is disabled.");
			Settings.MultishopsAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Multishops", false, "Whether or not multishops should drop void potentials. Includes mystery multishopsm even if that config is disabled");
			Settings.ShopsAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Shops", false, "Whether or not shops should drop void potentials. This includes: The bazaar shop, printers, and cauldrons. This setting will change in the future.");
			Settings.BossAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Boss", true, "Whether or not bosses should drop void potentials. This includes: the teleporter event, Alloy Worship Unit, Aurelionite, and any other \"boss\" event.");
			Settings.SonorousWhispersAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Sonorous Whispers", true, "Whether or not Sonorous Whispers should drop void potentials.");
			Settings.SacrificeAffected = ((BaseUnityPlugin)this).Config.Bind<bool>("Item Sources Affected", "Artifact of Sacrifice", true, "Whether or not Artifact of Sacrifice should drop void potentials.");
			Settings.DoppelgangerChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Item Sources Affected", "Artifact of Vengance - Choice Count", 5, "The number of item choices you get when killing a doppelganger from Artifact of Vengeance. Item choices can be any tier, regardless of other settings. Set to 1 to disable void potentials from this artifact.");
			Settings.Tier1ChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Common Options", 3, "The number of choices you get from common tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.Tier2ChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Uncommon Options", 3, "The number of choices you get from uncommon tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.Tier3ChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Legendary Options", 3, "The number of choices you get from legendary tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.EquipmentChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Equipment Options", 3, "The number of choices you get from Equipment tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.BossChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Boss Options", 1, "The number of choices you get from boss tier void potentials. Set to 1 to disable void potentials for this tier. Boss items are special, because they are based on the boss that is killed. Setting this value above 1 will allow you to get boss items that are hard to find normally, such as charged perforators or planulas.");
			Settings.LunarChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Lunar Options", 3, "The number of choices you get from lunar tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.Void1ChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Common Void Options", 3, "The number of choices you get from common void tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.Void2ChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Uncommon Void Options", 3, "The number of choices you get from uncommon void tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.Void3ChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Legendary Void Options", 3, "The number of choices you get from legendary void tier void potentials. Set to 1 to disable void potentials for this tier.");
			Settings.VoidBossChoiceCount = ((BaseUnityPlugin)this).Config.Bind<int>("Number of Options by Tier", "Boss Void Options", 3, "The number of choices you get from boss void tier void potentials. Set to 1 to disable void potentials for this tier. This option is redundant as there is only one boss void item at the time of this mod versions upload.");
		}
	}
	public static class PotentialArtifact
	{
		public enum PickupType
		{
			Ignore,
			NoDropTable,
			BasicDropTable,
			BossDropTable,
			DoppelgangerDropTable
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static ArtifactStateChangeDelegate <0>__OnArtifactEnabled;

			public static ArtifactStateChangeDelegate <1>__OnArtifactDisabled;

			public static hook_BaseItemDrop <2>__ChestBehavior_BaseItemDrop;

			public static hook_AddShrineStack <3>__ShrineChanceBehavior_AddShrineStack;

			public static hook_DropRewards <4>__BossGroup_DropRewards;

			public static hook_DropPickup <5>__ShopTerminalBehavior_DropPickup;

			public static hook_OnServerCharacterDeath <6>__SacrificeArtifactManager_OnServerCharacterDeath;

			public static hook_OnCharacterDeathGlobal <7>__DoppelgangerInvasionManager_OnCharacterDeathGlobal;

			public static hook_OnCharacterDeath <8>__GlobalEventManager_OnCharacterDeath;

			public static hook_RebuildModel <9>__PickupDisplay_RebuildModel;

			public static hook_CreatePickup <10>__GenericPickupController_CreatePickup;

			public static hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3 <11>__PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3;

			public static hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 <12>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3;
		}

		public static ArtifactDef Potential;

		public static GameObject voidPotentialPrefab = null;

		public static GameObject commandCubePrefab = null;

		public static Xoroshiro128Plus rng = null;

		public static PickupDropTable dropTable = null;

		public static GameObject currentModelObjectOverride = null;

		public static PickupType nextPickup = PickupType.Ignore;

		public static PickupIndex[][] bossDropsByTier = new PickupIndex[10][];

		public static void Init()
		{
			//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)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//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_00e0: Expected O, but got Unknown
			Potential = ScriptableObject.CreateInstance<ArtifactDef>();
			Potential.cachedName = "ArtifactOfPotential";
			Potential.nameToken = "Artifact of Potential";
			Potential.descriptionToken = "Most items become Void Potentials.";
			Potential.smallIconSelectedSprite = Asset.AssetBundle.LoadAsset<Sprite>("texArtifactPotentialEnabled.png");
			Potential.smallIconDeselectedSprite = Asset.AssetBundle.LoadAsset<Sprite>("texArtifactPotentialDisabled.png");
			ContentAddition.AddArtifactDef(Potential);
			voidPotentialPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/OptionPickup/OptionPickup.prefab").WaitForCompletion();
			commandCubePrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Command/CommandCube.prefab").WaitForCompletion();
			object obj = <>O.<0>__OnArtifactEnabled;
			if (obj == null)
			{
				ArtifactStateChangeDelegate val = OnArtifactEnabled;
				<>O.<0>__OnArtifactEnabled = val;
				obj = (object)val;
			}
			RunArtifactManager.onArtifactEnabledGlobal += (ArtifactStateChangeDelegate)obj;
			object obj2 = <>O.<1>__OnArtifactDisabled;
			if (obj2 == null)
			{
				ArtifactStateChangeDelegate val2 = OnArtifactDisabled;
				<>O.<1>__OnArtifactDisabled = val2;
				obj2 = (object)val2;
			}
			RunArtifactManager.onArtifactDisabledGlobal += (ArtifactStateChangeDelegate)obj2;
		}

		private static void OnArtifactEnabled(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//IL_0041: 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_004c: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Expected O, but got Unknown
			if ((Object)(object)artifactDef != (Object)(object)Potential || !NetworkServer.active)
			{
				return;
			}
			if (Settings.ChestsAffected.Value)
			{
				object obj = <>O.<2>__ChestBehavior_BaseItemDrop;
				if (obj == null)
				{
					hook_BaseItemDrop val = ChestBehavior_BaseItemDrop;
					<>O.<2>__ChestBehavior_BaseItemDrop = val;
					obj = (object)val;
				}
				ChestBehavior.BaseItemDrop += (hook_BaseItemDrop)obj;
			}
			if (Settings.ShrineOfChanceAffected.Value)
			{
				object obj2 = <>O.<3>__ShrineChanceBehavior_AddShrineStack;
				if (obj2 == null)
				{
					hook_AddShrineStack val2 = ShrineChanceBehavior_AddShrineStack;
					<>O.<3>__ShrineChanceBehavior_AddShrineStack = val2;
					obj2 = (object)val2;
				}
				ShrineChanceBehavior.AddShrineStack += (hook_AddShrineStack)obj2;
			}
			if (Settings.BossAffected.Value)
			{
				object obj3 = <>O.<4>__BossGroup_DropRewards;
				if (obj3 == null)
				{
					hook_DropRewards val3 = BossGroup_DropRewards;
					<>O.<4>__BossGroup_DropRewards = val3;
					obj3 = (object)val3;
				}
				BossGroup.DropRewards += (hook_DropRewards)obj3;
			}
			if (Settings.HiddenMultishopsAffected.Value || Settings.MultishopsAffected.Value || Settings.ShopsAffected.Value)
			{
				object obj4 = <>O.<5>__ShopTerminalBehavior_DropPickup;
				if (obj4 == null)
				{
					hook_DropPickup val4 = ShopTerminalBehavior_DropPickup;
					<>O.<5>__ShopTerminalBehavior_DropPickup = val4;
					obj4 = (object)val4;
				}
				ShopTerminalBehavior.DropPickup += (hook_DropPickup)obj4;
			}
			if (Settings.SacrificeAffected.Value)
			{
				object obj5 = <>O.<6>__SacrificeArtifactManager_OnServerCharacterDeath;
				if (obj5 == null)
				{
					hook_OnServerCharacterDeath val5 = SacrificeArtifactManager_OnServerCharacterDeath;
					<>O.<6>__SacrificeArtifactManager_OnServerCharacterDeath = val5;
					obj5 = (object)val5;
				}
				SacrificeArtifactManager.OnServerCharacterDeath += (hook_OnServerCharacterDeath)obj5;
			}
			if (Settings.DoppelgangerChoiceCount.Value > 1)
			{
				object obj6 = <>O.<7>__DoppelgangerInvasionManager_OnCharacterDeathGlobal;
				if (obj6 == null)
				{
					hook_OnCharacterDeathGlobal val6 = DoppelgangerInvasionManager_OnCharacterDeathGlobal;
					<>O.<7>__DoppelgangerInvasionManager_OnCharacterDeathGlobal = val6;
					obj6 = (object)val6;
				}
				DoppelgangerInvasionManager.OnCharacterDeathGlobal += (hook_OnCharacterDeathGlobal)obj6;
			}
			if (Settings.SonorousWhispersAffected.Value)
			{
				object obj7 = <>O.<8>__GlobalEventManager_OnCharacterDeath;
				if (obj7 == null)
				{
					hook_OnCharacterDeath val7 = GlobalEventManager_OnCharacterDeath;
					<>O.<8>__GlobalEventManager_OnCharacterDeath = val7;
					obj7 = (object)val7;
				}
				GlobalEventManager.OnCharacterDeath += (hook_OnCharacterDeath)obj7;
			}
			object obj8 = <>O.<9>__PickupDisplay_RebuildModel;
			if (obj8 == null)
			{
				hook_RebuildModel val8 = PickupDisplay_RebuildModel;
				<>O.<9>__PickupDisplay_RebuildModel = val8;
				obj8 = (object)val8;
			}
			PickupDisplay.RebuildModel += (hook_RebuildModel)obj8;
			object obj9 = <>O.<10>__GenericPickupController_CreatePickup;
			if (obj9 == null)
			{
				hook_CreatePickup val9 = GenericPickupController_CreatePickup;
				<>O.<10>__GenericPickupController_CreatePickup = val9;
				obj9 = (object)val9;
			}
			GenericPickupController.CreatePickup += (hook_CreatePickup)obj9;
			object obj10 = <>O.<11>__PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3;
			if (obj10 == null)
			{
				hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3 val10 = PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3;
				<>O.<11>__PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3 = val10;
				obj10 = (object)val10;
			}
			PickupDropletController.CreatePickupDroplet_PickupIndex_Vector3_Vector3 += (hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3)obj10;
			object obj11 = <>O.<12>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3;
			if (obj11 == null)
			{
				hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val11 = PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3;
				<>O.<12>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 = val11;
				obj11 = (object)val11;
			}
			PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj11;
		}

		private static void OnArtifactDisabled(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//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_0031: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0068: 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_0073: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_014f: 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_015a: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			if (!((Object)(object)artifactDef != (Object)(object)Potential))
			{
				object obj = <>O.<2>__ChestBehavior_BaseItemDrop;
				if (obj == null)
				{
					hook_BaseItemDrop val = ChestBehavior_BaseItemDrop;
					<>O.<2>__ChestBehavior_BaseItemDrop = val;
					obj = (object)val;
				}
				ChestBehavior.BaseItemDrop -= (hook_BaseItemDrop)obj;
				object obj2 = <>O.<3>__ShrineChanceBehavior_AddShrineStack;
				if (obj2 == null)
				{
					hook_AddShrineStack val2 = ShrineChanceBehavior_AddShrineStack;
					<>O.<3>__ShrineChanceBehavior_AddShrineStack = val2;
					obj2 = (object)val2;
				}
				ShrineChanceBehavior.AddShrineStack -= (hook_AddShrineStack)obj2;
				object obj3 = <>O.<4>__BossGroup_DropRewards;
				if (obj3 == null)
				{
					hook_DropRewards val3 = BossGroup_DropRewards;
					<>O.<4>__BossGroup_DropRewards = val3;
					obj3 = (object)val3;
				}
				BossGroup.DropRewards -= (hook_DropRewards)obj3;
				object obj4 = <>O.<5>__ShopTerminalBehavior_DropPickup;
				if (obj4 == null)
				{
					hook_DropPickup val4 = ShopTerminalBehavior_DropPickup;
					<>O.<5>__ShopTerminalBehavior_DropPickup = val4;
					obj4 = (object)val4;
				}
				ShopTerminalBehavior.DropPickup -= (hook_DropPickup)obj4;
				object obj5 = <>O.<6>__SacrificeArtifactManager_OnServerCharacterDeath;
				if (obj5 == null)
				{
					hook_OnServerCharacterDeath val5 = SacrificeArtifactManager_OnServerCharacterDeath;
					<>O.<6>__SacrificeArtifactManager_OnServerCharacterDeath = val5;
					obj5 = (object)val5;
				}
				SacrificeArtifactManager.OnServerCharacterDeath -= (hook_OnServerCharacterDeath)obj5;
				object obj6 = <>O.<7>__DoppelgangerInvasionManager_OnCharacterDeathGlobal;
				if (obj6 == null)
				{
					hook_OnCharacterDeathGlobal val6 = DoppelgangerInvasionManager_OnCharacterDeathGlobal;
					<>O.<7>__DoppelgangerInvasionManager_OnCharacterDeathGlobal = val6;
					obj6 = (object)val6;
				}
				DoppelgangerInvasionManager.OnCharacterDeathGlobal -= (hook_OnCharacterDeathGlobal)obj6;
				object obj7 = <>O.<8>__GlobalEventManager_OnCharacterDeath;
				if (obj7 == null)
				{
					hook_OnCharacterDeath val7 = GlobalEventManager_OnCharacterDeath;
					<>O.<8>__GlobalEventManager_OnCharacterDeath = val7;
					obj7 = (object)val7;
				}
				GlobalEventManager.OnCharacterDeath -= (hook_OnCharacterDeath)obj7;
				object obj8 = <>O.<9>__PickupDisplay_RebuildModel;
				if (obj8 == null)
				{
					hook_RebuildModel val8 = PickupDisplay_RebuildModel;
					<>O.<9>__PickupDisplay_RebuildModel = val8;
					obj8 = (object)val8;
				}
				PickupDisplay.RebuildModel -= (hook_RebuildModel)obj8;
				object obj9 = <>O.<10>__GenericPickupController_CreatePickup;
				if (obj9 == null)
				{
					hook_CreatePickup val9 = GenericPickupController_CreatePickup;
					<>O.<10>__GenericPickupController_CreatePickup = val9;
					obj9 = (object)val9;
				}
				GenericPickupController.CreatePickup -= (hook_CreatePickup)obj9;
				object obj10 = <>O.<11>__PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3;
				if (obj10 == null)
				{
					hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3 val10 = PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3;
					<>O.<11>__PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3 = val10;
					obj10 = (object)val10;
				}
				PickupDropletController.CreatePickupDroplet_PickupIndex_Vector3_Vector3 -= (hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3)obj10;
				object obj11 = <>O.<12>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3;
				if (obj11 == null)
				{
					hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val11 = PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3;
					<>O.<12>__PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 = val11;
					obj11 = (object)val11;
				}
				PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 -= (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj11;
			}
		}

		private static void PickupDisplay_RebuildModel(orig_RebuildModel orig, PickupDisplay self, GameObject modelObjectOverride)
		{
			if ((Object)(object)modelObjectOverride != (Object)null && (Object)(object)currentModelObjectOverride == (Object)null)
			{
				currentModelObjectOverride = modelObjectOverride;
			}
			else if ((Object)(object)currentModelObjectOverride != (Object)null)
			{
				modelObjectOverride = currentModelObjectOverride;
			}
			orig.Invoke(self, modelObjectOverride);
			if ((Object)(object)currentModelObjectOverride != (Object)null)
			{
				if (Object.op_Implicit((Object)(object)self.tier1ParticleEffect))
				{
					self.tier1ParticleEffect.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)self.tier2ParticleEffect))
				{
					self.tier2ParticleEffect.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)self.tier3ParticleEffect))
				{
					self.tier3ParticleEffect.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)self.equipmentParticleEffect))
				{
					self.equipmentParticleEffect.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)self.lunarParticleEffect))
				{
					self.lunarParticleEffect.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)self.voidParticleEffect))
				{
					self.voidParticleEffect.SetActive(false);
				}
			}
		}

		private static GenericPickupController GenericPickupController_CreatePickup(orig_CreatePickup orig, ref CreatePickupInfo createPickupInfo)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)createPickupInfo.prefabOverride == (Object)(object)commandCubePrefab)
			{
				Log.LogDebug("Prefab Overrid is CommandCube");
				GameObject val = Object.Instantiate<GameObject>(createPickupInfo.prefabOverride ?? GenericPickupController.pickupPrefab, createPickupInfo.position, createPickupInfo.rotation);
				GenericPickupController component = val.GetComponent<GenericPickupController>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.NetworkpickupIndex = ((CreatePickupInfo)(ref createPickupInfo)).pickupIndex;
					component.chestGeneratedFrom = createPickupInfo.chest;
				}
				PickupIndexNetworker component2 = val.GetComponent<PickupIndexNetworker>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.NetworkpickupIndex = ((CreatePickupInfo)(ref createPickupInfo)).pickupIndex;
				}
				PickupPickerController component3 = val.GetComponent<PickupPickerController>();
				if (Object.op_Implicit((Object)(object)component3) && createPickupInfo.pickerOptions != null)
				{
					component3.SetOptionsServer(createPickupInfo.pickerOptions);
				}
				NetworkServer.Spawn(val);
				return component;
			}
			orig.Invoke(ref createPickupInfo);
			currentModelObjectOverride = null;
			return null;
		}

		private static void ChestBehavior_BaseItemDrop(orig_BaseItemDrop orig, ChestBehavior self)
		{
			rng = Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng");
			dropTable = self.dropTable;
			nextPickup = PickupType.BasicDropTable;
			orig.Invoke(self);
			rng = null;
			dropTable = null;
			nextPickup = PickupType.Ignore;
			currentModelObjectOverride = null;
		}

		private static void ShrineChanceBehavior_AddShrineStack(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator)
		{
			rng = Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng");
			dropTable = self.dropTable;
			nextPickup = PickupType.BasicDropTable;
			orig.Invoke(self, activator);
			rng = null;
			dropTable = null;
			nextPickup = PickupType.Ignore;
			currentModelObjectOverride = null;
		}

		private static void SacrificeArtifactManager_OnServerCharacterDeath(orig_OnServerCharacterDeath orig, DamageReport damageReport)
		{
			rng = Reflection.GetFieldValue<Xoroshiro128Plus>(typeof(SacrificeArtifactManager), "treasureRng");
			dropTable = Reflection.GetFieldValue<PickupDropTable>(typeof(SacrificeArtifactManager), "dropTable");
			nextPickup = PickupType.BasicDropTable;
			orig.Invoke(damageReport);
			rng = null;
			dropTable = null;
			nextPickup = PickupType.Ignore;
			currentModelObjectOverride = null;
		}

		private static void ShopTerminalBehavior_DropPickup(orig_DropPickup orig, ShopTerminalBehavior self)
		{
			if ((Object)(object)self.serverMultiShopController != (Object)null && (Settings.MultishopsAffected.Value || (Settings.HiddenMultishopsAffected.Value && Reflection.GetFieldValue<bool>((object)self, "hidden"))))
			{
				rng = Reflection.GetFieldValue<Xoroshiro128Plus>((object)self.serverMultiShopController, "rng");
				nextPickup = PickupType.NoDropTable;
				orig.Invoke(self);
				rng = null;
				nextPickup = PickupType.Ignore;
				currentModelObjectOverride = null;
			}
			else if ((Object)(object)self.serverMultiShopController == (Object)null && Settings.ShopsAffected.Value)
			{
				rng = Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng");
				dropTable = self.dropTable;
				nextPickup = PickupType.BasicDropTable;
				orig.Invoke(self);
				rng = null;
				dropTable = null;
				nextPickup = PickupType.Ignore;
				currentModelObjectOverride = null;
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private static void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self)
		{
			rng = Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "rng");
			nextPickup = PickupType.BossDropTable;
			orig.Invoke(self);
			rng = null;
			nextPickup = PickupType.Ignore;
			currentModelObjectOverride = null;
			for (int i = 0; i < bossDropsByTier.Length; i++)
			{
				bossDropsByTier[i] = null;
			}
		}

		private static void DoppelgangerInvasionManager_OnCharacterDeathGlobal(orig_OnCharacterDeathGlobal orig, DoppelgangerInvasionManager self, DamageReport damageReport)
		{
			rng = self.treasureRng;
			dropTable = self.dropTable;
			nextPickup = PickupType.DoppelgangerDropTable;
			orig.Invoke(self, damageReport);
			rng = null;
			nextPickup = PickupType.Ignore;
			dropTable = null;
			currentModelObjectOverride = null;
		}

		private static void GlobalEventManager_OnCharacterDeath(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
		{
			if ((Object)(object)damageReport.attackerMaster == (Object)null)
			{
				orig.Invoke(self, damageReport);
				return;
			}
			CharacterMaster val = damageReport.attackerOwnerMaster ?? damageReport.attackerMaster;
			if (val.inventory.GetItemCount(Items.ResetChests) > 0 && (damageReport.victimBody.isChampion || damageReport.victimBody.isElite))
			{
				rng = Run.instance.runRNG;
				dropTable = CommonAssets.dtSonorousEchoPath;
				nextPickup = PickupType.BasicDropTable;
			}
			orig.Invoke(self, damageReport);
			rng = null;
			dropTable = null;
			nextPickup = PickupType.Ignore;
			currentModelObjectOverride = null;
		}

		private static void PickupDropletController_CreatePickupDroplet_PickupIndex_Vector3_Vector3(orig_CreatePickupDroplet_PickupIndex_Vector3_Vector3 orig, PickupIndex pickupIndex, Vector3 position, Vector3 velocity)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_004a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			switch (nextPickup)
			{
			case PickupType.Ignore:
				orig.Invoke(pickupIndex, position, velocity);
				break;
			case PickupType.NoDropTable:
				PickupDropletController.CreatePickupDroplet(CreatePickupInfo_NoDropTable(pickupIndex, position), position, velocity);
				break;
			case PickupType.BasicDropTable:
				PickupDropletController.CreatePickupDroplet(CreatePickupInfo_BasicPickupDropTable(pickupIndex, position), position, velocity);
				break;
			case PickupType.BossDropTable:
				PickupDropletController.CreatePickupDroplet(CreatePickupInfo_BossDropTable(pickupIndex, position), position, velocity);
				break;
			case PickupType.DoppelgangerDropTable:
				PickupDropletController.CreatePickupDroplet(CreatePickupInfo_DoppelGangerDropTable(pickupIndex, position), position, velocity);
				break;
			}
		}

		private static void PickupDropletController_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
		{
			//IL_0001: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0050: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_006b: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Invalid comparison between Unknown and I4
			//IL_00ae: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (pickupInfo.pickerOptions != null && pickupInfo.pickerOptions.Length != 0)
			{
				orig.Invoke(pickupInfo, position, velocity);
				return;
			}
			switch (nextPickup)
			{
			case PickupType.NoDropTable:
			{
				CreatePickupInfo val = CreatePickupInfo_NoDropTable(((CreatePickupInfo)(ref pickupInfo)).pickupIndex, pickupInfo.position);
				val.chest = pickupInfo.chest;
				val.artifactFlag = pickupInfo.artifactFlag;
				pickupInfo = val;
				break;
			}
			case PickupType.BasicDropTable:
			{
				CreatePickupInfo val = CreatePickupInfo_BasicPickupDropTable(((CreatePickupInfo)(ref pickupInfo)).pickupIndex, pickupInfo.position);
				val.chest = pickupInfo.chest;
				if ((int)pickupInfo.artifactFlag > 0)
				{
					val.artifactFlag = pickupInfo.artifactFlag;
				}
				pickupInfo = val;
				break;
			}
			}
			orig.Invoke(pickupInfo, position, velocity);
		}

		private static CreatePickupInfo CreatePickupInfo_NoDropTable(PickupIndex pickupIndex, Vector3 position)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			Log.LogInfo("Creating pickup without drop table");
			CreatePickupInfo val = default(CreatePickupInfo);
			val.position = position;
			val.rotation = Quaternion.identity;
			((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
			CreatePickupInfo result = val;
			int tier = GetTier(pickupIndex);
			PickupIndex[] array = null;
			PickupIndex[] array2 = null;
			array2 = GetUniqueItemsOfSameTier(Settings.GetChoiceCountByTier(tier) - 1, pickupIndex, rng);
			int num = array2.Length;
			if (num == 0)
			{
				return result;
			}
			array = (PickupIndex[])(object)new PickupIndex[num + 1];
			array[0] = pickupIndex;
			for (int i = 0; i < num; i++)
			{
				array[i + 1] = array2[i];
			}
			result.pickerOptions = PickupPickerController.GenerateOptionsFromArray(array);
			result.prefabOverride = ((array.Length > 3) ? commandCubePrefab : voidPotentialPrefab);
			return result;
		}

		private static CreatePickupInfo CreatePickupInfo_BasicPickupDropTable(PickupIndex pickupIndex, Vector3 position)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			Log.LogInfo("Creating pickup from basic drop table");
			CreatePickupInfo val = default(CreatePickupInfo);
			val.position = position;
			val.rotation = Quaternion.identity;
			((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
			CreatePickupInfo result = val;
			if ((Object)(object)dropTable == (Object)null)
			{
				Log.LogInfo("The droptable is null! This is usually the result of an error.");
				rng = null;
				return result;
			}
			int tier = GetTier(pickupIndex);
			PickupIndex[] array = null;
			PickupIndex[] array2 = null;
			int num = 0;
			if ((Settings.AnyTierMode.Value && tier <= 6) || (Settings.AnyTierModeVoid.Value && tier >= 7))
			{
				WeightedSelection<PickupIndex> fieldValue = Reflection.GetFieldValue<WeightedSelection<PickupIndex>>((object)(BasicPickupDropTable)dropTable, "selector");
				for (int i = 0; i < fieldValue.Count; i++)
				{
					if (fieldValue.GetChoice(i).value == pickupIndex)
					{
						fieldValue.RemoveChoice(i);
						i--;
					}
				}
				num = Mathf.Min((tier <= 6) ? (Settings.AnyTierModeChoiceCount.Value - 1) : (Settings.AnyTierModeVoidChoiceCount.Value - 1), fieldValue.Count);
				if (num == 0)
				{
					return result;
				}
				array = (PickupIndex[])(object)new PickupIndex[num + 1];
				array2 = dropTable.GenerateUniqueDrops(num, rng);
			}
			else if (tier == 6)
			{
				array2 = GetUniqueItemsOfSameTier(Settings.GetChoiceCountByTier(tier) - 1, pickupIndex, rng);
				num = array2.Length;
				if (num == 0)
				{
					return result;
				}
				array = (PickupIndex[])(object)new PickupIndex[num + 1];
			}
			else
			{
				dropTable.canDropBeReplaced = false;
				WeightedSelection<PickupIndex> fieldValue2 = Reflection.GetFieldValue<WeightedSelection<PickupIndex>>((object)(BasicPickupDropTable)dropTable, "selector");
				for (int j = 0; j < fieldValue2.Count; j++)
				{
					if (GetTier(fieldValue2.GetChoice(j).value) != tier || fieldValue2.GetChoice(j).value == pickupIndex)
					{
						fieldValue2.RemoveChoice(j);
						j--;
					}
				}
				num = Mathf.Min(Settings.GetChoiceCountByTier(tier) - 1, fieldValue2.Count);
				if (num == 0)
				{
					return result;
				}
				array = (PickupIndex[])(object)new PickupIndex[num + 1];
				array2 = dropTable.GenerateUniqueDrops(num, rng);
				dropTable.canDropBeReplaced = true;
				Reflection.InvokeMethod((object)dropTable, "Regenerate", new object[1] { Run.instance });
			}
			array[0] = pickupIndex;
			for (int k = 0; k < num; k++)
			{
				array[k + 1] = array2[k];
			}
			result.pickerOptions = PickupPickerController.GenerateOptionsFromArray(array);
			result.prefabOverride = ((array.Length > 3) ? commandCubePrefab : voidPotentialPrefab);
			return result;
		}

		private static CreatePickupInfo CreatePickupInfo_BossDropTable(PickupIndex pickupIndex, Vector3 position)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			Log.LogInfo("Creating pickup from boss drop table");
			CreatePickupInfo val = default(CreatePickupInfo);
			val.position = position;
			val.rotation = Quaternion.identity;
			((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
			CreatePickupInfo result = val;
			int tier = GetTier(pickupIndex);
			PickupIndex[] array = null;
			int num = 0;
			if (tier == 6)
			{
				PickupIndex[] uniqueItemsOfSameTier = GetUniqueItemsOfSameTier(Settings.GetChoiceCountByTier(tier) - 1, pickupIndex, rng);
				if (uniqueItemsOfSameTier == null || uniqueItemsOfSameTier.Length == 0)
				{
					return result;
				}
				num = uniqueItemsOfSameTier.Length;
				array = (PickupIndex[])(object)new PickupIndex[num + 1];
				array[0] = pickupIndex;
				for (int i = 0; i < num; i++)
				{
					array[i + 1] = uniqueItemsOfSameTier[i];
				}
			}
			else
			{
				if (bossDropsByTier[tier - 1] == null)
				{
					bossDropsByTier[tier - 1] = GetUniqueItemsOfSameTier(Settings.GetChoiceCountByTier(tier) - 1, pickupIndex, rng);
				}
				if (bossDropsByTier[tier - 1].Length == 0)
				{
					return result;
				}
				num = bossDropsByTier[tier - 1].Length;
				array = (PickupIndex[])(object)new PickupIndex[num + 1];
				array[0] = pickupIndex;
				for (int j = 0; j < num; j++)
				{
					array[j + 1] = bossDropsByTier[tier - 1][j];
				}
			}
			result.pickerOptions = PickupPickerController.GenerateOptionsFromArray(array);
			result.prefabOverride = ((array.Length > 3) ? commandCubePrefab : voidPotentialPrefab);
			return result;
		}

		private static CreatePickupInfo CreatePickupInfo_DoppelGangerDropTable(PickupIndex pickupIndex, Vector3 position)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			Log.LogInfo("Creating pickup from doppelganger drop table");
			CreatePickupInfo val = default(CreatePickupInfo);
			val.position = position;
			val.rotation = Quaternion.identity;
			((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
			CreatePickupInfo result = val;
			if ((Object)(object)dropTable == (Object)null)
			{
				Log.LogInfo("The droptable is null! This is usually the result of an error.");
				rng = null;
				return result;
			}
			PickupIndex[] array = null;
			PickupIndex[] array2 = null;
			int num = 0;
			WeightedSelection<PickupIndex> fieldValue = Reflection.GetFieldValue<WeightedSelection<PickupIndex>>((object)(DoppelgangerDropTable)dropTable, "selector");
			for (int i = 0; i < fieldValue.Count; i++)
			{
				if (fieldValue.GetChoice(i).value == pickupIndex)
				{
					fieldValue.RemoveChoice(i);
					i--;
				}
			}
			num = Mathf.Min(Settings.DoppelgangerChoiceCount.Value - 1, fieldValue.Count);
			if (num == 0)
			{
				return result;
			}
			array = (PickupIndex[])(object)new PickupIndex[num + 1];
			array2 = dropTable.GenerateUniqueDrops(num, rng);
			Reflection.InvokeMethod((object)dropTable, "Regenerate", new object[1] { Run.instance });
			array[0] = pickupIndex;
			for (int j = 0; j < num; j++)
			{
				array[j + 1] = array2[j];
			}
			result.pickerOptions = PickupPickerController.GenerateOptionsFromArray(array);
			result.prefabOverride = ((array.Length > 3) ? commandCubePrefab : voidPotentialPrefab);
			return result;
		}

		private static int GetTier(PickupIndex pickupIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected I4, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			ItemTier itemTier = PickupCatalog.GetPickupDef(pickupIndex).itemTier;
			ItemTier val = itemTier;
			switch ((int)val)
			{
			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;
			default:
				if (PickupCatalog.GetPickupDef(pickupIndex).isLunar)
				{
					return 6;
				}
				return 4;
			}
		}

		private static PickupIndex[] GetUniqueItemsOfSameTier(int num, PickupIndex pickupIndex, Xoroshiro128Plus rng)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			List<PickupIndex> list = null;
			switch (GetTier(pickupIndex))
			{
			case 1:
				list = Run.instance.availableTier1DropList;
				break;
			case 2:
				list = Run.instance.availableTier2DropList;
				break;
			case 3:
				list = Run.instance.availableTier3DropList;
				break;
			case 4:
				list = Run.instance.availableEquipmentDropList;
				break;
			case 5:
				list = Run.instance.availableBossDropList;
				break;
			case 6:
				list = Run.instance.availableLunarCombinedDropList;
				break;
			case 7:
				list = Run.instance.availableVoidTier1DropList;
				break;
			case 8:
				list = Run.instance.availableVoidTier2DropList;
				break;
			case 9:
				list = Run.instance.availableVoidTier3DropList;
				break;
			case 10:
				list = Run.instance.availableVoidBossDropList;
				break;
			}
			WeightedSelection<PickupIndex> val = new WeightedSelection<PickupIndex>(8);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i] != pickupIndex)
				{
					val.AddChoice(list[i], 1f);
				}
			}
			return Reflection.InvokeMethod<PickupIndex[]>(typeof(PickupDropTable), "GenerateUniqueDropsFromWeightedSelection", new object[3] { num, rng, val });
		}
	}
	public static class Asset
	{
		public static AssetBundle AssetBundle;

		public const string bundleName = "aopassetbundle";

		public static string AssetBundlePath => ArtifactOfPotential.PInfo.Location.Replace("ArtifactOfPotential.dll", "aopassetbundle");

		public static void Init()
		{
			AssetBundle = AssetBundle.LoadFromFile(AssetBundlePath);
			if ((Object)(object)AssetBundle == (Object)null)
			{
				Log.LogInfo("Failed to load AssetBundle!");
			}
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void LogDebug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			_logSource.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class Settings
	{
		public static ConfigEntry<bool> AnyTierMode;

		public static ConfigEntry<int> AnyTierModeChoiceCount;

		public static ConfigEntry<bool> AnyTierModeVoid;

		public static ConfigEntry<int> AnyTierModeVoidChoiceCount;

		public static ConfigEntry<bool> ChestsAffected;

		public static ConfigEntry<bool> ShrineOfChanceAffected;

		public static ConfigEntry<bool> HiddenMultishopsAffected;

		public static ConfigEntry<bool> MultishopsAffected;

		public static ConfigEntry<bool> PrintersAffected;

		public static ConfigEntry<bool> ShopsAffected;

		public static ConfigEntry<bool> BossAffected;

		public static ConfigEntry<bool> SonorousWhispersAffected;

		public static ConfigEntry<bool> SacrificeAffected;

		public static ConfigEntry<int> DoppelgangerChoiceCount;

		public static ConfigEntry<int> Tier1ChoiceCount;

		public static ConfigEntry<int> Tier2ChoiceCount;

		public static ConfigEntry<int> Tier3ChoiceCount;

		public static ConfigEntry<int> EquipmentChoiceCount;

		public static ConfigEntry<int> BossChoiceCount;

		public static ConfigEntry<int> LunarChoiceCount;

		public static ConfigEntry<int> Void1ChoiceCount;

		public static ConfigEntry<int> Void2ChoiceCount;

		public static ConfigEntry<int> Void3ChoiceCount;

		public static ConfigEntry<int> VoidBossChoiceCount;

		public static int GetChoiceCountByTier(int tier)
		{
			return tier switch
			{
				1 => Tier1ChoiceCount.Value, 
				2 => Tier2ChoiceCount.Value, 
				3 => Tier3ChoiceCount.Value, 
				4 => EquipmentChoiceCount.Value, 
				5 => BossChoiceCount.Value, 
				6 => LunarChoiceCount.Value, 
				7 => Void1ChoiceCount.Value, 
				8 => Void2ChoiceCount.Value, 
				9 => Void3ChoiceCount.Value, 
				10 => VoidBossChoiceCount.Value, 
				_ => 1, 
			};
		}
	}
}