Decompiled source of Instance Based Loot Fixed v2.4.0

InstanceLootPlugin.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.AurelioniteHeart;
using EntityStates.FalseSonBoss;
using EntityStates.Geode;
using EntityStates.Missions.GeodeSecretMission;
using EntityStates.NkuhanaChest;
using EntityStates.Reaper;
using EntityStates.SolusHeart.Death;
using EntityStates.VoidCamp;
using EntityStates.Wake;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.EntityStates.AurelioniteHeart;
using On.EntityStates.FalseSonBoss;
using On.EntityStates.Geode;
using On.EntityStates.Missions.GeodeSecretMission;
using On.EntityStates.NkuhanaChest;
using On.EntityStates.Reaper;
using On.EntityStates.SolusHeart.Death;
using On.EntityStates.VoidCamp;
using On.EntityStates.Wake;
using On.RoR2;
using On.RoR2.Artifacts;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InstanceLootPlugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e1b8de176acd97688fa3ab86781f2cb6d7a0a62f")]
[assembly: AssemblyProduct("InstanceLootPlugin")]
[assembly: AssemblyTitle("InstanceLootPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 InstanceLootPlugin
{
	public class DropRateManager
	{
		private ConfigEntry<bool> EnableBadLuckProtection;

		private ConfigEntry<bool> EnableSwarmsScaling;

		private ConfigEntry<float> DropChanceMultiplier;

		private ConfigEntry<float> BaseDropChance;

		private ConfigEntry<float> MinimumDropChance;

		public DropRateManager(ConfigEntry<bool> enableBadLuckProtection, ConfigEntry<bool> enableSwarmsScaling, ConfigEntry<float> dropChanceMultiplier, ConfigEntry<float> baseDropChance, ConfigEntry<float> minimumDropChance)
		{
			EnableBadLuckProtection = enableBadLuckProtection;
			EnableSwarmsScaling = enableSwarmsScaling;
			DropChanceMultiplier = dropChanceMultiplier;
			BaseDropChance = baseDropChance;
			MinimumDropChance = minimumDropChance;
		}

		public float GetBaseDropChance(bool scaleByPlayerCount, int playerCount)
		{
			float num = BaseDropChance.Value * DropChanceMultiplier.Value;
			if (!scaleByPlayerCount)
			{
				return num;
			}
			return Math.Max(num / (float)Math.Max(1, playerCount), MinimumDropChance.Value);
		}

		public float ComputeDropChance(bool isSwarmEnabled, float nativeDropChance, float nativeBaseDropChance, float dropChance)
		{
			if (nativeBaseDropChance <= 0f)
			{
				return nativeDropChance;
			}
			float num = ((!(EnableSwarmsScaling.Value && isSwarmEnabled) || nativeDropChance == 0f) ? nativeDropChance : ((nativeDropChance - nativeBaseDropChance) * 0.6f + nativeBaseDropChance));
			float num2 = nativeBaseDropChance / 5f;
			float num3 = num / nativeBaseDropChance;
			return dropChance * num2 * num3;
		}

		public bool NeedsBadLuckProtection(float actualDropChance, float time)
		{
			if (EnableBadLuckProtection.Value && DropRateTracker.cumulativeDropChance >= 100f && actualDropChance > 0f)
			{
				bool num = DropRateTracker.expectedItems > (float)DropRateTracker.totalItemDrops;
				float num2 = (float)DropRateTracker.totalItemDrops / (time / 60f);
				if (!num)
				{
					return (double)num2 < 0.8;
				}
				return true;
			}
			return false;
		}

		public float GetBadLuckProtectedDropChance(float dropChance)
		{
			float num = DropRateTracker.cumulativeDropChance - 100f;
			float num2 = Math.Min(dropChance + num, 90f);
			Log.Debug($"Bad Luck Protection triggered! ({dropChance}% => {num2}%)");
			return num2;
		}
	}
	public static class DropRateTracker
	{
		private static Dictionary<float, long> DropRateReport = new Dictionary<float, long>();

		public static long totalItemDrops { get; private set; } = 0L;

		public static float cumulativeDropChance { get; private set; } = 0f;

		public static float expectedItems { get; private set; } = 0f;

		public static void ResetTracker()
		{
			DropRateReport = new Dictionary<float, long>();
			totalItemDrops = 0L;
			cumulativeDropChance = 0f;
			expectedItems = 0f;
		}

		public static void RegisterDropOpportunity(float dropChance)
		{
			cumulativeDropChance += dropChance;
			expectedItems += (float)Math.Round(dropChance / 100f, 2);
			if (DropRateReport.TryGetValue(dropChance, out var _))
			{
				DropRateReport[dropChance]++;
			}
			else
			{
				DropRateReport.Add(dropChance, 1L);
			}
		}

		public static void RegisterItemDrop(UniquePickup pickup)
		{
			PickupDef pickupDef = ((PickupIndex)(ref pickup.pickupIndex)).pickupDef;
			if (pickupDef != null && pickupDef.coinValue == 0 && pickupDef.nameToken != "PICKUP_LUNAR_COIN")
			{
				cumulativeDropChance = 0f;
				totalItemDrops++;
			}
		}

		public static void LogReport()
		{
			if (Run.instance == null || !((Behaviour)Run.instance).isActiveAndEnabled)
			{
				return;
			}
			long num = DropRateReport.Values.Aggregate(0L, (long i, long l) => i + l);
			if (num != 0L)
			{
				string text = DropRateReport.Keys.OrderByDescending((float f) => f).Aggregate("Kills by Drop Rate", (string s, float f) => $"{s}\n  {f}%: {DropRateReport[f]} kills");
				float runStopwatch = Run.instance.GetRunStopwatch();
				float num2 = runStopwatch / 60f;
				float num3 = DropRateReport.Keys.Aggregate(0f, (float f, float f1) => f + (float)DropRateReport[f1] * f1) / (float)num;
				Log.Info(string.Concat(string.Concat(string.Concat(string.Concat(string.Concat(string.Concat(string.Concat(string.Concat("------ DROP RATE RUN REPORT -----\n" + $"Stage: {Run.instance.stageClearCount + 1}\n", $"Run Duration: {runStopwatch}s\n"), $"Total kills: {num}\n"), $"Total items: {totalItemDrops}\n"), $"Theoretical Average Drop Rate: {num3}%\n"), $"Actual Average Drop Rate: {(float)totalItemDrops / (float)num * 100f}%\n"), $"Drops per Minute: {Math.Round((float)totalItemDrops / num2, 2)}\n"), text, "\n"), "------ END OF REPORT -----"));
			}
		}
	}
	public class InstancedCommandCube : MonoBehaviour
	{
		public static readonly List<InstancedCommandCube> Instances = new List<InstancedCommandCube>();

		private void OnEnable()
		{
			Instances.Add(this);
		}

		private void OnDisable()
		{
			Instances.Remove(this);
		}

		public static void Create(UniquePickup pickup, Vector3 position)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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)
			GameObject commandCubePrefab = CommandArtifactManager.commandCubePrefab;
			if (!Object.op_Implicit((Object)(object)commandCubePrefab))
			{
				Log.Warning("Command cube prefab is not loaded, can't create instanced cube.");
				return;
			}
			GameObject obj = Object.Instantiate<GameObject>(commandCubePrefab, position, Quaternion.identity);
			obj.AddComponent<InstancedCommandCube>();
			obj.GetComponent<PickupPickerController>().SetOptionsInternal(PickupPickerController.GetOptionsFromPickupState(pickup));
			PickupIndexNetworker component = obj.GetComponent<PickupIndexNetworker>();
			component.NetworkpickupState = pickup;
			if (Object.op_Implicit((Object)(object)component.pickupDisplay))
			{
				component.pickupDisplay.SetPickup(ref pickup, false);
			}
		}
	}
	public class InstancedDropletMarker : MonoBehaviour
	{
		public NetworkConnection owner;

		public bool replacesPlayerPile;
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("programit.InstanceBasedLoot", "InstanceBasedLoot", "2.4.0")]
	public class InstanceLootPlugin : BaseUnityPlugin
	{
		private enum DropSource
		{
			None,
			MonsterKill,
			Other
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction<Scene, Scene> <0>__OnActiveSceneChanged;

			public static hook_GetExpAdjustedDropChancePercent <1>__Util_GetExpAdjustedDropChancePercent;

			public static hook_OnServerCharacterDeath <2>__SacrificeArtifactManager_OnServerCharacterDeath;

			public static hook_DropRewards <3>__BossGroup_DropRewards;

			public static hook_ItemDrop <4>__ChestBehavior_ItemDrop;

			public static hook_ItemDrop <5>__OptionChestBehavior_ItemDrop;

			public static hook_ItemDrop <6>__ScavBackpackBehavior_ItemDrop;

			public static hook_EjectPickupServer <7>__RouletteChestController_EjectPickupServer;

			public static hook_OnEnter <8>__VoidCampDeactivate_OnEnter;

			public static hook_FireBossHunter <9>__EquipmentSlot_FireBossHunter;

			public static hook_RewardAllPlayersPages <10>__DLC4ProgressionController_RewardAllPlayersPages;

			public static hook_HandleSquadDefeatServer <11>__ShrineDeathBehavior_HandleSquadDefeatServer;

			public static hook_OnEnter <12>__NkuhanaChestOpenPageReward_OnEnter;

			public static hook_OnEnter <13>__NkuhanaChestOpenBookReward_OnEnter;

			public static hook_FixedUpdate <14>__AurelioniteHeartActivationState_FixedUpdate;

			public static hook_GiveColossusItem <15>__SkyJumpDeathState_GiveColossusItem;

			public static hook_OnEnter <16>__GeodeShatter_OnEnter;

			public static hook_DropRewards <17>__GeodeSecretMissionRewardState_DropRewards;

			public static hook_DropRewards <18>__HalcyoniteShrineInteractable_DropRewards;

			public static hook_EndRound <19>__ArenaMissionController_EndRound;

			public static hook_DropRewards <20>__InfiniteTowerWaveController_DropRewards;

			public static hook_DropCursedItems <21>__ReaperDeathState_DropCursedItems;

			public static hook_OnEnter <22>__SolusHeartDeath_OnEnter;

			public static hook_OnEnter <23>__WakeDeactivate_OnEnter;

			public static hook_DropShamanRewards <24>__WakeController_DropShamanRewards;

			public static hook_ShutdownShrine <25>__ShrineDreadBehavior_ShutdownShrine;

			public static hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 <26>__PickupDropletController_CreatePickupDroplet;

			public static hook_CreateCommandCube <27>__PickupDropletController_CreateCommandCube;

			public static hook_CreatePickup <28>__PickupDropletController_CreatePickup;

			public static hook_AttemptInteraction <29>__Interactor_AttemptInteraction;

			public static hook_SubmitChoice <30>__PickupPickerController_SubmitChoice;

			public static Func<KeyCode, bool> <31>__GetKey;
		}

		public const string PluginGUID = "programit.InstanceBasedLoot";

		public const string PluginAuthor = "programit";

		public const string PluginName = "InstanceBasedLoot";

		public const string PluginVersion = "2.4.0";

		public static float dropChance = 5f;

		private static bool forceDisabled = false;

		private static bool useManualDropRate = false;

		private static DropRateManager dropRateManager;

		private static DropSource currentDropSource = DropSource.None;

		private static bool instanceCurrentDrops;

		private static int keepOneDropletInEvery = 1;

		private static int dropletsForSource;

		private static bool dropForEachPlayer;

		private static Queue<NetworkConnection> dropletOwners;

		private const int KeepOnlyFirst = int.MaxValue;

		private const float PullRadius = 10f;

		private const float CubeHeightAboveGround = 1f;

		private static readonly string[] MenuScenes = new string[7] { "loadingbasic", "intro", "splash", "title", "eclipseworld", "infinitetowerworld", "lobby" };

		private static ConfigEntry<float> DropChanceMultiplier { get; set; }

		private static ConfigEntry<float> MinimumDropChance { get; set; }

		private static ConfigEntry<float> BaseDropChance { get; set; }

		private static ConfigEntry<bool> EnablePlayerDropRateScaling { get; set; }

		private static ConfigEntry<bool> EnableSwarmsScaling { get; set; }

		private static ConfigEntry<bool> EnableBadLuckProtection { get; set; }

		private static ConfigEntry<KeyboardShortcut> PullItemsHotKey { get; set; }

		private static bool IsActive
		{
			get
			{
				if (!forceDisabled)
				{
					return IsCommandEnabled();
				}
				return false;
			}
		}

		public void Awake()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			DropChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DropChanceMultiplier", 1f, "Manipulate drop rate. Use `0.5` to halve or `2` to double.");
			MinimumDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimumDropChance", 1f, "The lowest possible drop chance when player count scaling is active.");
			EnablePlayerDropRateScaling = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnablePlayerBasedDropRateScaling", true, "Enabling this will reduce drop rates to account for shared loot.");
			EnableSwarmsScaling = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableSwarmsScaling", true, "Enabling this will (correctly) reduce drop rates for Artifact of Swarms.");
			EnableBadLuckProtection = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableBadLuckProtection", true, "Enabling this will increase drop rate consistency with low drop rates.");
			PullItemsHotKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "PullItemsHotkey", new KeyboardShortcut((KeyCode)284, Array.Empty<KeyCode>()), "Hotkey to use to pull items to yourself. Modifiers can be added, e.g. `F3 + LeftControl`.");
			BaseDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BaseDropChance", 5f, "Base item drop chance. It is recommended to leave this at the default value.");
			InstancingConfig.Bind(((BaseUnityPlugin)this).Config);
			if (RiskOfOptionsCompat.Enabled)
			{
				RiskOfOptionsCompat.AddPullItemsHotkey(PullItemsHotKey);
			}
			dropRateManager = new DropRateManager(EnableBadLuckProtection, EnableSwarmsScaling, DropChanceMultiplier, BaseDropChance, MinimumDropChance);
			dropChance = dropRateManager.GetBaseDropChance(scaleByPlayerCount: false, 1);
			NetworkingAPI.RegisterMessageType<SpawnInstancedCubeMessage>();
			NetworkingAPI.RegisterMessageType<ClaimInstancedPickupMessage>();
			Log.Info("InstanceLootPlugin loaded");
		}

		private void OnEnable()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b0: 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_00bb: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Expected O, but got Unknown
			//IL_02b0: 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_02bb: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Expected O, but got Unknown
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Expected O, but got Unknown
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Expected O, but got Unknown
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Expected O, but got Unknown
			SceneManager.activeSceneChanged += OnActiveSceneChanged;
			object obj = <>O.<1>__Util_GetExpAdjustedDropChancePercent;
			if (obj == null)
			{
				hook_GetExpAdjustedDropChancePercent val = Util_GetExpAdjustedDropChancePercent;
				<>O.<1>__Util_GetExpAdjustedDropChancePercent = val;
				obj = (object)val;
			}
			Util.GetExpAdjustedDropChancePercent += (hook_GetExpAdjustedDropChancePercent)obj;
			object obj2 = <>O.<2>__SacrificeArtifactManager_OnServerCharacterDeath;
			if (obj2 == null)
			{
				hook_OnServerCharacterDeath val2 = SacrificeArtifactManager_OnServerCharacterDeath;
				<>O.<2>__SacrificeArtifactManager_OnServerCharacterDeath = val2;
				obj2 = (object)val2;
			}
			SacrificeArtifactManager.OnServerCharacterDeath += (hook_OnServerCharacterDeath)obj2;
			object obj3 = <>O.<3>__BossGroup_DropRewards;
			if (obj3 == null)
			{
				hook_DropRewards val3 = BossGroup_DropRewards;
				<>O.<3>__BossGroup_DropRewards = val3;
				obj3 = (object)val3;
			}
			BossGroup.DropRewards += (hook_DropRewards)obj3;
			object obj4 = <>O.<4>__ChestBehavior_ItemDrop;
			if (obj4 == null)
			{
				hook_ItemDrop val4 = ChestBehavior_ItemDrop;
				<>O.<4>__ChestBehavior_ItemDrop = val4;
				obj4 = (object)val4;
			}
			ChestBehavior.ItemDrop += (hook_ItemDrop)obj4;
			object obj5 = <>O.<5>__OptionChestBehavior_ItemDrop;
			if (obj5 == null)
			{
				hook_ItemDrop val5 = OptionChestBehavior_ItemDrop;
				<>O.<5>__OptionChestBehavior_ItemDrop = val5;
				obj5 = (object)val5;
			}
			OptionChestBehavior.ItemDrop += (hook_ItemDrop)obj5;
			object obj6 = <>O.<6>__ScavBackpackBehavior_ItemDrop;
			if (obj6 == null)
			{
				hook_ItemDrop val6 = ScavBackpackBehavior_ItemDrop;
				<>O.<6>__ScavBackpackBehavior_ItemDrop = val6;
				obj6 = (object)val6;
			}
			ScavBackpackBehavior.ItemDrop += (hook_ItemDrop)obj6;
			object obj7 = <>O.<7>__RouletteChestController_EjectPickupServer;
			if (obj7 == null)
			{
				hook_EjectPickupServer val7 = RouletteChestController_EjectPickupServer;
				<>O.<7>__RouletteChestController_EjectPickupServer = val7;
				obj7 = (object)val7;
			}
			RouletteChestController.EjectPickupServer += (hook_EjectPickupServer)obj7;
			object obj8 = <>O.<8>__VoidCampDeactivate_OnEnter;
			if (obj8 == null)
			{
				hook_OnEnter val8 = VoidCampDeactivate_OnEnter;
				<>O.<8>__VoidCampDeactivate_OnEnter = val8;
				obj8 = (object)val8;
			}
			Deactivate.OnEnter += (hook_OnEnter)obj8;
			object obj9 = <>O.<9>__EquipmentSlot_FireBossHunter;
			if (obj9 == null)
			{
				hook_FireBossHunter val9 = EquipmentSlot_FireBossHunter;
				<>O.<9>__EquipmentSlot_FireBossHunter = val9;
				obj9 = (object)val9;
			}
			EquipmentSlot.FireBossHunter += (hook_FireBossHunter)obj9;
			object obj10 = <>O.<10>__DLC4ProgressionController_RewardAllPlayersPages;
			if (obj10 == null)
			{
				hook_RewardAllPlayersPages val10 = DLC4ProgressionController_RewardAllPlayersPages;
				<>O.<10>__DLC4ProgressionController_RewardAllPlayersPages = val10;
				obj10 = (object)val10;
			}
			DLC4ProgressionController.RewardAllPlayersPages += (hook_RewardAllPlayersPages)obj10;
			object obj11 = <>O.<11>__ShrineDeathBehavior_HandleSquadDefeatServer;
			if (obj11 == null)
			{
				hook_HandleSquadDefeatServer val11 = ShrineDeathBehavior_HandleSquadDefeatServer;
				<>O.<11>__ShrineDeathBehavior_HandleSquadDefeatServer = val11;
				obj11 = (object)val11;
			}
			ShrineDeathBehavior.HandleSquadDefeatServer += (hook_HandleSquadDefeatServer)obj11;
			object obj12 = <>O.<12>__NkuhanaChestOpenPageReward_OnEnter;
			if (obj12 == null)
			{
				hook_OnEnter val12 = NkuhanaChestOpenPageReward_OnEnter;
				<>O.<12>__NkuhanaChestOpenPageReward_OnEnter = val12;
				obj12 = (object)val12;
			}
			OpenPageReward.OnEnter += (hook_OnEnter)obj12;
			object obj13 = <>O.<13>__NkuhanaChestOpenBookReward_OnEnter;
			if (obj13 == null)
			{
				hook_OnEnter val13 = NkuhanaChestOpenBookReward_OnEnter;
				<>O.<13>__NkuhanaChestOpenBookReward_OnEnter = val13;
				obj13 = (object)val13;
			}
			OpenBookReward.OnEnter += (hook_OnEnter)obj13;
			object obj14 = <>O.<14>__AurelioniteHeartActivationState_FixedUpdate;
			if (obj14 == null)
			{
				hook_FixedUpdate val14 = AurelioniteHeartActivationState_FixedUpdate;
				<>O.<14>__AurelioniteHeartActivationState_FixedUpdate = val14;
				obj14 = (object)val14;
			}
			AurelioniteHeartActivationState.FixedUpdate += (hook_FixedUpdate)obj14;
			object obj15 = <>O.<15>__SkyJumpDeathState_GiveColossusItem;
			if (obj15 == null)
			{
				hook_GiveColossusItem val15 = SkyJumpDeathState_GiveColossusItem;
				<>O.<15>__SkyJumpDeathState_GiveColossusItem = val15;
				obj15 = (object)val15;
			}
			SkyJumpDeathState.GiveColossusItem += (hook_GiveColossusItem)obj15;
			object obj16 = <>O.<16>__GeodeShatter_OnEnter;
			if (obj16 == null)
			{
				hook_OnEnter val16 = GeodeShatter_OnEnter;
				<>O.<16>__GeodeShatter_OnEnter = val16;
				obj16 = (object)val16;
			}
			GeodeShatter.OnEnter += (hook_OnEnter)obj16;
			object obj17 = <>O.<17>__GeodeSecretMissionRewardState_DropRewards;
			if (obj17 == null)
			{
				hook_DropRewards val17 = GeodeSecretMissionRewardState_DropRewards;
				<>O.<17>__GeodeSecretMissionRewardState_DropRewards = val17;
				obj17 = (object)val17;
			}
			GeodeSecretMissionRewardState.DropRewards += (hook_DropRewards)obj17;
			object obj18 = <>O.<18>__HalcyoniteShrineInteractable_DropRewards;
			if (obj18 == null)
			{
				hook_DropRewards val18 = HalcyoniteShrineInteractable_DropRewards;
				<>O.<18>__HalcyoniteShrineInteractable_DropRewards = val18;
				obj18 = (object)val18;
			}
			HalcyoniteShrineInteractable.DropRewards += (hook_DropRewards)obj18;
			object obj19 = <>O.<19>__ArenaMissionController_EndRound;
			if (obj19 == null)
			{
				hook_EndRound val19 = ArenaMissionController_EndRound;
				<>O.<19>__ArenaMissionController_EndRound = val19;
				obj19 = (object)val19;
			}
			ArenaMissionController.EndRound += (hook_EndRound)obj19;
			object obj20 = <>O.<20>__InfiniteTowerWaveController_DropRewards;
			if (obj20 == null)
			{
				hook_DropRewards val20 = InfiniteTowerWaveController_DropRewards;
				<>O.<20>__InfiniteTowerWaveController_DropRewards = val20;
				obj20 = (object)val20;
			}
			InfiniteTowerWaveController.DropRewards += (hook_DropRewards)obj20;
			object obj21 = <>O.<21>__ReaperDeathState_DropCursedItems;
			if (obj21 == null)
			{
				hook_DropCursedItems val21 = ReaperDeathState_DropCursedItems;
				<>O.<21>__ReaperDeathState_DropCursedItems = val21;
				obj21 = (object)val21;
			}
			DeathState.DropCursedItems += (hook_DropCursedItems)obj21;
			object obj22 = <>O.<22>__SolusHeartDeath_OnEnter;
			if (obj22 == null)
			{
				hook_OnEnter val22 = SolusHeartDeath_OnEnter;
				<>O.<22>__SolusHeartDeath_OnEnter = val22;
				obj22 = (object)val22;
			}
			Death.OnEnter += (hook_OnEnter)obj22;
			object obj23 = <>O.<23>__WakeDeactivate_OnEnter;
			if (obj23 == null)
			{
				hook_OnEnter val23 = WakeDeactivate_OnEnter;
				<>O.<23>__WakeDeactivate_OnEnter = val23;
				obj23 = (object)val23;
			}
			Deactivate.OnEnter += (hook_OnEnter)obj23;
			object obj24 = <>O.<24>__WakeController_DropShamanRewards;
			if (obj24 == null)
			{
				hook_DropShamanRewards val24 = WakeController_DropShamanRewards;
				<>O.<24>__WakeController_DropShamanRewards = val24;
				obj24 = (object)val24;
			}
			WakeController.DropShamanRewards += (hook_DropShamanRewards)obj24;
			object obj25 = <>O.<25>__ShrineDreadBehavior_ShutdownShrine;
			if (obj25 == null)
			{
				hook_ShutdownShrine val25 = ShrineDreadBehavior_ShutdownShrine;
				<>O.<25>__ShrineDreadBehavior_ShutdownShrine = val25;
				obj25 = (object)val25;
			}
			ShrineDreadBehavior.ShutdownShrine += (hook_ShutdownShrine)obj25;
			object obj26 = <>O.<26>__PickupDropletController_CreatePickupDroplet;
			if (obj26 == null)
			{
				hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val26 = PickupDropletController_CreatePickupDroplet;
				<>O.<26>__PickupDropletController_CreatePickupDroplet = val26;
				obj26 = (object)val26;
			}
			PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj26;
			object obj27 = <>O.<27>__PickupDropletController_CreateCommandCube;
			if (obj27 == null)
			{
				hook_CreateCommandCube val27 = PickupDropletController_CreateCommandCube;
				<>O.<27>__PickupDropletController_CreateCommandCube = val27;
				obj27 = (object)val27;
			}
			PickupDropletController.CreateCommandCube += (hook_CreateCommandCube)obj27;
			object obj28 = <>O.<28>__PickupDropletController_CreatePickup;
			if (obj28 == null)
			{
				hook_CreatePickup val28 = PickupDropletController_CreatePickup;
				<>O.<28>__PickupDropletController_CreatePickup = val28;
				obj28 = (object)val28;
			}
			PickupDropletController.CreatePickup += (hook_CreatePickup)obj28;
			object obj29 = <>O.<29>__Interactor_AttemptInteraction;
			if (obj29 == null)
			{
				hook_AttemptInteraction val29 = Interactor_AttemptInteraction;
				<>O.<29>__Interactor_AttemptInteraction = val29;
				obj29 = (object)val29;
			}
			Interactor.AttemptInteraction += (hook_AttemptInteraction)obj29;
			object obj30 = <>O.<30>__PickupPickerController_SubmitChoice;
			if (obj30 == null)
			{
				hook_SubmitChoice val30 = PickupPickerController_SubmitChoice;
				<>O.<30>__PickupPickerController_SubmitChoice = val30;
				obj30 = (object)val30;
			}
			PickupPickerController.SubmitChoice += (hook_SubmitChoice)obj30;
		}

		private void OnDisable()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: 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_005b: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b0: 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_00bb: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Expected O, but got Unknown
			//IL_02b0: 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_02bb: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Expected O, but got Unknown
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Expected O, but got Unknown
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Expected O, but got Unknown
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Expected O, but got Unknown
			SceneManager.activeSceneChanged -= OnActiveSceneChanged;
			object obj = <>O.<1>__Util_GetExpAdjustedDropChancePercent;
			if (obj == null)
			{
				hook_GetExpAdjustedDropChancePercent val = Util_GetExpAdjustedDropChancePercent;
				<>O.<1>__Util_GetExpAdjustedDropChancePercent = val;
				obj = (object)val;
			}
			Util.GetExpAdjustedDropChancePercent -= (hook_GetExpAdjustedDropChancePercent)obj;
			object obj2 = <>O.<2>__SacrificeArtifactManager_OnServerCharacterDeath;
			if (obj2 == null)
			{
				hook_OnServerCharacterDeath val2 = SacrificeArtifactManager_OnServerCharacterDeath;
				<>O.<2>__SacrificeArtifactManager_OnServerCharacterDeath = val2;
				obj2 = (object)val2;
			}
			SacrificeArtifactManager.OnServerCharacterDeath -= (hook_OnServerCharacterDeath)obj2;
			object obj3 = <>O.<3>__BossGroup_DropRewards;
			if (obj3 == null)
			{
				hook_DropRewards val3 = BossGroup_DropRewards;
				<>O.<3>__BossGroup_DropRewards = val3;
				obj3 = (object)val3;
			}
			BossGroup.DropRewards -= (hook_DropRewards)obj3;
			object obj4 = <>O.<4>__ChestBehavior_ItemDrop;
			if (obj4 == null)
			{
				hook_ItemDrop val4 = ChestBehavior_ItemDrop;
				<>O.<4>__ChestBehavior_ItemDrop = val4;
				obj4 = (object)val4;
			}
			ChestBehavior.ItemDrop -= (hook_ItemDrop)obj4;
			object obj5 = <>O.<5>__OptionChestBehavior_ItemDrop;
			if (obj5 == null)
			{
				hook_ItemDrop val5 = OptionChestBehavior_ItemDrop;
				<>O.<5>__OptionChestBehavior_ItemDrop = val5;
				obj5 = (object)val5;
			}
			OptionChestBehavior.ItemDrop -= (hook_ItemDrop)obj5;
			object obj6 = <>O.<6>__ScavBackpackBehavior_ItemDrop;
			if (obj6 == null)
			{
				hook_ItemDrop val6 = ScavBackpackBehavior_ItemDrop;
				<>O.<6>__ScavBackpackBehavior_ItemDrop = val6;
				obj6 = (object)val6;
			}
			ScavBackpackBehavior.ItemDrop -= (hook_ItemDrop)obj6;
			object obj7 = <>O.<7>__RouletteChestController_EjectPickupServer;
			if (obj7 == null)
			{
				hook_EjectPickupServer val7 = RouletteChestController_EjectPickupServer;
				<>O.<7>__RouletteChestController_EjectPickupServer = val7;
				obj7 = (object)val7;
			}
			RouletteChestController.EjectPickupServer -= (hook_EjectPickupServer)obj7;
			object obj8 = <>O.<8>__VoidCampDeactivate_OnEnter;
			if (obj8 == null)
			{
				hook_OnEnter val8 = VoidCampDeactivate_OnEnter;
				<>O.<8>__VoidCampDeactivate_OnEnter = val8;
				obj8 = (object)val8;
			}
			Deactivate.OnEnter -= (hook_OnEnter)obj8;
			object obj9 = <>O.<9>__EquipmentSlot_FireBossHunter;
			if (obj9 == null)
			{
				hook_FireBossHunter val9 = EquipmentSlot_FireBossHunter;
				<>O.<9>__EquipmentSlot_FireBossHunter = val9;
				obj9 = (object)val9;
			}
			EquipmentSlot.FireBossHunter -= (hook_FireBossHunter)obj9;
			object obj10 = <>O.<10>__DLC4ProgressionController_RewardAllPlayersPages;
			if (obj10 == null)
			{
				hook_RewardAllPlayersPages val10 = DLC4ProgressionController_RewardAllPlayersPages;
				<>O.<10>__DLC4ProgressionController_RewardAllPlayersPages = val10;
				obj10 = (object)val10;
			}
			DLC4ProgressionController.RewardAllPlayersPages -= (hook_RewardAllPlayersPages)obj10;
			object obj11 = <>O.<11>__ShrineDeathBehavior_HandleSquadDefeatServer;
			if (obj11 == null)
			{
				hook_HandleSquadDefeatServer val11 = ShrineDeathBehavior_HandleSquadDefeatServer;
				<>O.<11>__ShrineDeathBehavior_HandleSquadDefeatServer = val11;
				obj11 = (object)val11;
			}
			ShrineDeathBehavior.HandleSquadDefeatServer -= (hook_HandleSquadDefeatServer)obj11;
			object obj12 = <>O.<12>__NkuhanaChestOpenPageReward_OnEnter;
			if (obj12 == null)
			{
				hook_OnEnter val12 = NkuhanaChestOpenPageReward_OnEnter;
				<>O.<12>__NkuhanaChestOpenPageReward_OnEnter = val12;
				obj12 = (object)val12;
			}
			OpenPageReward.OnEnter -= (hook_OnEnter)obj12;
			object obj13 = <>O.<13>__NkuhanaChestOpenBookReward_OnEnter;
			if (obj13 == null)
			{
				hook_OnEnter val13 = NkuhanaChestOpenBookReward_OnEnter;
				<>O.<13>__NkuhanaChestOpenBookReward_OnEnter = val13;
				obj13 = (object)val13;
			}
			OpenBookReward.OnEnter -= (hook_OnEnter)obj13;
			object obj14 = <>O.<14>__AurelioniteHeartActivationState_FixedUpdate;
			if (obj14 == null)
			{
				hook_FixedUpdate val14 = AurelioniteHeartActivationState_FixedUpdate;
				<>O.<14>__AurelioniteHeartActivationState_FixedUpdate = val14;
				obj14 = (object)val14;
			}
			AurelioniteHeartActivationState.FixedUpdate -= (hook_FixedUpdate)obj14;
			object obj15 = <>O.<15>__SkyJumpDeathState_GiveColossusItem;
			if (obj15 == null)
			{
				hook_GiveColossusItem val15 = SkyJumpDeathState_GiveColossusItem;
				<>O.<15>__SkyJumpDeathState_GiveColossusItem = val15;
				obj15 = (object)val15;
			}
			SkyJumpDeathState.GiveColossusItem -= (hook_GiveColossusItem)obj15;
			object obj16 = <>O.<16>__GeodeShatter_OnEnter;
			if (obj16 == null)
			{
				hook_OnEnter val16 = GeodeShatter_OnEnter;
				<>O.<16>__GeodeShatter_OnEnter = val16;
				obj16 = (object)val16;
			}
			GeodeShatter.OnEnter -= (hook_OnEnter)obj16;
			object obj17 = <>O.<17>__GeodeSecretMissionRewardState_DropRewards;
			if (obj17 == null)
			{
				hook_DropRewards val17 = GeodeSecretMissionRewardState_DropRewards;
				<>O.<17>__GeodeSecretMissionRewardState_DropRewards = val17;
				obj17 = (object)val17;
			}
			GeodeSecretMissionRewardState.DropRewards -= (hook_DropRewards)obj17;
			object obj18 = <>O.<18>__HalcyoniteShrineInteractable_DropRewards;
			if (obj18 == null)
			{
				hook_DropRewards val18 = HalcyoniteShrineInteractable_DropRewards;
				<>O.<18>__HalcyoniteShrineInteractable_DropRewards = val18;
				obj18 = (object)val18;
			}
			HalcyoniteShrineInteractable.DropRewards -= (hook_DropRewards)obj18;
			object obj19 = <>O.<19>__ArenaMissionController_EndRound;
			if (obj19 == null)
			{
				hook_EndRound val19 = ArenaMissionController_EndRound;
				<>O.<19>__ArenaMissionController_EndRound = val19;
				obj19 = (object)val19;
			}
			ArenaMissionController.EndRound -= (hook_EndRound)obj19;
			object obj20 = <>O.<20>__InfiniteTowerWaveController_DropRewards;
			if (obj20 == null)
			{
				hook_DropRewards val20 = InfiniteTowerWaveController_DropRewards;
				<>O.<20>__InfiniteTowerWaveController_DropRewards = val20;
				obj20 = (object)val20;
			}
			InfiniteTowerWaveController.DropRewards -= (hook_DropRewards)obj20;
			object obj21 = <>O.<21>__ReaperDeathState_DropCursedItems;
			if (obj21 == null)
			{
				hook_DropCursedItems val21 = ReaperDeathState_DropCursedItems;
				<>O.<21>__ReaperDeathState_DropCursedItems = val21;
				obj21 = (object)val21;
			}
			DeathState.DropCursedItems -= (hook_DropCursedItems)obj21;
			object obj22 = <>O.<22>__SolusHeartDeath_OnEnter;
			if (obj22 == null)
			{
				hook_OnEnter val22 = SolusHeartDeath_OnEnter;
				<>O.<22>__SolusHeartDeath_OnEnter = val22;
				obj22 = (object)val22;
			}
			Death.OnEnter -= (hook_OnEnter)obj22;
			object obj23 = <>O.<23>__WakeDeactivate_OnEnter;
			if (obj23 == null)
			{
				hook_OnEnter val23 = WakeDeactivate_OnEnter;
				<>O.<23>__WakeDeactivate_OnEnter = val23;
				obj23 = (object)val23;
			}
			Deactivate.OnEnter -= (hook_OnEnter)obj23;
			object obj24 = <>O.<24>__WakeController_DropShamanRewards;
			if (obj24 == null)
			{
				hook_DropShamanRewards val24 = WakeController_DropShamanRewards;
				<>O.<24>__WakeController_DropShamanRewards = val24;
				obj24 = (object)val24;
			}
			WakeController.DropShamanRewards -= (hook_DropShamanRewards)obj24;
			object obj25 = <>O.<25>__ShrineDreadBehavior_ShutdownShrine;
			if (obj25 == null)
			{
				hook_ShutdownShrine val25 = ShrineDreadBehavior_ShutdownShrine;
				<>O.<25>__ShrineDreadBehavior_ShutdownShrine = val25;
				obj25 = (object)val25;
			}
			ShrineDreadBehavior.ShutdownShrine -= (hook_ShutdownShrine)obj25;
			object obj26 = <>O.<26>__PickupDropletController_CreatePickupDroplet;
			if (obj26 == null)
			{
				hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val26 = PickupDropletController_CreatePickupDroplet;
				<>O.<26>__PickupDropletController_CreatePickupDroplet = val26;
				obj26 = (object)val26;
			}
			PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 -= (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj26;
			object obj27 = <>O.<27>__PickupDropletController_CreateCommandCube;
			if (obj27 == null)
			{
				hook_CreateCommandCube val27 = PickupDropletController_CreateCommandCube;
				<>O.<27>__PickupDropletController_CreateCommandCube = val27;
				obj27 = (object)val27;
			}
			PickupDropletController.CreateCommandCube -= (hook_CreateCommandCube)obj27;
			object obj28 = <>O.<28>__PickupDropletController_CreatePickup;
			if (obj28 == null)
			{
				hook_CreatePickup val28 = PickupDropletController_CreatePickup;
				<>O.<28>__PickupDropletController_CreatePickup = val28;
				obj28 = (object)val28;
			}
			PickupDropletController.CreatePickup -= (hook_CreatePickup)obj28;
			object obj29 = <>O.<29>__Interactor_AttemptInteraction;
			if (obj29 == null)
			{
				hook_AttemptInteraction val29 = Interactor_AttemptInteraction;
				<>O.<29>__Interactor_AttemptInteraction = val29;
				obj29 = (object)val29;
			}
			Interactor.AttemptInteraction -= (hook_AttemptInteraction)obj29;
			object obj30 = <>O.<30>__PickupPickerController_SubmitChoice;
			if (obj30 == null)
			{
				hook_SubmitChoice val30 = PickupPickerController_SubmitChoice;
				<>O.<30>__PickupPickerController_SubmitChoice = val30;
				obj30 = (object)val30;
			}
			PickupPickerController.SubmitChoice -= (hook_SubmitChoice)obj30;
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (!IsHotkeyPressed(PullItemsHotKey.Value))
			{
				return;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				List<Transform> list = FindCommandCubes();
				if (list.Count != 0)
				{
					PullCubesTo(val, list);
				}
			}
		}

		private static List<Transform> FindCommandCubes()
		{
			List<Transform> list = new List<Transform>();
			GameObject commandCubePrefab = CommandArtifactManager.commandCubePrefab;
			if (!Object.op_Implicit((Object)(object)commandCubePrefab))
			{
				return list;
			}
			PickupPickerController[] array = Object.FindObjectsOfType<PickupPickerController>();
			foreach (PickupPickerController val in array)
			{
				if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<InstancedCommandCube>()) || ((Object)val).name.StartsWith(((Object)commandCubePrefab).name))
				{
					list.Add(((Component)val).transform);
				}
			}
			return list;
		}

		private static void PullCubesTo(CharacterBody body, List<Transform> cubes)
		{
			//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_000c: 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_007f: 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_0084: 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)
			//IL_008e: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 corePosition = body.corePosition;
			int num = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask);
			Vector3 val = default(Vector3);
			RaycastHit val2 = default(RaycastHit);
			RaycastHit val4 = default(RaycastHit);
			for (int i = 0; i < cubes.Count; i++)
			{
				float num2 = (float)i * MathF.PI * 2f / (float)cubes.Count;
				((Vector3)(ref val))..ctor(Mathf.Cos(num2), 0f, Mathf.Sin(num2));
				float num3 = 10f;
				if (Physics.Raycast(corePosition, val, ref val2, 10f, num))
				{
					num3 = Mathf.Max(0f, ((RaycastHit)(ref val2)).distance - 1f);
				}
				Vector3 val3 = corePosition + val * num3;
				val3 = ((!Physics.Raycast(val3 + Vector3.up * 2f, Vector3.down, ref val4, 50f, num)) ? (body.footPosition + val * num3 + Vector3.up * 1f) : (((RaycastHit)(ref val4)).point + Vector3.up * 1f));
				cubes[i].position = val3;
			}
		}

		private static void OnActiveSceneChanged(Scene oldScene, Scene newScene)
		{
			bool num = MenuScenes.Contains(((Scene)(ref newScene)).name);
			forceDisabled = ((Scene)(ref newScene)).name == "artifactworld";
			if (num)
			{
				useManualDropRate = false;
				DropRateTracker.ResetTracker();
			}
			if (!useManualDropRate)
			{
				float baseDropChance = dropRateManager.GetBaseDropChance(EnablePlayerDropRateScaling.Value && IsSacrificeEnabled(), GetPlayerCount());
				if (!baseDropChance.Equals(dropChance))
				{
					dropChance = baseDropChance;
					Log.Debug($"Using dropRate of {dropChance}% (base={BaseDropChance.Value}, multiplier={DropChanceMultiplier.Value}, playerCount={GetPlayerCount()}, minimumDropChance={MinimumDropChance.Value})");
				}
			}
		}

		private static void RunWithDropSource(DropSource source, bool instance, Action dropLoot, int keepOneInEvery = 1, bool forEachPlayer = false, Queue<NetworkConnection> owners = null)
		{
			DropSource dropSource = currentDropSource;
			bool flag = instanceCurrentDrops;
			int num = keepOneDropletInEvery;
			int num2 = dropletsForSource;
			bool flag2 = dropForEachPlayer;
			Queue<NetworkConnection> queue = dropletOwners;
			currentDropSource = source;
			instanceCurrentDrops = instance;
			keepOneDropletInEvery = Math.Max(1, keepOneInEvery);
			dropletsForSource = 0;
			dropForEachPlayer = forEachPlayer;
			dropletOwners = owners;
			try
			{
				dropLoot();
			}
			finally
			{
				currentDropSource = dropSource;
				instanceCurrentDrops = flag;
				keepOneDropletInEvery = num;
				dropletsForSource = num2;
				dropForEachPlayer = flag2;
				dropletOwners = queue;
			}
		}

		private static void RunForPlayerPile(bool instance, Action dropLoot)
		{
			int keepOneInEvery = ((!Object.op_Implicit((Object)(object)Run.instance)) ? 1 : Run.instance.participatingPlayerCount);
			RunWithDropSource(DropSource.Other, instance, dropLoot, keepOneInEvery);
		}

		private static void SacrificeArtifactManager_OnServerCharacterDeath(orig_OnServerCharacterDeath orig, DamageReport damageReport)
		{
			RunWithDropSource(DropSource.MonsterKill, InstancingConfig.MonsterDrops.Value, delegate
			{
				orig.Invoke(damageReport);
			});
		}

		private static void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self)
		{
			bool value = InstancingConfig.BossRewards.Value;
			if (value && EnablePlayerDropRateScaling.Value && IsActive)
			{
				self.scaleRewardsByPlayerCount = false;
			}
			RunWithDropSource(DropSource.Other, value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void ChestBehavior_ItemDrop(orig_ItemDrop orig, ChestBehavior self)
		{
			RunWithDropSource(DropSource.Other, InstancingConfig.ShouldInstance(self), delegate
			{
				orig.Invoke(self);
			});
		}

		private static void OptionChestBehavior_ItemDrop(orig_ItemDrop orig, OptionChestBehavior self)
		{
			RunWithDropSource(DropSource.Other, InstancingConfig.ShouldInstance(self), delegate
			{
				orig.Invoke(self);
			});
		}

		private static void ScavBackpackBehavior_ItemDrop(orig_ItemDrop orig, ScavBackpackBehavior self)
		{
			RunWithDropSource(DropSource.Other, InstancingConfig.ScavengerBags.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void RouletteChestController_EjectPickupServer(orig_EjectPickupServer orig, RouletteChestController self, UniquePickup pickup)
		{
			//IL_0015: 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)
			RunWithDropSource(DropSource.Other, InstancingConfig.AdaptiveChests.Value, delegate
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, pickup);
			});
		}

		private static void VoidCampDeactivate_OnEnter(orig_OnEnter orig, Deactivate self)
		{
			RunWithDropSource(DropSource.Other, InstancingConfig.VoidSeeds.Value, delegate
			{
				orig.Invoke(self);
			}, int.MaxValue);
		}

		private static bool EquipmentSlot_FireBossHunter(orig_FireBossHunter orig, EquipmentSlot self)
		{
			bool fired = false;
			RunWithDropSource(DropSource.Other, InstancingConfig.TrophyHunterDrops.Value, delegate
			{
				fired = orig.Invoke(self);
			});
			return fired;
		}

		private static void DLC4ProgressionController_RewardAllPlayersPages(orig_RewardAllPlayersPages orig, DLC4ProgressionController self, TeamIndex team)
		{
			//IL_0015: 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)
			RunWithDropSource(DropSource.Other, InstancingConfig.BookRewards.Value, delegate
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, team);
			}, 1, forEachPlayer: true);
		}

		private static void ShrineDeathBehavior_HandleSquadDefeatServer(orig_HandleSquadDefeatServer orig, ShrineDeathBehavior self)
		{
			RunWithDropSource(DropSource.Other, InstancingConfig.BookRewards.Value, delegate
			{
				orig.Invoke(self);
			}, int.MaxValue);
		}

		private static void NkuhanaChestOpenPageReward_OnEnter(orig_OnEnter orig, OpenPageReward self)
		{
			RunForPlayerPile(InstancingConfig.BookRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void NkuhanaChestOpenBookReward_OnEnter(orig_OnEnter orig, OpenBookReward self)
		{
			Queue<NetworkConnection> queue = new Queue<NetworkConnection>();
			foreach (TeamComponent teamMember in TeamComponent.GetTeamMembers((TeamIndex)1))
			{
				CharacterBody body = teamMember.body;
				if (Object.op_Implicit((Object)(object)body) && body.isPlayerControlled && Object.op_Implicit((Object)(object)body.inventory) && (Object)(object)body.inventory.keyItem != (Object)(object)KeyItems.CursedBook)
				{
					NetworkConnection connection = GetConnection(body.master);
					if (connection != null)
					{
						queue.Enqueue(connection);
					}
				}
			}
			RunWithDropSource(DropSource.Other, InstancingConfig.BookRewards.Value, delegate
			{
				orig.Invoke(self);
			}, 1, forEachPlayer: false, queue);
		}

		private static void AurelioniteHeartActivationState_FixedUpdate(orig_FixedUpdate orig, AurelioniteHeartActivationState self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void SkyJumpDeathState_GiveColossusItem(orig_GiveColossusItem orig, SkyJumpDeathState self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void GeodeShatter_OnEnter(orig_OnEnter orig, GeodeShatter self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void HalcyoniteShrineInteractable_DropRewards(orig_DropRewards orig, HalcyoniteShrineInteractable self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void ArenaMissionController_EndRound(orig_EndRound orig, ArenaMissionController self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void InfiniteTowerWaveController_DropRewards(orig_DropRewards orig, InfiniteTowerWaveController self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void ReaperDeathState_DropCursedItems(orig_DropCursedItems orig, DeathState self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void SolusHeartDeath_OnEnter(orig_OnEnter orig, Death self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void WakeDeactivate_OnEnter(orig_OnEnter orig, Deactivate self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void WakeController_DropShamanRewards(orig_DropShamanRewards orig, WakeController self, int sacrificesKilled)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self, sacrificesKilled);
			});
		}

		private static void ShrineDreadBehavior_ShutdownShrine(orig_ShutdownShrine orig, ShrineDreadBehavior self)
		{
			RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
			{
				orig.Invoke(self);
			});
		}

		private static void GeodeSecretMissionRewardState_DropRewards(orig_DropRewards orig, GeodeSecretMissionRewardState self)
		{
			if (Object.op_Implicit((Object)(object)((GeodeSecretMissionEntityStates)self).geodeSecretMissionController) && ((GeodeSecretMissionEntityStates)self).geodeSecretMissionController.increaseRewardPerPlayer)
			{
				RunForPlayerPile(InstancingConfig.EventRewards.Value, delegate
				{
					orig.Invoke(self);
				});
			}
			else
			{
				RunWithDropSource(DropSource.Other, InstancingConfig.EventRewards.Value, delegate
				{
					orig.Invoke(self);
				});
			}
		}

		private static void PickupDropletController_CreatePickupDroplet(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (currentDropSource == DropSource.None || !IsActive)
			{
				orig.Invoke(pickupInfo, position, velocity);
				return;
			}
			if (currentDropSource == DropSource.MonsterKill)
			{
				DropRateTracker.RegisterItemDrop(((CreatePickupInfo)(ref pickupInfo)).pickup);
			}
			if (!instanceCurrentDrops)
			{
				orig.Invoke(pickupInfo, position, velocity);
				return;
			}
			int num = dropletsForSource++;
			if (keepOneDropletInEvery > 1 && num % keepOneDropletInEvery != 0)
			{
				return;
			}
			NetworkConnection val = null;
			if (dropletOwners != null)
			{
				if (dropletOwners.Count == 0)
				{
					Log.Warning($"No player left to give {((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex} to, it won't be instanced.");
					orig.Invoke(pickupInfo, position, velocity);
					return;
				}
				val = dropletOwners.Dequeue();
			}
			else if (dropForEachPlayer)
			{
				val = FindPlayerConnectionAt(position);
				if (val == null)
				{
					Log.Warning($"Couldn't find which player {((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex} was dropped for, it won't be instanced.");
					orig.Invoke(pickupInfo, position, velocity);
					return;
				}
			}
			orig.Invoke(pickupInfo, position, velocity);
			List<PickupDropletController> instancesList = InstanceTracker.GetInstancesList<PickupDropletController>();
			if (instancesList.Count > 0 && instancesList[instancesList.Count - 1].pickupState == ((CreatePickupInfo)(ref pickupInfo)).pickup)
			{
				InstancedDropletMarker instancedDropletMarker = ((Component)instancesList[instancesList.Count - 1]).gameObject.AddComponent<InstancedDropletMarker>();
				instancedDropletMarker.owner = val;
				instancedDropletMarker.replacesPlayerPile = keepOneDropletInEvery > 1;
			}
			else
			{
				Log.Warning($"Couldn't find the droplet for {((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex}, it won't be instanced.");
			}
		}

		private static void PickupDropletController_CreateCommandCube(orig_CreateCommandCube orig, PickupDropletController self)
		{
			//IL_0020: 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_003f: 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)
			if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<InstancedDropletMarker>()))
			{
				orig.Invoke(self);
				return;
			}
			Log.Debug($"Instancing CommandCube for {((CreatePickupInfo)(ref self.createPickupInfo)).pickup.pickupIndex}");
			NetMessageExtensions.Send((INetMessage)(object)new SpawnInstancedCubeMessage(((CreatePickupInfo)(ref self.createPickupInfo)).pickup, self.createPickupInfo.position), (NetworkDestination)1);
		}

		private static void PickupDropletController_CreatePickup(orig_CreatePickup orig, PickupDropletController self)
		{
			//IL_001f: 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_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_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)
			InstancedDropletMarker component = ((Component)self).GetComponent<InstancedDropletMarker>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				orig.Invoke(self);
				return;
			}
			SpawnInstancedCubeMessage spawnInstancedCubeMessage = new SpawnInstancedCubeMessage(((CreatePickupInfo)(ref self.createPickupInfo)).pickup, self.createPickupInfo.position);
			if (component.owner != null)
			{
				Log.Debug($"Instancing CommandCube for {((CreatePickupInfo)(ref self.createPickupInfo)).pickup.pickupIndex} for one player");
				NetMessageExtensions.Send((INetMessage)(object)spawnInstancedCubeMessage, component.owner);
			}
			else if (component.replacesPlayerPile)
			{
				Log.Debug($"Instancing CommandCube for {((CreatePickupInfo)(ref self.createPickupInfo)).pickup.pickupIndex}");
				NetMessageExtensions.Send((INetMessage)(object)spawnInstancedCubeMessage, (NetworkDestination)1);
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private static NetworkConnection FindPlayerConnectionAt(Vector3 position)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterBody val = (Object.op_Implicit((Object)(object)instance.master) ? instance.master.GetBody() : null);
				if (Object.op_Implicit((Object)(object)val) && val.corePosition == position)
				{
					return GetConnection(instance.master);
				}
			}
			return null;
		}

		private static NetworkConnection GetConnection(CharacterMaster master)
		{
			PlayerCharacterMasterController val = (Object.op_Implicit((Object)(object)master) ? master.playerCharacterMasterController : null);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.networkUser))
			{
				return null;
			}
			return ((NetworkBehaviour)val.networkUser).connectionToClient;
		}

		private static void Interactor_AttemptInteraction(orig_AttemptInteraction orig, Interactor self, GameObject interactableObject)
		{
			if (!Object.op_Implicit((Object)(object)interactableObject) || !Object.op_Implicit((Object)(object)interactableObject.GetComponent<InstancedCommandCube>()))
			{
				orig.Invoke(self, interactableObject);
				return;
			}
			PickupPickerController component = interactableObject.GetComponent<PickupPickerController>();
			LocalUser localUser = GetLocalUser(self);
			if (Object.op_Implicit((Object)(object)component) && !Object.op_Implicit((Object)(object)component.panelInstance) && localUser != null && Object.op_Implicit((Object)(object)localUser.cameraRigController))
			{
				component.OnDisplayBegin((NetworkUIPromptController)null, localUser, localUser.cameraRigController);
			}
		}

		private static void PickupPickerController_SubmitChoice(orig_SubmitChoice orig, PickupPickerController self, int choiceIndex)
		{
			//IL_0043: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<InstancedCommandCube>()))
			{
				orig.Invoke(self, choiceIndex);
			}
			else if ((uint)choiceIndex < (uint)self.options.Length)
			{
				ref Option reference = ref self.options[choiceIndex];
				if (reference.available)
				{
					Log.Info($"Claiming pickup {reference.pickup.pickupIndex}");
					NetMessageExtensions.Send((INetMessage)(object)new ClaimInstancedPickupMessage(reference.pickup, ((Component)self).transform.position), (NetworkDestination)2);
					self.OnDisplayEnd((NetworkUIPromptController)null, (LocalUser)null, (CameraRigController)null);
					Object.Destroy((Object)(object)((Component)self).gameObject);
				}
			}
		}

		private static float Util_GetExpAdjustedDropChancePercent(orig_GetExpAdjustedDropChancePercent orig, float nativeBaseDropChance, GameObject characterBodyObject)
		{
			float num = orig.Invoke(nativeBaseDropChance, characterBodyObject);
			if (currentDropSource != DropSource.MonsterKill || !IsActive)
			{
				return num;
			}
			float num2 = dropRateManager.ComputeDropChance(IsSwarmEnabled(), num, nativeBaseDropChance, dropChance);
			Log.Debug($"DropChance: original_base={nativeBaseDropChance} original_final={num}; plugin_base={dropChance}; plugin_final={num2} (Character={((Object)characterBodyObject).name})");
			DropRateTracker.RegisterDropOpportunity(num2);
			if (dropRateManager.NeedsBadLuckProtection(num2, Run.instance.GetRunStopwatch()))
			{
				return dropRateManager.GetBadLuckProtectedDropChance(num2);
			}
			return num2;
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCSetDropRate(ConCommandArgs args)
		{
			dropChance = ((ConCommandArgs)(ref args)).GetArgFloat(0);
			useManualDropRate = true;
			Log.Info("Drop rate set to: " + ((ConCommandArgs)(ref args)).GetArgString(0) + "%");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCGetDropRateReport(ConCommandArgs args)
		{
			if (IsActive)
			{
				DropRateTracker.LogReport();
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCSetHotkey(ConCommandArgs args)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			string argString = ((ConCommandArgs)(ref args)).GetArgString(0);
			if (Enum.TryParse<KeyCode>(argString, ignoreCase: true, out KeyCode result))
			{
				PullItemsHotKey.Value = new KeyboardShortcut(result, Array.Empty<KeyCode>());
				Log.Info($"Pull items hotkey set to {result}");
			}
			else
			{
				Log.Warning("Failed to set hotkey to " + argString);
			}
		}

		private static bool IsHotkeyPressed(KeyboardShortcut shortcut)
		{
			//IL_0002: 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)
			if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey))
			{
				return ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
			}
			return false;
		}

		private static LocalUser GetLocalUser(Interactor interactor)
		{
			CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.master) && Object.op_Implicit((Object)(object)component.master.playerCharacterMasterController))
			{
				NetworkUser networkUser = component.master.playerCharacterMasterController.networkUser;
				if (Object.op_Implicit((Object)(object)networkUser) && networkUser.localUser != null)
				{
					return networkUser.localUser;
				}
			}
			return LocalUserManager.GetFirstLocalUser();
		}

		private static bool IsSacrificeEnabled()
		{
			if (RunArtifactManager.instance != null && ((Behaviour)RunArtifactManager.instance).isActiveAndEnabled)
			{
				return RunArtifactManager.instance.IsArtifactEnabled(Artifacts.sacrificeArtifactDef);
			}
			return false;
		}

		private static bool IsCommandEnabled()
		{
			if (RunArtifactManager.instance != null && ((Behaviour)RunArtifactManager.instance).isActiveAndEnabled)
			{
				return RunArtifactManager.instance.IsArtifactEnabled(Artifacts.commandArtifactDef);
			}
			return false;
		}

		private static bool IsSwarmEnabled()
		{
			if (RunArtifactManager.instance != null && ((Behaviour)RunArtifactManager.instance).isActiveAndEnabled)
			{
				return RunArtifactManager.instance.IsArtifactEnabled(Artifacts.swarmsArtifactDef);
			}
			return false;
		}

		private static int GetPlayerCount()
		{
			return PlayerCharacterMasterController.instances.Count((PlayerCharacterMasterController pc) => pc.isConnected);
		}
	}
	internal static class InstancingConfig
	{
		private const string Section = "Instancing";

		public static ConfigEntry<bool> MonsterDrops { get; private set; }

		public static ConfigEntry<bool> BossRewards { get; private set; }

		public static ConfigEntry<bool> Chests { get; private set; }

		public static ConfigEntry<bool> EquipmentBarrels { get; private set; }

		public static ConfigEntry<bool> LunarPods { get; private set; }

		public static ConfigEntry<bool> VoidCradles { get; private set; }

		public static ConfigEntry<bool> AdaptiveChests { get; private set; }

		public static ConfigEntry<bool> ScavengerBags { get; private set; }

		public static ConfigEntry<bool> VoidPotentials { get; private set; }

		public static ConfigEntry<bool> VoidSeeds { get; private set; }

		public static ConfigEntry<bool> Lockboxes { get; private set; }

		public static ConfigEntry<bool> TrophyHunterDrops { get; private set; }

		public static ConfigEntry<bool> BookRewards { get; private set; }

		public static ConfigEntry<bool> EventRewards { get; private set; }

		public static void Bind(ConfigFile config)
		{
			MonsterDrops = config.Bind<bool>("Instancing", "MonsterDrops", true, "Instance items dropped by monsters killed with Artifact of Sacrifice.");
			BossRewards = config.Bind<bool>("Instancing", "BossRewards", true, "Instance teleporter and boss rewards (teleporter bosses, Mithrix, Voidling, Aurelionite, etc.). When instanced with EnablePlayerBasedDropRateScaling on, the game drops one set of rewards and every player gets their own copy. When off, the game drops one shared reward per player like vanilla.");
			Chests = config.Bind<bool>("Instancing", "Chests", true, "Instance regular chests (small, large, legendary and category chests).");
			EquipmentBarrels = config.Bind<bool>("Instancing", "EquipmentBarrels", true, "Instance equipment barrels.");
			LunarPods = config.Bind<bool>("Instancing", "LunarPods", true, "Instance lunar pods.");
			VoidCradles = config.Bind<bool>("Instancing", "VoidCradles", true, "Instance void cradles.");
			AdaptiveChests = config.Bind<bool>("Instancing", "AdaptiveChests", true, "Instance adaptive chests.");
			ScavengerBags = config.Bind<bool>("Instancing", "ScavengerBags", true, "Instance the bags dropped by Scavengers.");
			VoidPotentials = config.Bind<bool>("Instancing", "VoidPotentials", true, "Instance void potentials.");
			VoidSeeds = config.Bind<bool>("Instancing", "VoidSeeds", true, "Instance void seed rewards. When instanced, each player gets one reward. When off, the game drops one shared reward per player like vanilla.");
			Lockboxes = config.Bind<bool>("Instancing", "Lockboxes", false, "Instance Rusted Key and Encrusted Key lockboxes.");
			TrophyHunterDrops = config.Bind<bool>("Instancing", "TrophyHunterDrops", true, "Instance the boss item dropped when Trophy Hunter's Tricorn kills a boss.");
			BookRewards = config.Bind<bool>("Instancing", "BookRewards", true, "Instance N'tormat book and page rewards. When instanced, each player only sees their own book and page. When off, they drop as shared pickups like vanilla.");
			EventRewards = config.Bind<bool>("Instancing", "EventRewards", true, "Instance rewards that the game drops once per player in a pile: Void Fields, Simulacrum waves, Halcyonite shrines, the Aurelionite heart, False Son, geodes and the newer encounter and shrine rewards. When instanced, each player gets one reward. When off, the game drops one shared reward per player like vanilla.");
		}

		public static bool ShouldInstance(ChestBehavior chest)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_0028: 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_003c: 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_005d: Invalid comparison between Unknown and I4
			if (IsLockbox((Component)(object)chest))
			{
				return Lockboxes.Value;
			}
			if ((int)CostType((Component)(object)chest) == 3)
			{
				return LunarPods.Value;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef(chest.currentPickup.pickupIndex);
			if (pickupDef != null && IsVoidTier(pickupDef.itemTier))
			{
				return VoidCradles.Value;
			}
			if (pickupDef != null && (int)pickupDef.equipmentIndex != -1)
			{
				return EquipmentBarrels.Value;
			}
			return Chests.Value;
		}

		public static bool ShouldInstance(OptionChestBehavior chest)
		{
			if (!IsLockbox((Component)(object)chest))
			{
				return VoidPotentials.Value;
			}
			return Lockboxes.Value;
		}

		private static bool IsLockbox(Component chest)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			CostTypeIndex val = CostType(chest);
			if ((int)val != 12)
			{
				return (int)val == 13;
			}
			return true;
		}

		private static CostTypeIndex CostType(Component chest)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			PurchaseInteraction component = chest.GetComponent<PurchaseInteraction>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return (CostTypeIndex)0;
			}
			return component.costType;
		}

		private static bool IsVoidTier(ItemTier tier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			if ((int)tier != 6 && (int)tier != 7 && (int)tier != 8)
			{
				return (int)tier == 9;
			}
			return true;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public struct SpawnInstancedCubeMessage : INetMessage, ISerializableObject
	{
		private UniquePickup pickup;

		private Vector3 position;

		public SpawnInstancedCubeMessage(UniquePickup pickup, Vector3 position)
		{
			//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_0008: 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)
			this.pickup = pickup;
			this.position = position;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(position);
			NetworkExtensions.Write(writer, ref pickup);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0002: 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_000e: 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)
			position = reader.ReadVector3();
			pickup = NetworkExtensions.ReadUniquePickup(reader);
		}

		public void OnReceived()
		{
			//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)
			InstancedCommandCube.Create(pickup, position);
		}
	}
	public struct ClaimInstancedPickupMessage : INetMessage, ISerializableObject
	{
		private UniquePickup pickup;

		private Vector3 position;

		public ClaimInstancedPickupMessage(UniquePickup pickup, Vector3 position)
		{
			//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_0008: 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)
			this.pickup = pickup;
			this.position = position;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(position);
			NetworkExtensions.Write(writer, ref pickup);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0002: 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_000e: 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)
			position = reader.ReadVector3();
			pickup = NetworkExtensions.ReadUniquePickup(reader);
		}

		public void OnReceived()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_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)
			if (NetworkServer.active)
			{
				Log.Debug($"Creating claimed pickup {pickup.pickupIndex}");
				CreatePickupInfo val = default(CreatePickupInfo);
				((CreatePickupInfo)(ref val)).pickup = pickup;
				val.position = position;
				val.rotation = Quaternion.identity;
				GenericPickupController.CreatePickup(ref val);
			}
		}
	}
	internal static class RiskOfOptionsCompat
	{
		public const string PluginGUID = "com.rune580.riskofoptions";

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddPullItemsHotkey(ConfigEntry<KeyboardShortcut> hotkey)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Instance-based loot for Artifact of Sacrifice + Artifact of Command.");
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(hotkey));
		}
	}
}