Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of TempPickupBalance v3.2.0
TempPickupBalance.dll
Decompiled 14 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HG; using HarmonyLib; using Microsoft.CodeAnalysis; using On.RoR2; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; 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")] [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 TempPickupBalance { [BepInPlugin("br.vitorggbs.temppickupwalk", "Temp Pickup Balance", "3.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TempPickupBalancePlugin : BaseUnityPlugin { public enum PickupMode { Balanced, HighestStack } private ConfigEntry<PickupMode> mode; private ConfigEntry<bool> enabled; private ConfigEntry<float> radius; private ConfigEntry<float> interval; private ConfigEntry<bool> allowTemporaryOnlyCandidates; private float nextCheck; private float nextWorldScan; private const float HookedFallbackInterval = 30f; private const float UnhookedFallbackInterval = 3f; private readonly HashSet<int> trackedPickupIds = new HashSet<int>(); private readonly HashSet<int> trackedPickerIds = new HashSet<int>(); private readonly object[] grantArgs = new object[1]; private readonly object[] choiceArgs = new object[1]; private bool pickupLifecycleHooked; private bool pickerLifecycleHooked; private readonly Dictionary<int, float> pickupRetries = new Dictionary<int, float>(); private readonly List<CharacterBody> nearbyPlayers = new List<CharacterBody>(4); private readonly List<GenericPickupController> cachedPickups = new List<GenericPickupController>(); private readonly List<PickupPickerController> cachedPickers = new List<PickupPickerController>(); private Run lastRun; private static Inventory activeInventory; private static TempPickupBalancePlugin instance; private Harmony harmony; private static bool handlingPickup; private readonly HashSet<int> pickerAttempts = new HashSet<int>(); private static readonly FieldInfo PickerOptions = AccessTools.Field(typeof(PickupPickerController), "options"); private static readonly FieldInfo PickerSource = AccessTools.Field(typeof(PickupPickerController), "pickupThatGeneratedOptions"); private static readonly FieldInfo OptionPickup = AccessTools.Field(typeof(Option), "pickup"); private static readonly FieldInfo OptionAvailable = AccessTools.Field(typeof(Option), "available"); private static readonly MethodInfo SubmitPicker = AccessTools.Method(typeof(PickupPickerController), "SubmitChoice", new Type[1] { typeof(int) }, (Type[])null); private static readonly MethodInfo AttemptGrant = typeof(GenericPickupController).GetMethod("AttemptGrant", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(CharacterBody) }, null); private void Awake() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown instance = this; enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Pickup", "Enable Temporary Pickup", true, "When disabled, all pickups use their normal behavior."); mode = ((BaseUnityPlugin)this).Config.Bind<PickupMode>("Distribution", "Pickup Mode", PickupMode.Balanced, "Balanced: target the smallest stack. HighestStack: target the largest stack. Ties favor damage items."); radius = ((BaseUnityPlugin)this).Config.Bind<float>("Pickup", "Pickup Radius", 2.5f, "Maximum distance for automatically collecting temporary pickups."); interval = ((BaseUnityPlugin)this).Config.Bind<float>("Pickup", "Check Interval", 0.12f, "Time between pickup checks, in seconds."); allowTemporaryOnlyCandidates = ((BaseUnityPlugin)this).Config.Bind<bool>("Balancing", "Include Temporary-Only Items", false, "Include items that you only have temporary stacks of when choosing a target item."); ModSettingsManager.SetModDescription("Automatically collect temporary pickups and distribute them to existing items of the same rarity. Choose balanced or highest-stack priority. Damage items win ties. Regular pickups remain manual."); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(enabled)); ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)mode)); ModSettingsManager.AddOption((BaseOption)new SliderOption(radius, new SliderConfig { min = 0.5f, max = 6f })); ModSettingsManager.AddOption((BaseOption)new SliderOption(interval, new SliderConfig { min = 0.05f, max = 0.5f })); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(allowTemporaryOnlyCandidates)); GenericPickupController.AttemptGrant += new hook_AttemptGrant(OnAttemptGrant); harmony = new Harmony("br.vitorggbs.temppickupbalance.harmony"); MethodInfo methodInfo = AccessTools.Method(typeof(Inventory), "GiveItemTemp", new Type[2] { typeof(ItemIndex), typeof(float) }, (Type[])null); HarmonyMethod val = new HarmonyMethod(typeof(TempPickupBalancePlugin).GetMethod("BeforeGiveItemTemp", BindingFlags.Static | BindingFlags.NonPublic)); if (methodInfo != null) { harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { ((BaseUnityPlugin)this).Logger.LogError((object)"Inventory.GiveItemTemp(ItemIndex, float) was not found."); } if (AttemptGrant == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"AttemptGrant was not found. Check the game version."); } HookLifecycle(typeof(GenericPickupController), "OnPickupSpawned", out pickupLifecycleHooked); HookLifecycle(typeof(PickupPickerController), "OnPickerSpawned", out pickerLifecycleHooked); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Temp Pickup Balance 3.2.0 initialized (RiskOfOptions). Pickup hook: " + pickupLifecycleHooked + ", picker hook: " + pickerLifecycleHooked)); } private void HookLifecycle(Type component, string callback, out bool installed) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown installed = false; MethodInfo methodInfo = AccessTools.DeclaredMethod(component, "Start", (Type[])null, (Type[])null); if (methodInfo == null) { return; } try { MethodInfo methodInfo2 = AccessTools.Method(typeof(TempPickupBalancePlugin), callback, (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); installed = true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Lifecycle hook unavailable for " + component.Name + ": " + ex.Message)); } } private static void OnPickupSpawned(GenericPickupController __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) TempPickupBalancePlugin tempPickupBalancePlugin = instance; if (!((Object)(object)tempPickupBalancePlugin != (Object)null) || !((Object)(object)__instance != (Object)null)) { return; } UniquePickup pickup = __instance.pickup; if (((UniquePickup)(ref pickup)).isValid) { pickup = __instance.pickup; if (((UniquePickup)(ref pickup)).isTempItem && tempPickupBalancePlugin.trackedPickupIds.Add(((Object)__instance).GetInstanceID())) { tempPickupBalancePlugin.cachedPickups.Add(__instance); } } } private static void OnPickerSpawned(PickupPickerController __instance) { TempPickupBalancePlugin tempPickupBalancePlugin = instance; if ((Object)(object)tempPickupBalancePlugin != (Object)null && (Object)(object)__instance != (Object)null && tempPickupBalancePlugin.trackedPickerIds.Add(((Object)__instance).GetInstanceID())) { tempPickupBalancePlugin.cachedPickers.Add(__instance); } } private void OnDestroy() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown GenericPickupController.AttemptGrant -= new hook_AttemptGrant(OnAttemptGrant); if (harmony != null) { harmony.UnpatchSelf(); } instance = null; } private void OnAttemptGrant(orig_AttemptGrant orig, GenericPickupController pickupController, CharacterBody body) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 if (enabled.Value && NetworkServer.active && !handlingPickup && !((Object)(object)pickupController == (Object)null) && !((Object)(object)body == (Object)null) && !((Object)(object)body.inventory == (Object)null)) { UniquePickup pickup = pickupController.pickup; if (((UniquePickup)(ref pickup)).isValid) { pickup = pickupController.pickup; if (((UniquePickup)(ref pickup)).isTempItem) { PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupController.pickup.pickupIndex); if (pickupDef == null || (int)pickupDef.itemIndex == -1) { orig.Invoke(pickupController, body); return; } Inventory val = activeInventory; activeInventory = body.inventory; handlingPickup = true; try { orig.Invoke(pickupController, body); return; } finally { activeInventory = val; handlingPickup = false; } } } } orig.Invoke(pickupController, body); } private static void BeforeGiveItemTemp(Inventory __instance, ref ItemIndex __0, float __1) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected I4, but got Unknown TempPickupBalancePlugin tempPickupBalancePlugin = instance; if (!((Object)(object)tempPickupBalancePlugin == (Object)null) && tempPickupBalancePlugin.enabled.Value && NetworkServer.active && handlingPickup && !((Object)(object)__instance != (Object)(object)activeInventory) && !(__1 <= 0f)) { __0 = (ItemIndex)(int)tempPickupBalancePlugin.ChooseItem(__instance, __0); } } private ItemIndex ChooseItem(Inventory inventory, ItemIndex originalIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0035: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Invalid comparison between Unknown and I4 //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Invalid comparison between Unknown and I4 //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_00ef: Invalid comparison between Unknown and I4 //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) ItemDef itemDef = ItemCatalog.GetItemDef(originalIndex); if ((Object)(object)itemDef == (Object)null) { return originalIndex; } ItemIndex val = (ItemIndex)(-1); int num = ((mode.Value == PickupMode.Balanced) ? int.MaxValue : int.MinValue); bool flag = false; Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator(); try { while (enumerator.MoveNext()) { ItemDef current = enumerator.Current; if ((Object)(object)current == (Object)null || current.hidden || current.tier != itemDef.tier) { continue; } int itemCountPermanent = inventory.GetItemCountPermanent(current.itemIndex); int itemCountEffective = inventory.GetItemCountEffective(current.itemIndex); if (!(allowTemporaryOnlyCandidates.Value ? (itemCountEffective <= 0) : (itemCountPermanent <= 0))) { bool flag2 = HasDamageTag(current); bool flag3 = ((mode.Value == PickupMode.Balanced) ? (itemCountEffective < num) : (itemCountEffective > num)); bool flag4 = itemCountEffective == num && ((flag2 && !flag) || (flag2 == flag && ((int)val == -1 || current.itemIndex < val))); if ((int)val == -1 || flag3 || flag4) { val = current.itemIndex; num = itemCountEffective; flag = flag2; } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if ((int)val != -1) { return val; } return originalIndex; } private static bool HasDamageTag(ItemDef itemDef) { if (itemDef.tags == null) { return false; } ItemTag[] tags = itemDef.tags; for (int i = 0; i < tags.Length; i++) { if ((int)tags[i] == 1) { return true; } } return false; } private void Update() { //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Invalid comparison between Unknown and I4 //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) if (!enabled.Value || !NetworkServer.active || (Object)(object)Run.instance == (Object)null || Time.unscaledTime < nextCheck) { return; } float unscaledTime = Time.unscaledTime; if ((Object)(object)lastRun != (Object)(object)Run.instance) { lastRun = Run.instance; nextWorldScan = 0f; pickerAttempts.Clear(); cachedPickups.Clear(); cachedPickers.Clear(); trackedPickupIds.Clear(); trackedPickerIds.Clear(); pickupRetries.Clear(); } nextCheck = unscaledTime + Mathf.Max(0.05f, interval.Value); if (unscaledTime >= nextWorldScan) { RefreshPickupCache(); } if (cachedPickups.Count == 0 && cachedPickers.Count == 0) { return; } float num = Mathf.Max(0.2f, radius.Value); num *= num; nearbyPlayers.Clear(); foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.master == (Object)null)) { CharacterBody body = instance.master.GetBody(); if ((Object)(object)body != (Object)null && (Object)(object)body.inventory != (Object)null && (Object)(object)body.healthComponent != (Object)null && body.healthComponent.alive) { nearbyPlayers.Add(body); } } } if (nearbyPlayers.Count == 0) { return; } TryTemporaryPickers(num); if (AttemptGrant == null) { return; } for (int num2 = cachedPickups.Count - 1; num2 >= 0; num2--) { GenericPickupController val = cachedPickups[num2]; if (!((Object)(object)val == (Object)null)) { UniquePickup pickup = val.pickup; if (((UniquePickup)(ref pickup)).isValid) { pickup = val.pickup; if (((UniquePickup)(ref pickup)).isTempItem) { PickupDef pickupDef = PickupCatalog.GetPickupDef(val.pickup.pickupIndex); if (pickupDef == null || (int)pickupDef.itemIndex == -1) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (pickupRetries.TryGetValue(instanceID, out var value) && unscaledTime < value) { continue; } Vector3 position = ((Component)val).transform.position; foreach (CharacterBody nearbyPlayer in nearbyPlayers) { Vector3 val2 = nearbyPlayer.corePosition - position; if (((Vector3)(ref val2)).sqrMagnitude > num) { continue; } pickupRetries[instanceID] = unscaledTime + 0.6f; try { grantArgs[0] = nearbyPlayer; AttemptGrant.Invoke(val, grantArgs); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Pickup failed: " + ex.Message)); } finally { grantArgs[0] = null; } break; } continue; } } } if (val != null) { int instanceID2 = ((Object)val).GetInstanceID(); trackedPickupIds.Remove(instanceID2); pickupRetries.Remove(instanceID2); } cachedPickups.RemoveAt(num2); } } private void RefreshPickupCache() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_010c: 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) nextWorldScan = Time.unscaledTime + ((pickupLifecycleHooked && pickerLifecycleHooked) ? 30f : 3f); GenericPickupController[] array = Object.FindObjectsOfType<GenericPickupController>(); UniquePickup pickup; foreach (GenericPickupController val in array) { if (!((Object)(object)val != (Object)null)) { continue; } pickup = val.pickup; if (((UniquePickup)(ref pickup)).isValid) { pickup = val.pickup; if (((UniquePickup)(ref pickup)).isTempItem && trackedPickupIds.Add(((Object)val).GetInstanceID())) { cachedPickups.Add(val); } } } PickupPickerController[] array2 = Object.FindObjectsOfType<PickupPickerController>(); foreach (PickupPickerController val2 in array2) { if ((Object)(object)val2 != (Object)null && trackedPickerIds.Add(((Object)val2).GetInstanceID())) { cachedPickers.Add(val2); } } for (int num = cachedPickups.Count - 1; num >= 0; num--) { GenericPickupController val3 = cachedPickups[num]; if ((Object)(object)val3 != (Object)null) { pickup = val3.pickup; if (((UniquePickup)(ref pickup)).isValid) { pickup = val3.pickup; if (((UniquePickup)(ref pickup)).isTempItem) { continue; } } } if (val3 != null) { int instanceID = ((Object)val3).GetInstanceID(); trackedPickupIds.Remove(instanceID); pickupRetries.Remove(instanceID); } cachedPickups.RemoveAt(num); } for (int num2 = cachedPickers.Count - 1; num2 >= 0; num2--) { PickupPickerController val4 = cachedPickers[num2]; if (!((Object)(object)val4 != (Object)null)) { if (val4 != null) { int instanceID2 = ((Object)val4).GetInstanceID(); trackedPickerIds.Remove(instanceID2); pickerAttempts.Remove(instanceID2); } cachedPickers.RemoveAt(num2); } } } private void TryTemporaryPickers(float sqrRadius) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Invalid comparison between Unknown and I4 if (PickerOptions == null || PickerSource == null || OptionPickup == null || OptionAvailable == null || SubmitPicker == null) { return; } for (int num = cachedPickers.Count - 1; num >= 0; num--) { PickupPickerController val = cachedPickers[num]; if ((Object)(object)val == (Object)null) { if (val != null) { int instanceID = ((Object)val).GetInstanceID(); trackedPickerIds.Remove(instanceID); pickerAttempts.Remove(instanceID); } cachedPickers.RemoveAt(num); } else if (PickerSource.GetValue(val) is UniquePickup val2 && ((UniquePickup)(ref val2)).isTempItem) { int instanceID2 = ((Object)val).GetInstanceID(); if (!pickerAttempts.Contains(instanceID2) && PickerOptions.GetValue(val) is Array { Length: not 0 } array) { foreach (CharacterBody nearbyPlayer in nearbyPlayers) { Vector3 val3 = nearbyPlayer.corePosition - ((Component)val).transform.position; if (((Vector3)(ref val3)).sqrMagnitude > sqrRadius) { continue; } int num2 = -1; for (int i = 0; i < array.Length; i++) { object value = array.GetValue(i); if (value == null || !(bool)OptionAvailable.GetValue(value)) { continue; } UniquePickup val4 = (UniquePickup)OptionPickup.GetValue(value); if (((UniquePickup)(ref val4)).isValid) { PickupDef pickupDef = PickupCatalog.GetPickupDef(val4.pickupIndex); if (pickupDef != null && (int)pickupDef.itemIndex != -1) { num2 = i; break; } } } if (num2 < 0) { break; } pickerAttempts.Add(instanceID2); Inventory val5 = activeInventory; activeInventory = nearbyPlayer.inventory; handlingPickup = true; try { choiceArgs[0] = num2; SubmitPicker.Invoke(val, choiceArgs); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to select temporary item: " + ex)); } finally { activeInventory = val5; handlingPickup = false; choiceArgs[0] = null; } break; } } } } } } }