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 Assets.Scripts.Saves___Serialization.Progression.Achievements;
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+0f139d13c67cec48912ccbda3bfeb4cdd583d85c")]
[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.9.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.9.2";
public static Core Instance;
private Harmony _harmony;
public ConfigEntry<bool> _keysFirstConfig;
public ConfigEntry<bool> _chainEnabledConfig;
public ConfigEntry<bool> _strictChainConfig;
public ConfigEntry<string> _chainOrderConfig;
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 List<EItem> _parsedChainList = new List<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_00f5: 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_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected I4, but got Unknown
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_11eb: 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 ON: Prioritize Keys.");
_chainEnabledConfig = ((BasePlugin)this).Config.Bind<bool>("-- General --", "Chain Enabled", false, "If ON: Progression Chain is active.");
_strictChainConfig = ((BasePlugin)this).Config.Bind<bool>("-- General --", "Strict Chain Mode", false, "If ON: Strict mode.");
_chainOrderConfig = ((BasePlugin)this).Config.Bind<string>("-- General --", "Chain Order", "SpicyMeatball, JoesDagger, Bonker, SluttyCannon, CursedDoll", "Order of progression.");
ParseChainOrder();
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;
}
private void ParseChainOrder()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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)
_parsedChainList.Clear();
string value = _chainOrderConfig.Value;
if (string.IsNullOrEmpty(value))
{
return;
}
string[] array = value.Split(',');
string[] array2 = array;
foreach (string text in array2)
{
string value2 = text.Trim();
try
{
EItem item = (EItem)Enum.Parse(typeof(EItem), value2);
_parsedChainList.Add(item);
}
catch
{
}
}
}
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_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: 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_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0413: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_043f: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_023a: Invalid comparison between Unknown and I4
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Unknown result type (might be due to invalid IL or missing references)
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Invalid comparison between Unknown and I4
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Invalid comparison between Unknown and I4
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Invalid comparison between Unknown and I4
//IL_049e: Unknown result type (might be due to invalid IL or missing references)
//IL_057e: Unknown result type (might be due to invalid IL or missing references)
//IL_0583: Unknown result type (might be due to invalid IL or missing references)
//IL_058d: Unknown result type (might be due to invalid IL or missing references)
//IL_0592: Unknown result type (might be due to invalid IL or missing references)
//IL_059a: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Invalid comparison between Unknown and I4
//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
//IL_05da: Unknown result type (might be due to invalid IL or missing references)
//IL_0602: 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;
}
bool value2 = _chainEnabledConfig.Value;
bool value3 = _strictChainConfig.Value;
ItemData val = null;
bool flag = true;
if (value2 && _parsedChainList.Count > 0)
{
foreach (EItem parsedChain in _parsedChainList)
{
int amount2 = instance.inventory.itemInventory.GetAmount(parsedChain);
if (amount2 < 1)
{
if (_itemDataCache.ContainsKey(parsedChain))
{
val = _itemDataCache[parsedChain];
}
flag = false;
break;
}
}
}
if (value2 && value3 && !flag && (Object)(object)val != (Object)null)
{
foreach (KeyValuePair<EItem, ItemData> item in _itemDataCache)
{
ItemData value4 = item.Value;
if (((UnlockableBase)value4).isEnabled)
{
EItemRarity rarity = value4.rarity;
List<ItemData> val2 = null;
if (RunUnlockables.availableItems.TryGetValue(rarity, ref val2) && val2 != null && _allowedItems.Contains(value4.eItem))
{
bool flag2 = val2.Contains(value4);
bool flag3 = false;
bool flag4 = value4.eItem == val.eItem;
bool flag5 = (int)value4.eItem == 0;
if (flag4)
{
flag3 = true;
}
else if (flag5 && value && amount < num)
{
flag3 = true;
}
if (flag3)
{
if (!flag2)
{
val2.Add(value4);
}
}
else if (flag2)
{
val2.Remove(value4);
}
}
}
}
return;
}
if (value && amount < num)
{
foreach (KeyValuePair<EItem, ItemData> item2 in _itemDataCache)
{
ItemData value5 = item2.Value;
if (((UnlockableBase)value5).isEnabled)
{
EItemRarity rarity2 = value5.rarity;
List<ItemData> val3 = null;
if (RunUnlockables.availableItems.TryGetValue(rarity2, ref val3) && val3 != null && _allowedItems.Contains(value5.eItem))
{
bool flag6 = (int)value5.eItem == 0;
bool flag7 = (int)rarity2 == 3;
bool flag8 = (int)value5.eItem == 64 || (int)value5.eItem == 63;
bool flag9 = val3.Contains(value5);
if (flag6 || flag7 || flag8)
{
if (!flag9)
{
val3.Add(value5);
}
}
else if (flag9)
{
val3.Remove(value5);
}
}
}
}
return;
}
foreach (KeyValuePair<EItem, ItemData> item3 in _itemDataCache)
{
EItem key = item3.Key;
ItemData value6 = item3.Value;
if (!((UnlockableBase)value6).isEnabled)
{
continue;
}
EItemRarity rarity3 = value6.rarity;
List<ItemData> val4 = null;
if (!RunUnlockables.availableItems.TryGetValue(rarity3, ref val4) || val4 == null || !_allowedItems.Contains(key))
{
continue;
}
int num2 = -1;
if (_itemLimits.ContainsKey(key))
{
num2 = _itemLimits[key].Value;
}
bool flag10 = val4.Contains(value6);
if (num2 < 0)
{
if (!flag10)
{
val4.Add(value6);
}
continue;
}
int amount3 = instance.inventory.itemInventory.GetAmount(key);
if (amount3 >= num2)
{
if (flag10)
{
val4.Remove(value6);
}
}
else if (!flag10)
{
val4.Add(value6);
}
}
if (!value2 || value3 || _parsedChainList.Count <= 1)
{
return;
}
for (int i = 1; i < _parsedChainList.Count; i++)
{
EItem val5 = _parsedChainList[i - 1];
EItem key2 = _parsedChainList[i];
if (!_itemDataCache.ContainsKey(key2))
{
continue;
}
ItemData val6 = _itemDataCache[key2];
if (!((UnlockableBase)val6).isEnabled)
{
continue;
}
List<ItemData> val7 = null;
if (RunUnlockables.availableItems.TryGetValue(val6.rarity, ref val7) && val7 != null)
{
int amount4 = instance.inventory.itemInventory.GetAmount(val5);
if (amount4 < 1 && val7.Contains(val6))
{
val7.Remove(val6);
}
}
}
}
}
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;
private bool _lastKnownToggleState;
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();
}
else
{
CheckForExternalConfigChanges();
}
}
private void CheckForExternalConfigChanges()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_currentItem == (Object)null) && _toggleRoot.activeSelf)
{
bool flag = false;
if ((int)_currentItem.eItem == 0)
{
flag = Core.Instance._keysFirstConfig.Value;
}
else if (Core.Instance._parsedChainList.Count > 0 && _currentItem.eItem == Core.Instance._parsedChainList[0])
{
flag = Core.Instance._chainEnabledConfig.Value;
}
else if (Core.Instance._parsedChainList.Count > 1 && _currentItem.eItem == Core.Instance._parsedChainList[1])
{
flag = Core.Instance._strictChainConfig.Value;
}
if (flag != _lastKnownToggleState)
{
UpdateToggleVisuals(flag);
}
}
}
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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Invalid comparison between Unknown and I4
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
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);
}
bool flag = false;
bool isOn = false;
if ((int)_currentItem.eItem == 0)
{
flag = true;
isOn = Core.Instance._keysFirstConfig.Value;
}
else if (Core.Instance._parsedChainList.Count > 0 && _currentItem.eItem == Core.Instance._parsedChainList[0])
{
flag = true;
isOn = Core.Instance._chainEnabledConfig.Value;
}
else if (Core.Instance._parsedChainList.Count > 1 && _currentItem.eItem == Core.Instance._parsedChainList[1])
{
flag = true;
isOn = Core.Instance._strictChainConfig.Value;
}
if (flag)
{
_toggleRoot.SetActive(true);
UpdateToggleVisuals(isOn);
}
else
{
_toggleRoot.SetActive(false);
}
}
private void UpdateToggleVisuals(bool isOn)
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_0026: 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_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
_lastKnownToggleState = isOn;
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()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
if ((int)_currentItem.eItem == 0)
{
bool value = Core.Instance._keysFirstConfig.Value;
Core.Instance._keysFirstConfig.Value = !value;
((BasePlugin)Core.Instance).Config.Save();
UpdateToggleVisuals(!value);
}
else if (Core.Instance._parsedChainList.Count > 0 && _currentItem.eItem == Core.Instance._parsedChainList[0])
{
bool value2 = Core.Instance._chainEnabledConfig.Value;
Core.Instance._chainEnabledConfig.Value = !value2;
if (value2)
{
Core.Instance._strictChainConfig.Value = false;
}
((BasePlugin)Core.Instance).Config.Save();
UpdateToggleVisuals(!value2);
}
else if (Core.Instance._parsedChainList.Count > 1 && _currentItem.eItem == Core.Instance._parsedChainList[1])
{
bool value3 = Core.Instance._strictChainConfig.Value;
if (!value3 && !Core.Instance._chainEnabledConfig.Value)
{
Core.Instance._chainEnabledConfig.Value = true;
}
Core.Instance._strictChainConfig.Value = !value3;
((BasePlugin)Core.Instance).Config.Save();
UpdateToggleVisuals(!value3);
}
}
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();
}
}
}
}
}