Decompiled source of IntuitiveItems BepInEx v1.5.2

IntuitiveItems.dll

Decompiled 10 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 Assets.Scripts.Actors.Player;
using Assets.Scripts.Inventory__Items__Pickups;
using Assets.Scripts.Inventory__Items__Pickups.Items;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("IntuitiveItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Configurable Item Limits for Megabonk")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+a80525d5e416052b80cf3c0977520ea197c3e8aa")]
[assembly: AssemblyProduct("IntuitiveItems")]
[assembly: AssemblyTitle("IntuitiveItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace IntuitiveItems
{
	[BepInPlugin("com.arvietabz.intuitiveitems", "IntuitiveItems", "1.5.2")]
	public class Core : BasePlugin
	{
		[HarmonyPatch(typeof(UnlockContainer), "OnEnable")]
		public static class UnlockContainerPatch
		{
			[HarmonyPostfix]
			public static void Postfix(UnlockContainer __instance)
			{
				if (!((Object)(object)((Component)__instance).GetComponent<ConfigInputBehavior>() != (Object)null))
				{
					((Component)__instance).gameObject.AddComponent<ConfigInputBehavior>();
				}
			}
		}

		public const string GUID = "com.arvietabz.intuitiveitems";

		public const string NAME = "IntuitiveItems";

		public const string VERSION = "1.5.2";

		public static Core Instance;

		private Harmony _harmony;

		public ConfigEntry<bool> _keysFirstConfig;

		public Dictionary<EItem, ConfigEntry<int>> _itemLimits = new Dictionary<EItem, ConfigEntry<int>>();

		public Dictionary<EItem, ItemData> _itemDataCache = new Dictionary<EItem, ItemData>();

		private HashSet<EItem> _allowedItems = new HashSet<EItem>();

		public bool _isConfigInitialized = false;

		public override void Load()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			Instance = this;
			_harmony = new Harmony("com.arvietabz.intuitiveitems");
			ClassInjector.RegisterTypeInIl2Cpp<IntuitiveItemsBehavior>();
			ClassInjector.RegisterTypeInIl2Cpp<ConfigInputBehavior>();
			GameObject val = new GameObject("IntuitiveItemsBehavior");
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<IntuitiveItemsBehavior>();
			_harmony.PatchAll();
			((BasePlugin)this).Log.LogInfo((object)"IntuitiveItems Loaded.");
		}

		public void TryInitializeConfig()
		{
			//IL_0087: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected I4, but got Unknown
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_117d: Unknown result type (might be due to invalid IL or missing references)
			Il2CppReferenceArray<Object> val = Resources.FindObjectsOfTypeAll(Il2CppType.Of<ItemData>());
			if (val == null || ((Il2CppArrayBase<Object>)(object)val).Length == 0)
			{
				return;
			}
			_keysFirstConfig = ((BasePlugin)this).Config.Bind<bool>("-- General --", "Keys First", false, "If set to true: Only Keys, Legendaries, and Credit Cards will spawn until you reach your Key limit.");
			List<ItemData> list = new List<ItemData>();
			HashSet<EItem> hashSet = new HashSet<EItem>();
			foreach (Object item in (Il2CppArrayBase<Object>)(object)val)
			{
				ItemData val2 = ((Il2CppObjectBase)item).TryCast<ItemData>();
				if (!((Object)(object)val2 == (Object)null) && !hashSet.Contains(val2.eItem))
				{
					list.Add(val2);
					hashSet.Add(val2.eItem);
					if (!_itemDataCache.ContainsKey(val2.eItem))
					{
						_itemDataCache[val2.eItem] = val2;
					}
				}
			}
			IOrderedEnumerable<ItemData> orderedEnumerable = (from x in list.ToArray()
				orderby (int)x.rarity
				select x).ThenBy(delegate(ItemData x)
			{
				//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)
				EItem eItem2 = x.eItem;
				return ((object)(EItem)(ref eItem2)).ToString();
			});
			foreach (ItemData item2 in orderedEnumerable)
			{
				EItem eItem = item2.eItem;
				string text = ((object)(EItem)(ref eItem)).ToString();
				string text2 = $"{(int)item2.rarity}. {item2.rarity}";
				int num = -1;
				switch (text)
				{
				case "Borgar":
					num = 1;
					break;
				case "BossBuster":
					num = 1;
					break;
				case "Battery":
					num = 1;
					break;
				case "Cactus":
					num = 1;
					break;
				case "Clover":
					num = 1;
					break;
				case "CreditCardGreen":
					num = 20;
					break;
				case "CreditCardRed":
					num = 20;
					break;
				case "CursedDoll":
					num = 1;
					break;
				case "ForbiddenJuice":
					num = 1;
					break;
				case "Ghost":
					num = 1;
					break;
				case "GoldenGlove":
					num = 1;
					break;
				case "GymSauce":
					num = 1;
					break;
				case "IceCrystal":
					num = 1;
					break;
				case "Key":
					num = 10;
					break;
				case "Medkit":
					num = 1;
					break;
				case "MoldyCheese":
					num = 1;
					break;
				case "Oats":
					num = 1;
					break;
				case "OldMask":
					num = 1;
					break;
				case "Skuleg":
					num = 1;
					break;
				case "SlipperyRing":
					num = 1;
					break;
				case "TacticalGlasses":
					num = 1;
					break;
				case "TimeBracelet":
					num = 1;
					break;
				case "TurboSocks":
					num = 1;
					break;
				case "Wrench":
					num = 1;
					break;
				case "Backpack":
					num = 1;
					break;
				case "Beacon":
					num = 1;
					break;
				case "Beer":
					num = 1;
					break;
				case "BrassKnuckles":
					num = 5;
					break;
				case "Campfire":
					num = 1;
					break;
				case "CowardsCloak":
					num = 1;
					break;
				case "DemonBlade":
					num = 1;
					break;
				case "DemonicBlood":
					num = 5;
					break;
				case "EchoShard":
					num = 1;
					break;
				case "ElectricPlug":
					num = 1;
					break;
				case "Feathers":
					num = 1;
					break;
				case "GloveLightning":
					num = 1;
					break;
				case "GlovePoison":
					num = 1;
					break;
				case "GoldenShield":
					num = 1;
					break;
				case "GoldenSneakers":
					num = 1;
					break;
				case "IdleJuice":
					num = 5;
					break;
				case "LeechingCrystal":
					num = 1;
					break;
				case "PhantomShroud":
					num = 1;
					break;
				case "Pumpkin":
					num = 1;
					break;
				case "UnstableTransfusion":
					num = 1;
					break;
				case "BeefyRing":
					num = 5;
					break;
				case "BobDead":
					num = 1;
					break;
				case "BobsLantern":
					num = 5;
					break;
				case "DemonicSoul":
					num = 5;
					break;
				case "EagleClaw":
					num = 1;
					break;
				case "GamerGoggles":
					num = 1;
					break;
				case "Gasmask":
					num = 1;
					break;
				case "GloveBlood":
					num = 1;
					break;
				case "GloveCurse":
					num = 1;
					break;
				case "GrandmasSecretTonic":
					num = 2;
					break;
				case "Kevin":
					num = 1;
					break;
				case "Mirror":
					num = 1;
					break;
				case "QuinsMask":
					num = 1;
					break;
				case "Rollerblades":
					num = 1;
					break;
				case "Scarf":
					num = 1;
					break;
				case "ShatteredWisdom":
					num = 1;
					break;
				case "SluttyCannon":
					num = 5;
					break;
				case "SpikyShield":
					num = 1;
					break;
				case "ToxicBarrel":
					num = 1;
					break;
				case "Anvil":
					num = 3;
					break;
				case "BloodyCleaver":
					num = 2;
					break;
				case "Bonker":
					num = 5;
					break;
				case "Chonkplate":
					num = 5;
					break;
				case "Dragonfire":
					num = 5;
					break;
				case "EnergyCore":
					num = 1;
					break;
				case "GiantFork":
					num = 5;
					break;
				case "GlovePower":
					num = 1;
					break;
				case "GoldenRing":
					num = 1;
					break;
				case "HolyBook":
					num = 2;
					break;
				case "IceCube":
					num = 1;
					break;
				case "JoesDagger":
					num = 5;
					break;
				case "LightningOrb":
					num = 5;
					break;
				case "OverpoweredLamp":
					num = 5;
					break;
				case "Snek":
					num = 5;
					break;
				case "SoulHarvester":
					num = 1;
					break;
				case "SpeedBoi":
					num = 1;
					break;
				case "SpicyMeatball":
					num = 1;
					break;
				case "SuckyMagnet":
					num = 2;
					break;
				case "ZaWarudo":
					num = 1;
					break;
				}
				ConfigEntry<int> value = ((BasePlugin)this).Config.Bind<int>(text2, text, num, "Max amount of " + text + " to hold.");
				_itemLimits[item2.eItem] = value;
			}
			((BasePlugin)this).Config.Save();
			_isConfigInitialized = true;
		}

		public void UpdateAllowedItemsList()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (RunUnlockables.availableItems == null)
			{
				return;
			}
			List<ItemData> val2 = default(List<ItemData>);
			foreach (object value in Enum.GetValues(typeof(EItemRarity)))
			{
				EItemRarity val = (EItemRarity)value;
				if (RunUnlockables.availableItems.TryGetValue(val, ref val2) && val2 != null)
				{
					Enumerator<ItemData> enumerator2 = val2.GetEnumerator();
					while (enumerator2.MoveNext())
					{
						ItemData current2 = enumerator2.Current;
						_allowedItems.Add(current2.eItem);
					}
				}
			}
		}

		public void ApplySmartLootLogic()
		{
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Invalid comparison between Unknown and I4
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Invalid comparison between Unknown and I4
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Invalid comparison between Unknown and I4
			//IL_0263: 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_015c: Invalid comparison between Unknown and I4
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			if (!_isConfigInitialized)
			{
				TryInitializeConfig();
				return;
			}
			MyPlayer instance = MyPlayer.Instance;
			if ((Object)(object)instance == (Object)null || instance.inventory == null || instance.inventory.itemInventory == null || RunUnlockables.availableItems == null)
			{
				return;
			}
			UpdateAllowedItemsList();
			bool value = _keysFirstConfig.Value;
			int amount = instance.inventory.itemInventory.GetAmount((EItem)0);
			int num = 10;
			if (_itemLimits.ContainsKey((EItem)0))
			{
				num = _itemLimits[(EItem)0].Value;
			}
			if (value && amount < num)
			{
				foreach (KeyValuePair<EItem, ItemData> item in _itemDataCache)
				{
					ItemData value2 = item.Value;
					EItemRarity rarity = value2.rarity;
					List<ItemData> val = null;
					if (RunUnlockables.availableItems.TryGetValue(rarity, ref val) && val != null && _allowedItems.Contains(value2.eItem))
					{
						bool flag = (int)value2.eItem == 0;
						bool flag2 = (int)rarity == 3;
						bool flag3 = (int)value2.eItem == 64 || (int)value2.eItem == 63;
						bool flag4 = val.Contains(value2);
						if (flag || flag2 || flag3)
						{
							if (!flag4)
							{
								val.Add(value2);
							}
						}
						else if (flag4)
						{
							val.Remove(value2);
						}
					}
				}
				return;
			}
			foreach (KeyValuePair<EItem, ItemData> item2 in _itemDataCache)
			{
				EItem key = item2.Key;
				ItemData value3 = item2.Value;
				EItemRarity rarity2 = value3.rarity;
				List<ItemData> val2 = null;
				if (!RunUnlockables.availableItems.TryGetValue(rarity2, ref val2) || val2 == null || !_allowedItems.Contains(key))
				{
					continue;
				}
				int num2 = -1;
				if (_itemLimits.ContainsKey(key))
				{
					num2 = _itemLimits[key].Value;
				}
				bool flag5 = val2.Contains(value3);
				if (num2 < 0)
				{
					if (!flag5)
					{
						val2.Add(value3);
					}
					continue;
				}
				int amount2 = instance.inventory.itemInventory.GetAmount(key);
				if (amount2 >= num2)
				{
					if (flag5)
					{
						val2.Remove(value3);
					}
				}
				else if (!flag5)
				{
					val2.Add(value3);
				}
			}
		}
	}
	public class ConfigInputBehavior : MonoBehaviour
	{
		private UnlockContainer _container;

		private GameObject _limitRoot;

		private InputField _inputField;

		private GameObject _toggleRoot;

		private Image _toggleBg;

		private RectTransform _toggleHandle;

		private ItemData _currentItem;

		public ConfigInputBehavior(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Start()
		{
			_container = ((Component)this).GetComponent<UnlockContainer>();
			CreateLimitUI();
			CreateToggleUI();
			HideAllUI();
		}

		public void OnEnable()
		{
			_currentItem = null;
			if ((Object)(object)_limitRoot != (Object)null)
			{
				HideAllUI();
			}
		}

		public void Update()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_container == (Object)null || (Object)(object)_container.unlockable == (Object)null)
			{
				if ((Object)(object)_currentItem != (Object)null)
				{
					_currentItem = null;
					HideAllUI();
				}
				return;
			}
			ItemData val = ((Il2CppObjectBase)_container.unlockable).TryCast<ItemData>();
			if ((Object)(object)val == (Object)null)
			{
				if ((Object)(object)_currentItem != (Object)null)
				{
					_currentItem = null;
					HideAllUI();
				}
			}
			else if (!Core.Instance._itemLimits.ContainsKey(val.eItem))
			{
				if ((Object)(object)_currentItem != (Object)null)
				{
					_currentItem = null;
					HideAllUI();
				}
			}
			else if ((Object)(object)val != (Object)(object)_currentItem)
			{
				_currentItem = val;
				RefreshUI();
			}
		}

		private void HideAllUI()
		{
			if ((Object)(object)_limitRoot != (Object)null)
			{
				_limitRoot.SetActive(false);
			}
			if ((Object)(object)_toggleRoot != (Object)null)
			{
				_toggleRoot.SetActive(false);
			}
		}

		private void CreateLimitUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			_limitRoot = new GameObject("LimitBorder");
			_limitRoot.transform.SetParent(((Component)this).transform, false);
			_limitRoot.SetActive(false);
			RectTransform val = _limitRoot.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(1f, 0f);
			val.anchorMax = new Vector2(1f, 0f);
			val.pivot = new Vector2(1f, 0f);
			val.sizeDelta = new Vector2(26f, 26f);
			val.anchoredPosition = new Vector2(-5f, 5f);
			Image val2 = _limitRoot.AddComponent<Image>();
			((Graphic)val2).color = Color.white;
			GameObject val3 = new GameObject("LimitInput");
			val3.transform.SetParent(_limitRoot.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.sizeDelta = Vector2.zero;
			val4.offsetMin = new Vector2(1f, 1f);
			val4.offsetMax = new Vector2(-1f, -1f);
			Image val5 = val3.AddComponent<Image>();
			((Graphic)val5).color = Color.black;
			_inputField = val3.AddComponent<InputField>();
			GameObject val6 = new GameObject("Text");
			val6.transform.SetParent(val3.transform, false);
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.anchorMin = Vector2.zero;
			val7.anchorMax = Vector2.one;
			val7.sizeDelta = Vector2.zero;
			Text val8 = val6.AddComponent<Text>();
			val8.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			((Graphic)val8).color = Color.white;
			val8.alignment = (TextAnchor)4;
			val8.resizeTextForBestFit = true;
			val8.resizeTextMinSize = 8;
			val8.resizeTextMaxSize = 16;
			_inputField.textComponent = val8;
			((UnityEvent<string>)(object)_inputField.onEndEdit).AddListener(UnityAction<string>.op_Implicit((Action<string>)OnValueChanged));
		}

		private void CreateToggleUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_00a5: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			_toggleRoot = new GameObject("KeysFirstToggle");
			_toggleRoot.transform.SetParent(((Component)this).transform, false);
			_toggleRoot.SetActive(false);
			RectTransform val = _toggleRoot.AddComponent<RectTransform>();
			val.anchorMin = new Vector2(0f, 0f);
			val.anchorMax = new Vector2(0f, 0f);
			val.pivot = new Vector2(0f, 0f);
			val.sizeDelta = new Vector2(34f, 20f);
			val.anchoredPosition = new Vector2(5f, 5f);
			Button val2 = _toggleRoot.AddComponent<Button>();
			((UnityEvent)val2.onClick).AddListener(UnityAction.op_Implicit((Action)OnToggleClicked));
			Image val3 = _toggleRoot.AddComponent<Image>();
			((Graphic)val3).color = Color.white;
			GameObject val4 = new GameObject("InnerBlack");
			val4.transform.SetParent(_toggleRoot.transform, false);
			RectTransform val5 = val4.AddComponent<RectTransform>();
			val5.anchorMin = Vector2.zero;
			val5.anchorMax = Vector2.one;
			val5.sizeDelta = Vector2.zero;
			val5.offsetMin = new Vector2(1f, 1f);
			val5.offsetMax = new Vector2(-1f, -1f);
			Image val6 = val4.AddComponent<Image>();
			((Graphic)val6).color = Color.black;
			GameObject val7 = new GameObject("ToggleContent");
			val7.transform.SetParent(val4.transform, false);
			RectTransform val8 = val7.AddComponent<RectTransform>();
			val8.anchorMin = Vector2.zero;
			val8.anchorMax = Vector2.one;
			val8.sizeDelta = Vector2.zero;
			val8.offsetMin = new Vector2(1f, 1f);
			val8.offsetMax = new Vector2(-1f, -1f);
			_toggleBg = val7.AddComponent<Image>();
			((Graphic)_toggleBg).color = Color.black;
			GameObject val9 = new GameObject("Handle");
			val9.transform.SetParent(val7.transform, false);
			_toggleHandle = val9.AddComponent<RectTransform>();
			_toggleHandle.sizeDelta = new Vector2(12f, 12f);
			_toggleHandle.anchorMin = new Vector2(0f, 0.5f);
			_toggleHandle.anchorMax = new Vector2(0f, 0.5f);
			_toggleHandle.pivot = new Vector2(0f, 0.5f);
			_toggleHandle.anchoredPosition = new Vector2(2f, 0f);
			Image val10 = val9.AddComponent<Image>();
			((Graphic)val10).color = Color.white;
		}

		private void RefreshUI()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Invalid comparison between Unknown and I4
			if ((Object)(object)_inputField == (Object)null)
			{
				return;
			}
			if ((Object)(object)_currentItem == (Object)null)
			{
				HideAllUI();
				return;
			}
			if (Core.Instance._itemLimits.TryGetValue(_currentItem.eItem, out var value))
			{
				_limitRoot.SetActive(true);
				if (value.Value == -1)
				{
					_inputField.text = "∞";
				}
				else
				{
					_inputField.text = value.Value.ToString();
				}
			}
			else
			{
				_limitRoot.SetActive(false);
			}
			if ((int)_currentItem.eItem == 0)
			{
				_toggleRoot.SetActive(true);
				bool value2 = Core.Instance._keysFirstConfig.Value;
				UpdateToggleVisuals(value2);
			}
			else
			{
				_toggleRoot.SetActive(false);
			}
		}

		private void UpdateToggleVisuals(bool isOn)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_003a: 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_0070: 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)
			if (isOn)
			{
				((Graphic)_toggleBg).color = new Color(0f, 0.8f, 0f);
				_toggleHandle.anchorMin = new Vector2(1f, 0.5f);
				_toggleHandle.anchorMax = new Vector2(1f, 0.5f);
				_toggleHandle.pivot = new Vector2(1f, 0.5f);
				_toggleHandle.anchoredPosition = new Vector2(-2f, 0f);
			}
			else
			{
				((Graphic)_toggleBg).color = Color.black;
				_toggleHandle.anchorMin = new Vector2(0f, 0.5f);
				_toggleHandle.anchorMax = new Vector2(0f, 0.5f);
				_toggleHandle.pivot = new Vector2(0f, 0.5f);
				_toggleHandle.anchoredPosition = new Vector2(2f, 0f);
			}
		}

		private void OnToggleClicked()
		{
			bool value = Core.Instance._keysFirstConfig.Value;
			Core.Instance._keysFirstConfig.Value = !value;
			((BasePlugin)Core.Instance).Config.Save();
			UpdateToggleVisuals(!value);
		}

		private void OnValueChanged(string val)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_currentItem == (Object)null))
			{
				int result = -1;
				if (string.IsNullOrEmpty(val) || val == "∞")
				{
					result = -1;
				}
				else if (!int.TryParse(val, out result))
				{
					RefreshUI();
					return;
				}
				if (Core.Instance._itemLimits.TryGetValue(_currentItem.eItem, out var value))
				{
					value.Value = result;
					((BasePlugin)Core.Instance).Config.Save();
					RefreshUI();
				}
			}
		}
	}
	public class IntuitiveItemsBehavior : MonoBehaviour
	{
		private float _checkTimer = 0f;

		private const float CHECK_INTERVAL = 1f;

		public IntuitiveItemsBehavior(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Update()
		{
			_checkTimer += Time.deltaTime;
			float num = (Core.Instance._isConfigInitialized ? 1f : 1f);
			if (_checkTimer > num)
			{
				_checkTimer = 0f;
				if (Core.Instance != null)
				{
					Core.Instance.ApplySmartLootLogic();
				}
			}
		}
	}
}