Decompiled source of BossDropRewardDelay v1.2.0

BossDropRewardDelay.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BossDropRewardDelay;

internal static class BuildInfo
{
	public const string Version = "1.2.0";
}
internal sealed class DropEvent
{
	public bool CommandArtifact;

	public bool CubesAvailable;

	public bool OrbsAvailable;

	public bool GreenAsCommand;

	public bool GreenAsOrbs;

	public Option[] GreenOptions;

	public Option[] BossOptions;

	public readonly List<PickupPickerController> Pickers = new List<PickupPickerController>();

	public readonly HashSet<PickupPickerController> Cubes = new HashSet<PickupPickerController>();

	public readonly List<PickupIndex> ChosenCubeItems = new List<PickupIndex>();

	public readonly List<PickupIndex> ChosenOrbItems = new List<PickupIndex>();

	public List<PickupIndex> ChosenFor(bool isCube)
	{
		if (!isCube)
		{
			return ChosenOrbItems;
		}
		return ChosenCubeItems;
	}
}
internal static class GameAssets
{
	private const string OptionPickupKey = "RoR2/DLC1/OptionPickup/OptionPickup.prefab";

	private const string OptionChestKey = "RoR2/DLC1/OptionChest/OptionChest.prefab";

	private static GameObject optionPickupPrefab;

	private static bool triedToLoad;

	public static GameObject OptionPickupPrefab
	{
		get
		{
			if (Object.op_Implicit((Object)(object)optionPickupPrefab))
			{
				return optionPickupPrefab;
			}
			if (triedToLoad)
			{
				return null;
			}
			triedToLoad = true;
			optionPickupPrefab = LoadAddressable("RoR2/DLC1/OptionPickup/OptionPickup.prefab");
			if (!Object.op_Implicit((Object)(object)optionPickupPrefab))
			{
				GameObject val = LoadAddressable("RoR2/DLC1/OptionChest/OptionChest.prefab");
				OptionChestBehavior val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<OptionChestBehavior>() : null);
				FieldInfo field = typeof(OptionChestBehavior).GetField("pickupPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (Object.op_Implicit((Object)(object)val2) && field != null)
				{
					object? value = field.GetValue(val2);
					optionPickupPrefab = (GameObject)((value is GameObject) ? value : null);
				}
			}
			if (!Object.op_Implicit((Object)(object)optionPickupPrefab))
			{
				Plugin.Log.LogWarning((object)"Could not find the Void Potential orb prefab; Void Potential orb drops are disabled.");
			}
			return optionPickupPrefab;
		}
	}

	public static GameObject CommandCubePrefab => CommandArtifactManager.commandCubePrefab;

	private static GameObject LoadAddressable(string key)
	{
		try
		{
			Type type = Type.GetType("UnityEngine.AddressableAssets.Addressables, Unity.Addressables");
			if (type == null)
			{
				return null;
			}
			MethodInfo methodInfo = type.GetMethods(BindingFlags.Static | BindingFlags.Public).FirstOrDefault((MethodInfo m) => m.Name == "LoadAssetAsync" && m.IsGenericMethodDefinition && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(object));
			if (methodInfo == null)
			{
				return null;
			}
			object obj = methodInfo.MakeGenericMethod(typeof(GameObject)).Invoke(null, new object[1] { key });
			object? obj2 = obj.GetType().GetMethod("WaitForCompletion", BindingFlags.Instance | BindingFlags.Public)?.Invoke(obj, null);
			return (GameObject)((obj2 is GameObject) ? obj2 : null);
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Failed to load '" + key + "': " + ex.GetBaseException().Message));
			return null;
		}
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInIncompatibility("com.DestroyedClone.BossDropRewardDelay")]
[BepInIncompatibility("com.YourName.BossDropDelay")]
[BepInPlugin("com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay", "1.2.0")]
public class Plugin : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3 <>9__29_0;

		public static hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool <>9__29_1;

		public static hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool_bool <>9__29_2;

		public static hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3 <>9__29_3;

		public static hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 <>9__29_4;

		internal void <Awake>b__29_0(orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3 orig, UniquePickup pickup, Vector3 position, Vector3 velocity)
		{
			//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_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)
			//IL_001c: 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_0035: 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_004f: 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)
			<>c__DisplayClass29_0 CS$<>8__locals9 = new <>c__DisplayClass29_0
			{
				orig = orig,
				pickup = pickup,
				position = position,
				velocity = velocity
			};
			if (!Capture(delegate
			{
				//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
				CS$<>8__locals9.orig.Invoke(CS$<>8__locals9.pickup, CS$<>8__locals9.position, CS$<>8__locals9.velocity);
			}, CS$<>8__locals9.pickup.pickupIndex))
			{
				CS$<>8__locals9.orig.Invoke(CS$<>8__locals9.pickup, CS$<>8__locals9.position, CS$<>8__locals9.velocity);
			}
		}

		internal void <Awake>b__29_1(orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool orig, UniquePickup pickup, Vector3 position, Vector3 velocity, bool a)
		{
			//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_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)
			//IL_001c: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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: Unknown result type (might be due to invalid IL or missing references)
			<>c__DisplayClass29_1 CS$<>8__locals11 = new <>c__DisplayClass29_1
			{
				orig = orig,
				pickup = pickup,
				position = position,
				velocity = velocity,
				a = a
			};
			if (!Capture(delegate
			{
				//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
				CS$<>8__locals11.orig.Invoke(CS$<>8__locals11.pickup, CS$<>8__locals11.position, CS$<>8__locals11.velocity, CS$<>8__locals11.a);
			}, CS$<>8__locals11.pickup.pickupIndex))
			{
				CS$<>8__locals11.orig.Invoke(CS$<>8__locals11.pickup, CS$<>8__locals11.position, CS$<>8__locals11.velocity, CS$<>8__locals11.a);
			}
		}

		internal void <Awake>b__29_2(orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool_bool orig, UniquePickup pickup, Vector3 position, Vector3 velocity, bool a, bool b)
		{
			//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_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)
			//IL_001c: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			<>c__DisplayClass29_2 CS$<>8__locals13 = new <>c__DisplayClass29_2
			{
				orig = orig,
				pickup = pickup,
				position = position,
				velocity = velocity,
				a = a,
				b = b
			};
			if (!Capture(delegate
			{
				//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
				CS$<>8__locals13.orig.Invoke(CS$<>8__locals13.pickup, CS$<>8__locals13.position, CS$<>8__locals13.velocity, CS$<>8__locals13.a, CS$<>8__locals13.b);
			}, CS$<>8__locals13.pickup.pickupIndex))
			{
				CS$<>8__locals13.orig.Invoke(CS$<>8__locals13.pickup, CS$<>8__locals13.position, CS$<>8__locals13.velocity, CS$<>8__locals13.a, CS$<>8__locals13.b);
			}
		}

		internal void <Awake>b__29_3(orig_CreatePickupDroplet_PickupIndex_Vector3_Vector3 orig, PickupIndex pickupIndex, Vector3 position, Vector3 velocity)
		{
			//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_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)
			//IL_001c: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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)
			<>c__DisplayClass29_3 CS$<>8__locals9 = new <>c__DisplayClass29_3
			{
				orig = orig,
				pickupIndex = pickupIndex,
				position = position,
				velocity = velocity
			};
			if (!Capture(delegate
			{
				//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
				CS$<>8__locals9.orig.Invoke(CS$<>8__locals9.pickupIndex, CS$<>8__locals9.position, CS$<>8__locals9.velocity);
			}, CS$<>8__locals9.pickupIndex))
			{
				CS$<>8__locals9.orig.Invoke(CS$<>8__locals9.pickupIndex, CS$<>8__locals9.position, CS$<>8__locals9.velocity);
			}
		}

		internal void <Awake>b__29_4(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo info, Vector3 position, Vector3 velocity)
		{
			//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_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)
			//IL_001c: 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_0035: 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_004e: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			<>c__DisplayClass29_4 CS$<>8__locals9 = new <>c__DisplayClass29_4
			{
				orig = orig,
				info = info,
				position = position,
				velocity = velocity
			};
			if (!Capture(delegate
			{
				//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
				CreateInfoDroplet(CS$<>8__locals9.orig, CS$<>8__locals9.info, CS$<>8__locals9.position, CS$<>8__locals9.velocity);
			}, ((CreatePickupInfo)(ref CS$<>8__locals9.info)).pickup.pickupIndex))
			{
				CreateInfoDroplet(CS$<>8__locals9.orig, CS$<>8__locals9.info, CS$<>8__locals9.position, CS$<>8__locals9.velocity);
			}
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass29_0
	{
		public orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3 orig;

		public UniquePickup pickup;

		public Vector3 position;

		public Vector3 velocity;

		internal void <Awake>b__5()
		{
			//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(pickup, position, velocity);
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass29_1
	{
		public orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool orig;

		public UniquePickup pickup;

		public Vector3 position;

		public Vector3 velocity;

		public bool a;

		internal void <Awake>b__6()
		{
			//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(pickup, position, velocity, a);
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass29_2
	{
		public orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool_bool orig;

		public UniquePickup pickup;

		public Vector3 position;

		public Vector3 velocity;

		public bool a;

		public bool b;

		internal void <Awake>b__7()
		{
			//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(pickup, position, velocity, a, b);
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass29_3
	{
		public orig_CreatePickupDroplet_PickupIndex_Vector3_Vector3 orig;

		public PickupIndex pickupIndex;

		public Vector3 position;

		public Vector3 velocity;

		internal void <Awake>b__8()
		{
			//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(pickupIndex, position, velocity);
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass29_4
	{
		public orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig;

		public CreatePickupInfo info;

		public Vector3 position;

		public Vector3 velocity;

		internal void <Awake>b__9()
		{
			//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			CreateInfoDroplet(orig, info, position, velocity);
		}
	}

	public const string ModName = "BossDropRewardDelay";

	public const string FormattedModName = "Boss Drop Reward Delay";

	public const string Author = "Videowiz92";

	public const string OriginalAuthor = "DestroyedClone";

	public const string Guid = "com.Videowiz92.BossDropRewardDelay";

	public const string Version = "1.2.0";

	public static ConfigEntry<float> cfgSpawnDelay;

	public static ConfigEntry<int> cfgBatchSize;

	public static ConfigEntry<bool> cfgAnnounceTotal;

	public static ConfigEntry<float> cfgCommandChance;

	public static ConfigEntry<bool> cfgIncludeBossEssence;

	public static ConfigEntry<bool> cfgSyncCommandItems;

	public static ConfigEntry<float> cfgOrbChance;

	public static ConfigEntry<bool> cfgIncludeBossOrbs;

	public static ConfigEntry<bool> cfgSyncOrbItems;

	internal static ManualLogSource Log;

	private static List<Action> captureQueue;

	private static DropEvent currentEvent;

	private static DropEvent landingEvent;

	private static readonly ConditionalWeakTable<PickupDropletController, DropEvent> dropletEvents = new ConditionalWeakTable<PickupDropletController, DropEvent>();

	private static readonly ConditionalWeakTable<PickupPickerController, DropEvent> pickerEvents = new ConditionalWeakTable<PickupPickerController, DropEvent>();

	private static bool captureHasHalcyonSeed;

	private static PickupIndex halcyonSeedIndex = PickupIndex.none;

	private static bool halcyonSeedLooked;

	private static int eventCounter;

	private static bool inCommandSetup;

	private static Plugin instance;

	public static float SpawnDelay => Mathf.Max(0f, cfgSpawnDelay.Value);

	public static int BatchSize => Math.Max(1, cfgBatchSize.Value);

	public static bool SyncCommandItems => cfgSyncCommandItems.Value;

	public static bool SyncOrbItems => cfgSyncOrbItems.Value;

	private void Awake()
	{
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Expected O, but got Unknown
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Expected O, but got Unknown
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Expected O, but got Unknown
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Expected O, but got Unknown
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Expected O, but got Unknown
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Expected O, but got Unknown
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Expected O, but got Unknown
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Expected O, but got Unknown
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Expected O, but got Unknown
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Expected O, but got Unknown
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Expected O, but got Unknown
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Expected O, but got Unknown
		cfgSpawnDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Delay Between Drops", 0.3f, "The amount of time, in seconds, between each drop.");
		cfgBatchSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Item Batch Size", 1, "The amount of items dropped in each tick");
		Log = ((BaseUnityPlugin)this).Logger;
		instance = this;
		cfgAnnounceTotal = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Announce Item Total", false, "Announce in chat how many items the teleporter dropped in total and how many each player gets.");
		cfgCommandChance = ((BaseUnityPlugin)this).Config.Bind<float>("Command Essence", "Chance To Drop As Command (%)", 0f, new ConfigDescription("Chance that all green items from a teleporter event drop as Command essence (cubes) so players can choose their items. Boss items only join in if \"Include Boss Essence\" is on. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		cfgIncludeBossEssence = ((BaseUnityPlugin)this).Config.Bind<bool>("Command Essence", "Include Boss Essence", false, "When the chance above passes, boss (yellow) items from the teleporter drop as Command essence too. Note that boss essence can offer yellow items that are exclusive to certain bosses.");
		cfgSyncCommandItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Command Essence", "Synchronize Teleporter Essence", true, "When a player picks an item from one of the teleporter's Command cubes, the other cubes of the same kind (green / boss) turn into that item.");
		cfgOrbChance = ((BaseUnityPlugin)this).Config.Bind<float>("Void Potential Orbs", "Chance To Drop As Void Potential Orb (%)", 0f, new ConfigDescription("Chance that all green items from a teleporter event drop as Void Potential orbs (choose 1 of 3). Boss items only join in if \"Include Boss Orbs\" is on. Requires Survivors of the Void to be enabled for the run. Command essence takes priority over orbs. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		cfgIncludeBossOrbs = ((BaseUnityPlugin)this).Config.Bind<bool>("Void Potential Orbs", "Include Boss Orbs", false, "When the chance above passes, boss (yellow) items from the teleporter drop as Void Potential orbs too. Requires Survivors of the Void. Note that boss orbs can offer yellow items that are exclusive to certain bosses.");
		cfgSyncOrbItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Void Potential Orbs", "Synchronize Teleporter Orbs", true, "When a player picks an item from one of the teleporter's Void Potential orbs, the other orbs offering that item turn into that item.");
		BossGroup.DropRewards += new hook_DropRewards(BossGroup_DropRewards);
		PickupDropletController.OnEnable += new hook_OnEnable(PickupDropletController_OnEnable);
		PickupDropletController.CreatePickup += new hook_CreatePickup(PickupDropletController_CreatePickup);
		PickupPickerController.SetOptionsFromPickupForCommandArtifact_UniquePickup += new hook_SetOptionsFromPickupForCommandArtifact_UniquePickup(PickupPicker_SetOptionsForCommand);
		GenericPickupController.CreatePickup += new hook_CreatePickup(GenericPickupController_CreatePickup);
		PickupPickerController.HandlePickupSelected += new hook_HandlePickupSelected(PickupPicker_HandlePickupSelected);
		PickupPickerController.SetOptionsServer += new hook_SetOptionsServer(PickupPicker_SetOptionsServer);
		object obj = <>c.<>9__29_0;
		if (obj == null)
		{
			hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3 val = delegate(orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3 orig, UniquePickup pickup, Vector3 position, Vector3 velocity)
			{
				//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_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)
				//IL_001c: 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_0035: 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_004f: 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)
				if (!Capture(delegate
				{
					//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(pickup, position, velocity);
				}, pickup.pickupIndex))
				{
					orig.Invoke(pickup, position, velocity);
				}
			};
			<>c.<>9__29_0 = val;
			obj = (object)val;
		}
		PickupDropletController.CreatePickupDroplet_UniquePickup_Vector3_Vector3 += (hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3)obj;
		object obj2 = <>c.<>9__29_1;
		if (obj2 == null)
		{
			hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool val2 = delegate(orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool orig, UniquePickup pickup, Vector3 position, Vector3 velocity, bool a)
			{
				//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_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)
				//IL_001c: 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_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: 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: Unknown result type (might be due to invalid IL or missing references)
				if (!Capture(delegate
				{
					//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(pickup, position, velocity, a);
				}, pickup.pickupIndex))
				{
					orig.Invoke(pickup, position, velocity, a);
				}
			};
			<>c.<>9__29_1 = val2;
			obj2 = (object)val2;
		}
		PickupDropletController.CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool += (hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool)obj2;
		object obj3 = <>c.<>9__29_2;
		if (obj3 == null)
		{
			hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool_bool val3 = delegate(orig_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool_bool orig, UniquePickup pickup, Vector3 position, Vector3 velocity, bool a, bool b)
			{
				//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_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)
				//IL_001c: 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_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: 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)
				if (!Capture(delegate
				{
					//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(pickup, position, velocity, a, b);
				}, pickup.pickupIndex))
				{
					orig.Invoke(pickup, position, velocity, a, b);
				}
			};
			<>c.<>9__29_2 = val3;
			obj3 = (object)val3;
		}
		PickupDropletController.CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool_bool += (hook_CreatePickupDroplet_UniquePickup_Vector3_Vector3_bool_bool)obj3;
		object obj4 = <>c.<>9__29_3;
		if (obj4 == null)
		{
			hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3 val4 = delegate(orig_CreatePickupDroplet_PickupIndex_Vector3_Vector3 orig, PickupIndex pickupIndex, Vector3 position, Vector3 velocity)
			{
				//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_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)
				//IL_001c: 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_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: 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 (!Capture(delegate
				{
					//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(pickupIndex, position, velocity);
				}, pickupIndex))
				{
					orig.Invoke(pickupIndex, position, velocity);
				}
			};
			<>c.<>9__29_3 = val4;
			obj4 = (object)val4;
		}
		PickupDropletController.CreatePickupDroplet_PickupIndex_Vector3_Vector3 += (hook_CreatePickupDroplet_PickupIndex_Vector3_Vector3)obj4;
		object obj5 = <>c.<>9__29_4;
		if (obj5 == null)
		{
			hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val5 = delegate(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo info, Vector3 position, Vector3 velocity)
			{
				//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_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)
				//IL_001c: 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_0035: 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_004e: 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_005a: Unknown result type (might be due to invalid IL or missing references)
				if (!Capture(delegate
				{
					//IL_0007: 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_0013: Unknown result type (might be due to invalid IL or missing references)
					CreateInfoDroplet(orig, info, position, velocity);
				}, ((CreatePickupInfo)(ref info)).pickup.pickupIndex))
				{
					CreateInfoDroplet(orig, info, position, velocity);
				}
			};
			<>c.<>9__29_4 = val5;
			obj5 = (object)val5;
		}
		PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj5;
		if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
		{
			ModCompat_RiskOfOptions();
		}
	}

	private static bool Capture(Action spawn, PickupIndex pickupIndex)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		if (captureQueue == null)
		{
			return false;
		}
		captureQueue.Add(spawn);
		if (pickupIndex == HalcyonSeedIndex())
		{
			captureHasHalcyonSeed = true;
		}
		return true;
	}

	private static PickupIndex HalcyonSeedIndex()
	{
		//IL_0027: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Invalid comparison between Unknown and I4
		//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_001c: Unknown result type (might be due to invalid IL or missing references)
		if (!halcyonSeedLooked)
		{
			ItemIndex val = ItemCatalog.FindItemIndex("TitanGoldDuringTP");
			if ((int)val != -1)
			{
				halcyonSeedIndex = PickupCatalog.FindPickupIndex(val);
				halcyonSeedLooked = true;
			}
		}
		return halcyonSeedIndex;
	}

	private void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self)
	{
		if (!NetworkServer.active)
		{
			orig.Invoke(self);
			return;
		}
		List<Action> queue = new List<Action>();
		List<Action> list = captureQueue;
		bool flag = captureHasHalcyonSeed;
		captureQueue = queue;
		captureHasHalcyonSeed = false;
		bool flag2 = false;
		try
		{
			orig.Invoke(self);
		}
		finally
		{
			captureQueue = list;
			flag2 = captureHasHalcyonSeed;
			captureHasHalcyonSeed = flag;
			Release(queue, self, flag2);
		}
	}

	private void Release(List<Action> queue, BossGroup group, bool halcyonSeedEvent)
	{
		if (queue.Count == 0)
		{
			return;
		}
		if (halcyonSeedEvent)
		{
			Log.LogDebug((object)"Halcyon Seed event (Aurelionite): leaving the drops to the game.");
			{
				foreach (Action item in queue)
				{
					try
					{
						item();
					}
					catch (Exception arg)
					{
						((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to spawn a boss reward droplet: {arg}");
					}
				}
				return;
			}
		}
		DropEvent dropEvent = CreateEvent();
		Log.LogDebug((object)(string.Format("Drop event #{0}: {1} items from '{2}' (id {3}), ", ++eventCounter, queue.Count, Object.op_Implicit((Object)(object)group) ? ((Object)group).name : "?", Object.op_Implicit((Object)(object)group) ? ((Object)group).GetInstanceID() : 0) + "green as " + (dropEvent.CommandArtifact ? "artifact cubes" : (dropEvent.GreenAsCommand ? "Command cubes" : (dropEvent.GreenAsOrbs ? "orbs" : "normal items"))) + ", " + $"delay {SpawnDelay:0.##}s, batch {BatchSize}, time {Time.time:0.0}."));
		if (cfgAnnounceTotal.Value)
		{
			AnnounceTotal(queue.Count);
		}
		int batchSize = BatchSize;
		float spawnDelay = SpawnDelay;
		if (spawnDelay <= 0f || queue.Count <= batchSize)
		{
			foreach (Action item2 in queue)
			{
				Invoke(dropEvent, item2);
			}
			return;
		}
		((MonoBehaviour)this).StartCoroutine(DropQueued(dropEvent, queue, batchSize, spawnDelay));
	}

	private static DropEvent CreateEvent()
	{
		DropEvent dropEvent = new DropEvent();
		if (CommandArtifactManager.IsCommandArtifactEnabled)
		{
			dropEvent.CommandArtifact = true;
			return dropEvent;
		}
		dropEvent.CubesAvailable = Object.op_Implicit((Object)(object)GameAssets.CommandCubePrefab);
		dropEvent.OrbsAvailable = IsVoidDlcEnabled() && Object.op_Implicit((Object)(object)GameAssets.OptionPickupPrefab);
		if (RollPercent(cfgCommandChance))
		{
			if (dropEvent.CubesAvailable)
			{
				dropEvent.GreenAsCommand = true;
			}
			else
			{
				Log.LogWarning((object)"Command cube prefab is not loaded; the Command chance was ignored.");
			}
		}
		if (!dropEvent.GreenAsCommand && dropEvent.OrbsAvailable && RollPercent(cfgOrbChance))
		{
			dropEvent.GreenAsOrbs = true;
		}
		return dropEvent;
	}

	private static float SnapPercent(float value)
	{
		return Mathf.Clamp(Mathf.Round(value * 2f) / 2f, 0f, 100f);
	}

	private static bool RollPercent(ConfigEntry<float> entry)
	{
		float num = SnapPercent(entry.Value);
		if (num <= 0f)
		{
			return false;
		}
		if (num >= 100f)
		{
			return true;
		}
		return Random.Range(0f, 100f) < num;
	}

	private static bool IsVoidDlcEnabled()
	{
		if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)DLC1Content.DLC1))
		{
			return Run.instance.IsExpansionEnabled(DLC1Content.DLC1);
		}
		return false;
	}

	private static void AnnounceTotal(int total)
	{
		//IL_005a: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Expected O, but got Unknown
		int num = ((!Object.op_Implicit((Object)(object)Run.instance)) ? 1 : Math.Max(1, Run.instance.participatingPlayerCount));
		string arg = ((float)total / (float)num).ToString("0.##", CultureInfo.InvariantCulture);
		string baseToken = string.Format("<color=#90EE90>Teleporter dropped {0} {1} ({2} per player)</color>", total, (total == 1) ? "item" : "items", arg);
		Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
		{
			baseToken = baseToken,
			paramTokens = new string[0]
		});
	}

	private IEnumerator DropQueued(DropEvent dropEvent, List<Action> queue, int batchSize, float delay)
	{
		Stage startStage = Stage.instance;
		int index = 0;
		while (index < queue.Count)
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || (Object)(object)Stage.instance != (Object)(object)startStage)
			{
				Log.LogDebug((object)$"Drop event stopped early after {index}/{queue.Count} items (stage changed or run ended).");
				yield break;
			}
			for (int num = Math.Min(index + batchSize, queue.Count); index < num; index++)
			{
				Invoke(dropEvent, queue[index]);
			}
			if (index < queue.Count)
			{
				yield return (object)new WaitForSeconds(delay);
			}
		}
		Log.LogDebug((object)$"Drop event finished: {queue.Count} items dropped, time {Time.time:0.0}.");
	}

	private void Invoke(DropEvent dropEvent, Action spawn)
	{
		DropEvent dropEvent2 = currentEvent;
		currentEvent = dropEvent;
		try
		{
			spawn();
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to spawn a boss reward droplet: {arg}");
		}
		finally
		{
			currentEvent = dropEvent2;
		}
	}

	private static void CreateInfoDroplet(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo info, Vector3 position, Vector3 velocity)
	{
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: 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_0017: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Invalid comparison between Unknown and I4
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Invalid comparison between Unknown and I4
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Invalid comparison between Unknown and I4
		DropEvent dropEvent = currentEvent;
		if (dropEvent != null && !dropEvent.CommandArtifact && info.pickerOptions == null && !Object.op_Implicit((Object)(object)info.prefabOverride))
		{
			PickupDef pickupDef = PickupCatalog.GetPickupDef(((CreatePickupInfo)(ref info)).pickup.pickupIndex);
			if (pickupDef != null && ((int)pickupDef.itemTier == 1 || (int)pickupDef.itemTier == 4))
			{
				bool flag = (int)pickupDef.itemTier == 4;
				bool num = dropEvent.GreenAsCommand && (!flag || cfgIncludeBossEssence.Value);
				bool flag2 = dropEvent.GreenAsOrbs && (!flag || cfgIncludeBossOrbs.Value);
				if (num)
				{
					ref PickupArtifactFlag artifactFlag = ref info.artifactFlag;
					artifactFlag = (PickupArtifactFlag)((uint)artifactFlag | 1u);
				}
				else if (flag2)
				{
					ConvertToOrb(dropEvent, ref info, flag);
				}
			}
		}
		orig.Invoke(info, position, velocity);
	}

	private static void ConvertToOrb(DropEvent dropEvent, ref CreatePickupInfo info, bool boss)
	{
		//IL_0017: 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_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)
		Option[] array = (boss ? dropEvent.BossOptions : dropEvent.GreenOptions);
		if (array == null)
		{
			array = BuildOrbOptions(boss, ((CreatePickupInfo)(ref info)).pickup.pickupIndex);
			if (boss)
			{
				dropEvent.BossOptions = array;
			}
			else
			{
				dropEvent.GreenOptions = array;
			}
		}
		if (array != null && array.Length != 0)
		{
			info.pickerOptions = array;
			info.maxOptionCount = 1;
			info.prefabOverride = GameAssets.OptionPickupPrefab;
			((CreatePickupInfo)(ref info)).pickup = new UniquePickup(PickupCatalog.FindPickupIndex((ItemTier)((!boss) ? 1 : 4)));
		}
	}

	private static Option[] BuildOrbOptions(bool boss, PickupIndex rolled)
	{
		//IL_0038: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: 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_0114: 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_0097: 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)
		if (!Object.op_Implicit((Object)(object)Run.instance))
		{
			return null;
		}
		List<PickupIndex> list = (boss ? Run.instance.availableBossDropList : Run.instance.availableTier2DropList);
		List<PickupIndex> list2 = new List<PickupIndex>();
		if (((PickupIndex)(ref rolled)).isValid)
		{
			list2.Add(rolled);
		}
		if (list != null)
		{
			Random rng = new Random();
			foreach (PickupIndex item in list.OrderBy((PickupIndex _) => rng.Next()))
			{
				if (list2.Count >= 3)
				{
					break;
				}
				if (!list2.Contains(item))
				{
					list2.Add(item);
				}
			}
		}
		if (list2.Count == 0)
		{
			return null;
		}
		Option[] array = (Option[])(object)new Option[list2.Count];
		for (int num = 0; num < array.Length; num++)
		{
			array[num] = new Option
			{
				pickup = new UniquePickup(list2[num]),
				available = Run.instance.IsPickupAvailable(list2[num])
			};
		}
		return array;
	}

	private static void PickupDropletController_OnEnable(orig_OnEnable orig, PickupDropletController self)
	{
		orig.Invoke(self);
		if (currentEvent != null)
		{
			dropletEvents.Remove(self);
			dropletEvents.Add(self, currentEvent);
		}
	}

	private static void PickupDropletController_CreatePickup(orig_CreatePickup orig, PickupDropletController self)
	{
		DropEvent dropEvent = landingEvent;
		landingEvent = (dropletEvents.TryGetValue(self, out var value) ? value : null);
		try
		{
			orig.Invoke(self);
		}
		finally
		{
			landingEvent = dropEvent;
		}
	}

	private static void PickupPicker_SetOptionsForCommand(orig_SetOptionsFromPickupForCommandArtifact_UniquePickup orig, PickupPickerController self, UniquePickup pickup)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		bool flag = inCommandSetup;
		inCommandSetup = true;
		try
		{
			orig.Invoke(self, pickup);
		}
		finally
		{
			inCommandSetup = flag;
		}
		if (landingEvent != null)
		{
			RegisterPicker(landingEvent, self, isCube: true);
		}
	}

	private static GenericPickupController GenericPickupController_CreatePickup(orig_CreatePickup orig, ref CreatePickupInfo createPickupInfo)
	{
		GenericPickupController val = orig.Invoke(ref createPickupInfo);
		if (landingEvent != null && Object.op_Implicit((Object)(object)val))
		{
			PickupPickerController componentInChildren = ((Component)val).GetComponentInChildren<PickupPickerController>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				RegisterPicker(landingEvent, componentInChildren, inCommandSetup);
			}
		}
		return val;
	}

	private static void PickupPicker_SetOptionsServer(orig_SetOptionsServer orig, PickupPickerController self, Option[] newOptions)
	{
		orig.Invoke(self, newOptions);
		if (landingEvent != null && Object.op_Implicit((Object)(object)self))
		{
			RegisterPicker(landingEvent, self, inCommandSetup);
		}
	}

	private static bool SyncFor(bool isCube)
	{
		if (!isCube)
		{
			return SyncOrbItems;
		}
		return SyncCommandItems;
	}

	private static void RegisterPicker(DropEvent dropEvent, PickupPickerController picker, bool isCube)
	{
		bool num = !dropEvent.Pickers.Contains(picker);
		if (num)
		{
			Log.LogDebug((object)string.Format("Tracking a {0} of this event ({1} so far).", isCube ? "cube" : "orb", dropEvent.Pickers.Count + 1));
			dropEvent.Pickers.Add(picker);
			pickerEvents.Remove(picker);
			pickerEvents.Add(picker, dropEvent);
		}
		if (isCube)
		{
			dropEvent.Cubes.Add(picker);
		}
		if (num && SyncFor(isCube) && dropEvent.ChosenFor(isCube).Count > 0 && (Object)(object)instance != (Object)null)
		{
			((MonoBehaviour)instance).StartCoroutine(ConvertNextFrame(dropEvent, picker, isCube));
		}
	}

	private static IEnumerator ConvertNextFrame(DropEvent dropEvent, PickupPickerController picker, bool isCube)
	{
		yield return null;
		isCube = dropEvent.Cubes.Contains(picker);
		PickupIndex[] array = dropEvent.ChosenFor(isCube).ToArray();
		foreach (PickupIndex pickupIndex in array)
		{
			if (ConvertPicker(picker, pickupIndex))
			{
				break;
			}
		}
	}

	private static void PickupPicker_HandlePickupSelected(orig_HandlePickupSelected orig, PickupPickerController self, int choiceIndex)
	{
		//IL_0004: 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_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_0067: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		DropEvent value = null;
		UniquePickup val = default(UniquePickup);
		bool flag = false;
		bool flag2 = false;
		if (NetworkServer.active && pickerEvents.TryGetValue(self, out value))
		{
			flag2 = value.Cubes.Contains(self);
			Option[] options = self.options;
			if (SyncFor(flag2) && options != null && choiceIndex >= 0 && choiceIndex < options.Length && options[choiceIndex].available)
			{
				val = options[choiceIndex].pickup;
				flag = true;
			}
		}
		orig.Invoke(self, choiceIndex);
		if (!flag || !Object.op_Implicit((Object)(object)self))
		{
			return;
		}
		List<PickupIndex> list = value.ChosenFor(flag2);
		if (!list.Contains(val.pickupIndex))
		{
			list.Add(val.pickupIndex);
		}
		int num = 0;
		PickupPickerController[] array = value.Pickers.ToArray();
		foreach (PickupPickerController val2 in array)
		{
			if (Object.op_Implicit((Object)(object)val2) && (Object)(object)val2 != (Object)(object)self && value.Cubes.Contains(val2) == flag2 && ConvertPicker(val2, val.pickupIndex))
			{
				num++;
			}
		}
		Log.LogInfo((object)string.Format("Sync: picked item converted {0} other {1} of this event ({2} tracked).", num, flag2 ? "cube(s)" : "orb(s)", value.Pickers.Count));
	}

	private static bool ConvertPicker(PickupPickerController picker, PickupIndex pickupIndex)
	{
		//IL_003b: 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_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)picker))
		{
			return false;
		}
		Option[] options = picker.options;
		if (options == null)
		{
			return false;
		}
		for (int i = 0; i < options.Length; i++)
		{
			if (options[i].available && !(options[i].pickup.pickupIndex != pickupIndex))
			{
				UniquePickup pickup = options[i].pickup;
				picker.CreatePickup(pickup);
				NetworkServer.Destroy(((Component)picker).gameObject);
				return true;
			}
		}
		return false;
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	private void ModCompat_RiskOfOptions()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//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_009a: 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_00b5: Expected O, but got Unknown
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Expected O, but got Unknown
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Expected O, but got Unknown
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Expected O, but got Unknown
		ModSettingsManager.AddOption((BaseOption)new SliderOption(cfgSpawnDelay, new SliderConfig
		{
			min = 0.01f,
			max = 4f,
			FormatString = "{0:0.00}s"
		}), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new IntSliderOption(cfgBatchSize, new IntSliderConfig
		{
			min = 1,
			max = 50
		}), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgAnnounceTotal), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new SliderOption(cfgCommandChance, new SliderConfig
		{
			min = 0f,
			max = 100f,
			FormatString = "{0:0.0}%"
		}), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgIncludeBossEssence), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgSyncCommandItems), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new SliderOption(cfgOrbChance, new SliderConfig
		{
			min = 0f,
			max = 100f,
			FormatString = "{0:0.0}%"
		}), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgIncludeBossOrbs), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(cfgSyncOrbItems), "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		ModSettingsManager.SetModDescription("Adds a short delay between boss drops to prevent lagspikes/crashing at large drop counts. Original mod by DestroyedClone.", "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		Sprite val = LoadIconSprite();
		if ((Object)(object)val != (Object)null)
		{
			ModSettingsManager.SetModIcon(val, "com.Videowiz92.BossDropRewardDelay", "Boss Drop Reward Delay");
		}
	}

	private Sprite LoadIconSprite()
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Expected O, but got Unknown
		//IL_0084: 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)
		try
		{
			using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("icon.png");
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			int num;
			for (int i = 0; i < array.Length; i += num)
			{
				num = stream.Read(array, i, array.Length - i);
				if (num <= 0)
				{
					break;
				}
			}
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, array))
			{
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not load the Risk of Options icon: " + ex.Message));
			return null;
		}
	}
}