using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Nessie.ATLYSS.EasySettings; using Nessie.ATLYSS.EasySettings.UIElements; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: Guid("6b1f4e2a-9d7c-4a3b-b8e1-2f6c9a4d7e35")] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyDescription("Search and filter UI for modded items.")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyTitle("TundrasItemSearcher")] [assembly: AssemblyProduct("TundrasItemSearcher")] [assembly: AssemblyVersion("1.0.4.0")] namespace tundras_item_searcher; internal static class HomebreweryBridge { private static FieldInfo _modShops; private static FieldInfo _itemsGear; private static FieldInfo _itemsCons; private static FieldInfo _itemsTrad; private static FieldInfo _itemName; private static FieldInfo _itemDescription; private static FieldInfo _itemSecret; private static FieldInfo _modFolderName; private static PropertyInfo _itemType; private static PropertyInfo _itemMod; private static PropertyInfo _itemRarity; private static PropertyInfo _itemShopItem; private static FieldInfo _shopItemScript; private static FieldInfo _scriptItemIcon; private static bool _ready; internal static List LoadAllItems() { List list = new List(); try { if (!EnsureReflection()) { return list; } if (!(_modShops.GetValue(null) is IEnumerable enumerable)) { return list; } foreach (object item in enumerable) { if (item != null) { AddItems(_itemsGear.GetValue(item) as IEnumerable, list); AddItems(_itemsCons.GetValue(item) as IEnumerable, list); AddItems(_itemsTrad.GetValue(item) as IEnumerable, list); } } } catch (Exception ex) { Log.Warn("failed reading the item list: " + ex.Message); } return list; } private static void AddItems(IEnumerable itemThings, List items) { if (itemThings == null) { return; } foreach (object itemThing in itemThings) { if (itemThing != null) { ItemInfo itemInfo = ToItemInfo(itemThing); if (itemInfo != null) { items.Add(itemInfo); } } } } private static ItemInfo ToItemInfo(object itemThing) { try { object value = _itemSecret.GetValue(itemThing); if (value is bool && (bool)value) { return null; } object value2 = _itemType.GetValue(itemThing, null); object value3 = _itemMod.GetValue(itemThing, null); object value4 = _itemRarity.GetValue(itemThing, null); object value5 = _itemShopItem.GetValue(itemThing, null); object obj = ((value5 != null) ? _shopItemScript.GetValue(value5) : null); Sprite iconSprite = (Sprite)((obj != null) ? /*isinst with value type is only supported in some contexts*/: null); ItemInfo itemInfo = new ItemInfo(); itemInfo.Name = (_itemName.GetValue(itemThing) as string) ?? ""; itemInfo.Description = (_itemDescription.GetValue(itemThing) as string) ?? ""; itemInfo.Category = ToItemCategory((value2 != null) ? value2.ToString() : ""); itemInfo.SourceModName = ((value3 != null) ? ((_modFolderName.GetValue(value3) as string) ?? "") : ""); itemInfo.Rarity = ((value4 != null) ? value4.ToString() : ""); itemInfo.IconSprite = iconSprite; itemInfo.ScriptItemRef = obj; return itemInfo; } catch (Exception ex) { Log.Warn("skipped an item that wouldn't read: " + ex.Message); return null; } } private static ItemCategory ToItemCategory(string folderTypeName) { return folderTypeName switch { "Helm" => ItemCategory.Helm, "Chestpiece" => ItemCategory.Chestpiece, "Leggings" => ItemCategory.Leggings, "Cape" => ItemCategory.Cape, "Weapon" => ItemCategory.Weapon, "Shield" => ItemCategory.Shield, "Consumable" => ItemCategory.Consumable, "Dye" => ItemCategory.Consumable, "TradeItem" => ItemCategory.TradeItem, _ => ItemCategory.Unknown, }; } private static bool EnsureReflection() { if (_ready) { return true; } Type type = ReflectionUtil.FindType("Homebrewery.HB"); Type type2 = ReflectionUtil.FindType("Homebrewery.Code.Objects.ModShop"); Type type3 = ReflectionUtil.FindType("Homebrewery.Code.Objects.Things.ItemThing"); Type type4 = ReflectionUtil.FindType("Homebrewery.Code.Objects.ModFolder"); Type type5 = ReflectionUtil.FindType("ShopkeepItem"); Type type6 = ReflectionUtil.FindType("ScriptableItem"); if (type == null || type2 == null || type3 == null || type4 == null || type5 == null || type6 == null) { Log.Warn("homebrewery types not found, is it installed?"); return false; } _modShops = type.GetField("_modShops", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _itemsGear = type2.GetField("_items_Gear", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _itemsCons = type2.GetField("_items_Cons", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _itemsTrad = type2.GetField("_items_Trad", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _itemName = ReflectionUtil.FindField(type3, "_itemName"); _itemDescription = ReflectionUtil.FindField(type3, "_itemDescription"); _itemSecret = ReflectionUtil.FindField(type3, "secretitem"); _itemType = ReflectionUtil.FindProperty(type3, "Type"); _itemMod = ReflectionUtil.FindProperty(type3, "Mod"); _itemRarity = ReflectionUtil.FindProperty(type3, "ItemRarity"); _itemShopItem = ReflectionUtil.FindProperty(type3, "ShopItem"); _modFolderName = ReflectionUtil.FindField(type4, "_name"); _shopItemScript = type5.GetField("_scriptItem", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _scriptItemIcon = type6.GetField("_itemIcon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!ReflectionUtil.AllResolved(_modShops, _itemsGear, _itemsCons, _itemsTrad, _itemName, _itemDescription, _itemSecret, _itemType, _itemMod, _itemRarity, _itemShopItem, _modFolderName, _shopItemScript, _scriptItemIcon)) { Log.Warn("homebrewery's internals changed, can't read the item list"); return false; } _ready = true; return true; } } internal static class TundrasItemSearcherEasySettingsBridge { private const string TabName = "Tundra's Item Searcher"; private static bool _hooked; internal static void TryIntegrate() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown if (!_hooked) { _hooked = true; Settings.OnInitialized.AddListener(new UnityAction(BuildTab)); Settings.OnApplySettings.AddListener(new UnityAction(UiScale.RefreshAll)); } } private static void BuildTab() { SettingsTab orAddCustomTab = Settings.GetOrAddCustomTab("Tundra's Item Searcher"); orAddCustomTab.AddHeader("Keybinds"); orAddCustomTab.AddKeyButton("Open search panel", TundrasItemSearcherConfig.MenuKey); orAddCustomTab.AddHeader("Display"); AtlyssAdvancedSlider val = orAddCustomTab.AddAdvancedSlider("Panel size", TundrasItemSearcherConfig.ScaleStep); if (val != null) { val.OnValueChanged.AddListener((UnityAction)delegate { UiScale.RefreshAll(); }); } } } internal static class TundrasItemSearcherInventoryBridge { internal enum GrantResult { Success, InventoryFull, NoLocalPlayer, Unavailable } private static Type _itemDataType; private static FieldInfo _mainPlayer; private static FieldInfo _pInventory; private static FieldInfo _pSound; private static MethodInfo _checkInventoryFull; private static MethodInfo _addItem; private static FieldInfo _dataName; private static FieldInfo _dataQuantity; private static FieldInfo _dataMaxQuantity; private static FieldInfo _dataIsEquipped; private static FieldInfo _dataIsAltWeapon; private static FieldInfo _dataSlotNumber; private static FieldInfo _scriptItemName; private static FieldInfo _scriptItemMaxStack; private static FieldInfo _generalAudioSource; private static FieldInfo _purchaseSound; private static bool _ready; private static bool _failed; internal static GrantResult TryGrantItem(object scriptableItem) { if (scriptableItem == null || !EnsureReflection()) { return GrantResult.Unavailable; } try { object value = _mainPlayer.GetValue(null); if (value == null) { return GrantResult.NoLocalPlayer; } object value2 = _pInventory.GetValue(value); if (value2 == null) { return GrantResult.NoLocalPlayer; } if ((bool)_checkInventoryFull.Invoke(value2, new object[2] { scriptableItem, 1 })) { return GrantResult.InventoryFull; } object obj = Activator.CreateInstance(_itemDataType); _dataName.SetValue(obj, (_scriptItemName.GetValue(scriptableItem) as string) ?? ""); _dataQuantity.SetValue(obj, 1); _dataMaxQuantity.SetValue(obj, _scriptItemMaxStack.GetValue(scriptableItem)); _dataIsEquipped.SetValue(obj, false); _dataIsAltWeapon.SetValue(obj, false); _dataSlotNumber.SetValue(obj, 0); _addItem.Invoke(value2, new object[2] { obj, true }); PlayPurchaseSound(value); return GrantResult.Success; } catch (Exception ex) { Log.Warn("giving the item failed: " + ex.Message); return GrantResult.Unavailable; } } private static void PlayPurchaseSound(object player) { try { object value = _pSound.GetValue(player); if (value != null) { object? value2 = _generalAudioSource.GetValue(value); AudioSource val = (AudioSource)((value2 is AudioSource) ? value2 : null); object? value3 = _purchaseSound.GetValue(value); AudioClip val2 = (AudioClip)((value3 is AudioClip) ? value3 : null); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { val.PlayOneShot(val2); } } } catch (Exception ex) { Log.Warn("purchase sound failed: " + ex.Message); } } private static bool EnsureReflection() { if (_ready) { return true; } if (_failed) { return false; } Type type = ReflectionUtil.FindType("Player"); Type type2 = ReflectionUtil.FindType("PlayerInventory"); Type type3 = ReflectionUtil.FindType("ScriptableItem"); Type type4 = ReflectionUtil.FindType("PlayerSound"); _itemDataType = ReflectionUtil.FindType("ItemData"); if (type == null || type2 == null || _itemDataType == null || type3 == null || type4 == null) { Log.Warn("couldn't find the player and inventory types"); _failed = true; return false; } _mainPlayer = type.GetField("_mainPlayer", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _pInventory = type.GetField("_pInventory", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _pSound = type.GetField("_pSound", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _checkInventoryFull = type2.GetMethod("Check_InventoryFull", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _addItem = type2.GetMethod("Add_Item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _dataName = _itemDataType.GetField("_itemName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _dataQuantity = _itemDataType.GetField("_quantity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _dataMaxQuantity = _itemDataType.GetField("_maxQuantity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _dataIsEquipped = _itemDataType.GetField("_isEquipped", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _dataIsAltWeapon = _itemDataType.GetField("_isAltWeapon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _dataSlotNumber = _itemDataType.GetField("_slotNumber", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _scriptItemName = type3.GetField("_itemName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _scriptItemMaxStack = type3.GetField("_maxStackAmount", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _generalAudioSource = type4.GetField("_aSrcGeneral", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _purchaseSound = type4.GetField("_purchaseItemSound", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!ReflectionUtil.AllResolved(_mainPlayer, _pInventory, _pSound, _checkInventoryFull, _addItem, _dataName, _dataQuantity, _dataMaxQuantity, _dataIsEquipped, _dataIsAltWeapon, _dataSlotNumber, _scriptItemName, _scriptItemMaxStack, _generalAudioSource, _purchaseSound)) { Log.Warn("inventory internals changed, granting items won't work"); _failed = true; return false; } _ready = true; return true; } } internal static class TundrasItemSearcherMenuAnimator { private static Type _menuElementType; private static FieldInfo _menuRect; private static FieldInfo _rectValue; private static FieldInfo _lerpSpeed; private static FieldInfo _lerpType; private static FieldInfo _startDisabledOnEnable; private static MethodInfo _enableElement; private static object _scaleLerpType; private static bool _ready; private static bool _failed; internal static object TryAttach(GameObject target, RectTransform menuRect, float lerpSpeed) { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!EnsureReflection()) { return null; } try { Component val = target.AddComponent(_menuElementType); _menuRect.SetValue(val, menuRect); _rectValue.SetValue(val, new Vector2[2] { Vector2.one, Vector2.zero }); _lerpSpeed.SetValue(val, lerpSpeed); _lerpType.SetValue(val, _scaleLerpType); _startDisabledOnEnable.SetValue(val, false); return val; } catch (Exception ex) { Log.Warn("couldn't attach MenuElement, the panel won't animate: " + ex.Message); return null; } } internal static void SetEnabled(object menuElement, bool isEnabled) { if (menuElement == null || _enableElement == null) { return; } try { _enableElement.Invoke(menuElement, new object[1] { isEnabled }); } catch (Exception ex) { Log.Warn("couldn't toggle MenuElement: " + ex.Message); } } private static bool EnsureReflection() { if (_ready) { return true; } if (_failed) { return false; } _menuElementType = ReflectionUtil.FindType("MenuElement"); if (_menuElementType == null) { Log.Warn("no MenuElement, the panel won't animate"); _failed = true; return false; } Type nestedType = _menuElementType.GetNestedType("LerpType", BindingFlags.Public | BindingFlags.NonPublic); if (nestedType == null) { Log.Warn("MenuElement.LerpType is missing, the panel won't animate"); _failed = true; return false; } _menuRect = _menuElementType.GetField("menuRect", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _rectValue = _menuElementType.GetField("rectValue", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _lerpSpeed = _menuElementType.GetField("lerpSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _lerpType = _menuElementType.GetField("lerpType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _startDisabledOnEnable = _menuElementType.GetField("_startDisabledOnEnable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _enableElement = _menuElementType.GetMethod("EnableElement", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); try { _scaleLerpType = Enum.Parse(nestedType, "Scale"); } catch (Exception ex) { Log.Warn("MenuElement has no Scale lerp type: " + ex.Message); _failed = true; return false; } if (!ReflectionUtil.AllResolved(_menuRect, _rectValue, _lerpSpeed, _lerpType, _startDisabledOnEnable, _enableElement)) { Log.Warn("MenuElement changed, the panel won't animate"); _failed = true; return false; } _ready = true; return true; } } internal static class TundrasItemSearcherPlayerBridge { private const float HotkeySuppressSeconds = 0.2f; private const float MovementLockSeconds = 0.25f; private const int SoftLock = 1; private const int NoLock = 0; private static FieldInfo _tabMenuCurrent; private static FieldInfo _hotkeyBuffer; private static FieldInfo _cameraCurrent; private static FieldInfo _unlockedCamera; private static FieldInfo _mainPlayer; private static FieldInfo _playerMove; private static MethodInfo _applyMovementLock; private static FieldInfo _movementLockType; private static FieldInfo _movLockBuffer; private static object _softLockValue; private static object _noLockValue; private static bool _ready; private static bool _failed; private static bool _warnedSetField; private static bool _warnedMovementLock; internal static void HoldInputSuppressed() { if (EnsureReflection()) { SetField(_tabMenuCurrent.GetValue(null), _hotkeyBuffer, 0.2f); LockMovement(); } } internal static void HoldCursorFree() { if (EnsureReflection()) { SetField(_cameraCurrent.GetValue(null), _unlockedCamera, true); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } internal static void Release() { if (EnsureReflection()) { SetField(_cameraCurrent.GetValue(null), _unlockedCamera, false); object obj = LocalPlayerMove(); if (obj != null && _noLockValue != null) { SetField(obj, _movementLockType, _noLockValue); SetField(obj, _movLockBuffer, 0f); } } } private static void LockMovement() { if (_applyMovementLock == null || _softLockValue == null) { return; } object obj = LocalPlayerMove(); if (obj == null) { return; } try { _applyMovementLock.Invoke(obj, new object[2] { _softLockValue, 0.25f }); } catch (Exception ex) { if (!_warnedMovementLock) { _warnedMovementLock = true; Log.Warn("movement lock failed, you'll be able to walk while the panel is open: " + ex.Message); } } } private static object LocalPlayerMove() { if (_mainPlayer == null || _playerMove == null) { return null; } object value = _mainPlayer.GetValue(null); if (value != null) { return _playerMove.GetValue(value); } return null; } private static void SetField(object target, FieldInfo field, object value) { if (target == null || field == null) { return; } try { field.SetValue(target, value); } catch (Exception ex) { if (!_warnedSetField) { _warnedSetField = true; Log.Warn("couldn't write " + field.Name + ": " + ex.Message); } } } private static bool EnsureReflection() { if (_ready) { return true; } if (_failed) { return false; } Type type = ReflectionUtil.FindType("TabMenu"); Type type2 = ReflectionUtil.FindType("CameraFunction"); Type type3 = ReflectionUtil.FindType("Player"); if (type == null || type2 == null || type3 == null) { Log.Warn("couldn't find TabMenu, CameraFunction or Player"); _failed = true; return false; } _tabMenuCurrent = type.GetField("_current", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _hotkeyBuffer = type.GetField("_hotkeyBuffer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _cameraCurrent = type2.GetField("_current", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _unlockedCamera = type2.GetField("_unlockedCamera", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _mainPlayer = type3.GetField("_mainPlayer", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _playerMove = type3.GetField("_pMove", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!ReflectionUtil.AllResolved(_tabMenuCurrent, _hotkeyBuffer, _cameraCurrent, _unlockedCamera)) { Log.Warn("TabMenu or CameraFunction changed, cursor and hotkey handling are off"); _failed = true; return false; } ResolveMovementLock(); _ready = true; return true; } private static void ResolveMovementLock() { Type type = ReflectionUtil.FindType("PlayerMove"); Type type2 = ReflectionUtil.FindType("MovementLockType"); if (type == null || type2 == null || _mainPlayer == null || _playerMove == null) { return; } _applyMovementLock = type.GetMethod("Apply_MovementLockCondition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { type2, typeof(float) }, null); _movementLockType = type.GetField("_movementLockType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _movLockBuffer = type.GetField("_movLockBuffer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); try { _softLockValue = Enum.ToObject(type2, 1); _noLockValue = Enum.ToObject(type2, 0); } catch { _softLockValue = null; _noLockValue = null; } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.tundra.atlyss.tundrasitemsearcher", "Tundra's Item Searcher", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class TundrasItemSearcherPlugin : BaseUnityPlugin { internal static TundrasItemSearcherPlugin Instance; private ItemSearchPanelUI _panel; internal BuyPromptUI BuyPrompt { get; private set; } private void Awake() { Instance = this; Log.Source = ((BaseUnityPlugin)this).Logger; TundrasItemSearcherConfig.Bind(((BaseUnityPlugin)this).Config); BuyPrompt = new BuyPromptUI(); _panel = new ItemSearchPanelUI(); TundrasItemSearcherEasySettingsBridge.TryIntegrate(); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(TundrasItemSearcherConfig.MenuKey.Value)) { _panel.ToggleVisible(); } else if (_panel.IsVisible && Input.GetKeyDown((KeyCode)27)) { _panel.Close(); } _panel.Tick(); } private void LateUpdate() { _panel.LateTick(); } } internal static class Log { internal static ManualLogSource Source; internal static void Warn(string message) { if (Source != null) { Source.LogWarning((object)message); } } } internal static class TundrasItemSearcherConfig { internal const int MinScaleStep = -10; internal const int MaxScaleStep = 10; internal static ConfigEntry MenuKey; internal static ConfigEntry ScaleStep; internal static void Bind(ConfigFile config) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown MenuKey = config.Bind("UI", "MenuKey", (KeyCode)286, "Key to open/close the item search panel."); ScaleStep = config.Bind("UI", "ScaleStep", 0, new ConfigDescription("Panel size adjustment. 0 is the default size, negative is smaller, positive is larger.", (AcceptableValueBase)(object)new AcceptableValueRange(-10, 10), new object[0])); } } internal enum ItemCategory { Unknown, Helm, Chestpiece, Leggings, Cape, Weapon, Shield, Consumable, TradeItem } internal sealed class ItemInfo { internal string Name; internal string Description; internal ItemCategory Category; internal string SourceModName; internal string Rarity; internal Sprite IconSprite; internal object ScriptItemRef; } internal static class UiScale { private const float ReferenceWidth = 1920f; private const float ReferenceHeight = 1080f; private const float Dampening = 0.5f; private const float Minimum = 0.8f; private const float StepAmount = 0.05f; private static readonly List Scalers = new List(); internal static void Register(CanvasScaler scaler) { if (!((Object)(object)scaler == (Object)null) && !Scalers.Contains(scaler)) { Scalers.Add(scaler); Apply(scaler); } } internal static void RefreshAll() { foreach (CanvasScaler scaler in Scalers) { Apply(scaler); } } internal static void Apply(CanvasScaler scaler) { if (!((Object)(object)scaler == (Object)null)) { scaler.uiScaleMode = (ScaleMode)0; scaler.scaleFactor = Factor() * UserScale(); } } private static float Factor() { if (Screen.width <= 0 || Screen.height <= 0) { return 1f; } float num = Mathf.Min((float)Screen.width / 1920f, (float)Screen.height / 1080f); return Mathf.Max(Mathf.Pow(num, 0.5f), 0.8f); } private static float UserScale() { if (TundrasItemSearcherConfig.ScaleStep == null) { return 1f; } int num = Mathf.Clamp(TundrasItemSearcherConfig.ScaleStep.Value, -10, 10); return 1f + (float)num * 0.05f; } } internal static class GameAssets { internal const string ClickSound = "_uiClick01"; internal const string OpenSound = "_uiGameTabMenu"; internal const string CloseSound = "_uiGameTabMenuClose"; internal const string ItemSlotSprite = "bk_04"; internal const float ClickVolume = 0.5f; internal const float OpenVolume = 0.75f; internal const float CloseVolume = 0.55f; private static readonly PropertyInfo MixerGroupProperty = typeof(AudioSource).GetProperty("outputAudioMixerGroup", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); internal static void RouteToGuiChannel(AudioSource source) { if (!((Object)(object)source == (Object)null) && !(MixerGroupProperty == null) && MixerGroupProperty.GetValue(source, null) == null) { object obj = FindGuiMixerGroup(); if (obj != null) { MixerGroupProperty.SetValue(source, obj, null); } } } private static object FindGuiMixerGroup() { Type type = ReflectionUtil.FindType("TabMenu"); if (type != null && MixerGroupProperty != null) { FieldInfo field = type.GetField("_current", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo field2 = type.GetField("_aSrc", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && field2 != null) { object value = field.GetValue(null); AudioSource val = (AudioSource)((value != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val != (Object)null) { object value2 = MixerGroupProperty.GetValue(val, null); if (value2 != null) { return value2; } } } } Type type2 = ReflectionUtil.FindType("UnityEngine.Audio.AudioMixerGroup"); if (type2 == null) { return null; } Object[] array = Resources.FindObjectsOfTypeAll(type2); foreach (Object val2 in array) { if (!(val2 == (Object)null) && val2.name != null) { string text = val2.name.ToLowerInvariant(); if (text.Contains("gui") || text.Contains("ui")) { return val2; } } } return null; } internal static Sprite LoadFromDisk(string fileName) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) string text = ResolveAssetPath(fileName); if (text == null) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, File.ReadAllBytes(text)); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } private static string ResolveAssetPath(string fileName) { string path = Path.GetDirectoryName(typeof(TundrasItemSearcherPlugin).Assembly.Location) ?? ""; string[] array = new string[3] { Path.Combine(path, "Assets", fileName), Path.Combine(path, fileName), Path.Combine(path, "TundrasItemSearcher", "Assets", fileName) }; string[] array2 = array; foreach (string text in array2) { if (File.Exists(text)) { return text; } } return null; } internal static Sprite FindSprite(string exactName) { Sprite[] array = Resources.FindObjectsOfTypeAll(); foreach (Sprite val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name == exactName) { return val; } } return null; } internal static AudioClip FindAudioClip(string exactName) { AudioClip[] array = Resources.FindObjectsOfTypeAll(); foreach (AudioClip val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name == exactName) { return val; } } return null; } internal static AudioSource CreatePersistentAudioSource(string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GameObject val = new GameObject(name); Object.DontDestroyOnLoad((Object)(object)val); AudioSource val2 = val.AddComponent(); val2.playOnAwake = false; return val2; } } internal static class TundrasItemSearcherFonts { private static TMP_FontAsset _centaur; private static bool _searched; internal static TMP_FontAsset Centaur { get { if (!_searched) { _searched = true; _centaur = FindByName("CENTAUR"); } return _centaur; } } private static TMP_FontAsset FindByName(string nameFragment) { TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll(); foreach (TMP_FontAsset val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name != null && ((Object)val).name.ToUpperInvariant().Contains(nameFragment)) { return val; } } return null; } } internal static class ReflectionUtil { internal const BindingFlags Instance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; internal const BindingFlags Static = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; internal static Type FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName); if (type != null) { return type; } } return null; } internal static PropertyInfo FindProperty(Type type, string name) { Type type2 = type; while (type2 != null) { PropertyInfo property = type2.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { return property; } type2 = type2.BaseType; } return null; } internal static FieldInfo FindField(Type type, string name) { Type type2 = type; while (type2 != null) { FieldInfo field = type2.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { return field; } type2 = type2.BaseType; } return null; } internal static bool AllResolved(params object[] members) { foreach (object obj in members) { if (obj == null) { return false; } } return true; } } internal static class TundrasItemSearcherTooltip { private static FieldInfo _tooltipCurrent; private static MethodInfo _applyItemTooltip; private static MethodInfo _applyGenericTooltip; private static MethodInfo _disableAllTooltips; private static bool _tooltipReady; private static bool _tooltipFailed; private static FieldInfo _errorPromptCurrent; private static MethodInfo _initErrorPrompt; private static bool _errorPromptReady; private static bool _errorPromptFailed; internal static void ShowItemTooltip(object scriptItem) { if (scriptItem != null) { InvokeOnTooltipManager(_applyItemTooltip, new object[2] { scriptItem, false }); } } internal static void ShowGenericMessage(string message) { InvokeOnTooltipManager(_applyGenericTooltip, new object[1] { message }); } internal static void HideTooltip() { InvokeOnTooltipManager(_disableAllTooltips, null); } internal static void ShowErrorPrompt(string message) { if (!EnsureErrorPromptReflection()) { return; } try { object value = _errorPromptCurrent.GetValue(null); if (value != null) { _initErrorPrompt.Invoke(value, new object[1] { message }); } } catch (Exception ex) { Log.Warn("error prompt failed: " + ex.Message); } } private static void InvokeOnTooltipManager(MethodInfo method, object[] args) { if (!EnsureTooltipReflection() || method == null) { return; } try { object value = _tooltipCurrent.GetValue(null); if (value != null) { method.Invoke(value, args); } } catch (Exception ex) { Log.Warn("tooltip call failed: " + ex.Message); } } private static bool EnsureTooltipReflection() { if (_tooltipReady) { return true; } if (_tooltipFailed) { return false; } Type type = ReflectionUtil.FindType("ToolTipManager"); if (type == null) { Log.Warn("no ToolTipManager, item tooltips are off"); _tooltipFailed = true; return false; } _tooltipCurrent = type.GetField("_current", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _applyItemTooltip = type.GetMethod("Apply_ItemDataToolTip", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _applyGenericTooltip = type.GetMethod("Apply_GenericToolTip", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); _disableAllTooltips = type.GetMethod("Disable_AllTooltips", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!ReflectionUtil.AllResolved(_tooltipCurrent, _applyItemTooltip, _disableAllTooltips)) { Log.Warn("ToolTipManager changed, item tooltips are off"); _tooltipFailed = true; return false; } _tooltipReady = true; return true; } private static bool EnsureErrorPromptReflection() { if (_errorPromptReady) { return true; } if (_errorPromptFailed) { return false; } Type type = ReflectionUtil.FindType("ErrorPromptTextManager"); if (type == null) { Log.Warn("no ErrorPromptTextManager, error text is off"); _errorPromptFailed = true; return false; } _errorPromptCurrent = type.GetField("current", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); _initErrorPrompt = type.GetMethod("Init_ErrorPrompt", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!ReflectionUtil.AllResolved(_errorPromptCurrent, _initErrorPrompt)) { Log.Warn("ErrorPromptTextManager changed, error text is off"); _errorPromptFailed = true; return false; } _errorPromptReady = true; return true; } } internal sealed class ItemSearchPanelUI { private sealed class CategoryToggle { internal readonly string Key; internal readonly string Label; internal readonly Rect Rect; internal CategoryToggle(string key, string label, Rect rect) { //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) Key = key; Label = label; Rect = rect; } } private const float PanelWidth = 705f; private const float PanelHeight = 500f; private const float PanelAnchorX = 0.01f; private const float MenuAnimationLerpSpeed = 45f; private const int SmallFontSize = 16; private const int TinyFontSize = 12; private const int SlotLabelFontSize = 16; private const int GridColumns = 8; private const int GridRows = 7; private const float CellSpacing = 2f; private const string ArmorKey = "Armor"; private static readonly Rect ItemDisplayRect = new Rect(0.1021f, 0.1231f, 0.534f, 0.6697f); private static readonly Rect CurrentlyDisplayingRect = new Rect(0.1106f, 0.8108f, 0.5106f, 0.0571f); private static readonly Rect SearchbarRect = new Rect(0.1f, 0.012f, 0.534f, 0.0661f); private static readonly Rect ModListRect = new Rect(0.6915f, 0.1291f, 0.283f, 0.2132f); private static readonly Rect PreviousPageRect = new Rect(0.0043f, 0.6817f, 0.0766f, 0.1111f); private static readonly Rect NextPageRect = new Rect(0.0043f, 0.5706f, 0.0766f, 0.1081f); private static readonly CategoryToggle[] Categories = new CategoryToggle[8] { new CategoryToggle("Armor", "Armor", new Rect(0.9106f, 0.9009f, 0.0234f, 0.033f)), new CategoryToggle("Helm", "Helm", new Rect(0.9106f, 0.8108f, 0.0234f, 0.033f)), new CategoryToggle("Chestpiece", "Chestpiece", new Rect(0.9106f, 0.7628f, 0.0234f, 0.033f)), new CategoryToggle("Leggings", "Leggings", new Rect(0.9106f, 0.7177f, 0.0234f, 0.033f)), new CategoryToggle("Cape", "Cape", new Rect(0.9106f, 0.6757f, 0.0234f, 0.033f)), new CategoryToggle("Weaponry", "Weaponry", new Rect(0.9106f, 0.6336f, 0.0234f, 0.033f)), new CategoryToggle("Consumeable", "Consumable", new Rect(0.9106f, 0.5375f, 0.0234f, 0.033f)), new CategoryToggle("TradeItem", "Trade Item", new Rect(0.9106f, 0.4474f, 0.0234f, 0.033f)) }; private static readonly string[] ArmorSubtypes = new string[4] { "Helm", "Chestpiece", "Leggings", "Cape" }; private static readonly Dictionary RarityColors = new Dictionary { { "Common", ParseHex("848585") }, { "Rare", ParseHex("46627F") }, { "Exotic", ParseHex("524267") }, { "Cosmetic", ParseHex("855F38") }, { "Legendary", ParseHex("848585") }, { "Quest", ParseHex("848585") } }; private readonly Dictionary _categoryEnabled = new Dictionary(); private readonly Dictionary _categoryOverlays = new Dictionary(); private readonly Dictionary _modListEntries = new Dictionary(); private GameObject _rootObject; private RectTransform _panelRect; private CanvasScaler _scaler; private bool _built; private bool _isOpen; private AudioSource _audioSource; private AudioClip _clickClip; private AudioClip _openClip; private AudioClip _closeClip; private object _menuElement; private Sprite _overlaySprite; private Sprite _slotSprite; private float _cellSize = 52f; private int _itemsPerPage = 56; private List _allItems = new List(); private List _filteredItems = new List(); private bool _itemsLoaded; private int _currentPage; private string _searchText = ""; private string _selectedModName; private TextMeshProUGUI _currentlyDisplayingText; private Transform _itemGrid; private Transform _modListContent; internal bool IsVisible => _isOpen; internal ItemSearchPanelUI() { CategoryToggle[] categories = Categories; foreach (CategoryToggle categoryToggle in categories) { _categoryEnabled[categoryToggle.Key] = true; } } internal void ToggleVisible() { if (_isOpen) { Close(); } else { Show(); } } internal void Close() { if (_isOpen) { _isOpen = false; if ((Object)(object)TundrasItemSearcherPlugin.Instance != (Object)null) { TundrasItemSearcherPlugin.Instance.BuyPrompt.Hide(); } PlaySound(ref _closeClip, "_uiGameTabMenuClose", 0.55f); TundrasItemSearcherPlayerBridge.Release(); if (_menuElement != null) { TundrasItemSearcherMenuAnimator.SetEnabled(_menuElement, isEnabled: false); } else { _rootObject.SetActive(false); } } } private void Show() { EnsureBuilt(); UiScale.Register(_scaler); _rootObject.SetActive(true); _isOpen = true; PlaySound(ref _openClip, "_uiGameTabMenu", 0.75f); if (_menuElement != null) { TundrasItemSearcherMenuAnimator.SetEnabled(_menuElement, isEnabled: true); } if (!_itemsLoaded) { LoadItems(); } } internal void Tick() { if (_isOpen) { TundrasItemSearcherPlayerBridge.HoldInputSuppressed(); } } internal void LateTick() { if (_isOpen) { TundrasItemSearcherPlayerBridge.HoldCursorFree(); } } private void LoadItems() { _allItems = HomebreweryBridge.LoadAllItems(); if (_allItems.Count != 0) { _itemsLoaded = true; RebuildModList(); RecomputeFilter(); } } private void EnsureBuilt() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_0102: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) if (!_built) { _built = true; _rootObject = new GameObject("TundrasItemSearcher_Panel"); Object.DontDestroyOnLoad((Object)(object)_rootObject); Canvas val = _rootObject.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 500; _scaler = _rootObject.AddComponent(); UiScale.Register(_scaler); _rootObject.AddComponent(); EnsureEventSystemExists(); GameObject val2 = new GameObject("Panel"); val2.transform.SetParent(_rootObject.transform, false); _panelRect = val2.AddComponent(); _panelRect.pivot = new Vector2(0f, 0.5f); _panelRect.anchorMin = new Vector2(0.01f, 0.5f); _panelRect.anchorMax = new Vector2(0.01f, 0.5f); _panelRect.sizeDelta = new Vector2(705f, 500f); _panelRect.anchoredPosition = Vector2.zero; Sprite val3 = GameAssets.LoadFromDisk("TundraISUI.png"); Image val4 = val2.AddComponent(); if ((Object)(object)val3 != (Object)null) { val4.sprite = val3; } _overlaySprite = GameAssets.LoadFromDisk("showButtonOverlay.png"); _slotSprite = GameAssets.FindSprite("bk_04"); _audioSource = GameAssets.CreatePersistentAudioSource("TundrasItemSearcher_Audio"); Rect itemDisplayRect = ItemDisplayRect; float num = 705f * ((Rect)(ref itemDisplayRect)).width; Rect itemDisplayRect2 = ItemDisplayRect; float num2 = 500f * ((Rect)(ref itemDisplayRect2)).height; float num3 = (num - 14f) / 8f; float num4 = (num2 - 12f) / 7f; _cellSize = Mathf.Min(num3, num4); _itemsPerPage = 56; BuildContents(val2.transform); _rootObject.SetActive(false); _menuElement = TundrasItemSearcherMenuAnimator.TryAttach(val2, _panelRect, 45f); } } private static void EnsureEventSystemExists() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_001d: 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) EventSystem[] array = Resources.FindObjectsOfTypeAll(); foreach (EventSystem val in array) { if ((Object)(object)val != (Object)null) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return; } } } GameObject val2 = new GameObject("TundrasItemSearcher_EventSystem"); Object.DontDestroyOnLoad((Object)(object)val2); val2.AddComponent(); val2.AddComponent(); } private void BuildContents(Transform parent) { //IL_001d: 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_0063: Unknown result type (might be due to invalid IL or missing references) BuildItemGrid(parent); BuildSearchbar(parent); BuildModList(parent); _currentlyDisplayingText = CreateText(parent, "CurrentlyDisplaying", CurrentlyDisplayingRect, 16); ((TMP_Text)_currentlyDisplayingText).text = "All Items"; CreateButton(parent, "PreviousPage", PreviousPageRect, delegate { ChangePage(-1); }); CreateButton(parent, "NextPage", NextPageRect, delegate { ChangePage(1); }); CategoryToggle[] categories = Categories; foreach (CategoryToggle category in categories) { BuildCategoryButton(parent, category); } RefreshCategoryOverlays(); } private void BuildItemGrid(Transform parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ItemDisplay"); val.transform.SetParent(parent, false); ApplyAnchorRect(val.AddComponent(), ItemDisplayRect); GridLayoutGroup val2 = val.AddComponent(); val2.cellSize = new Vector2(_cellSize, _cellSize); val2.spacing = new Vector2(2f, 2f); ((LayoutGroup)val2).childAlignment = (TextAnchor)0; val2.constraint = (Constraint)1; val2.constraintCount = 8; _itemGrid = val.transform; } private void BuildSearchbar(Transform parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: 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_003a: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown GameObject val = new GameObject("ItemSearchbar"); val.transform.SetParent(parent, false); ApplyAnchorRect(val.AddComponent(), SearchbarRect); TMP_InputField val2 = val.AddComponent(); GameObject val3 = new GameObject("Text Area"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent(); Stretch(val4); val3.AddComponent(); GameObject val5 = new GameObject("Text"); val5.transform.SetParent(val3.transform, false); Stretch(val5.AddComponent()); TextMeshProUGUI val6 = val5.AddComponent(); StyleText(val6, 16, (TextAlignmentOptions)4097); val2.textViewport = val4; val2.textComponent = (TMP_Text)(object)val6; val2.lineType = (LineType)0; ((UnityEvent)(object)val2.onValueChanged).AddListener((UnityAction)delegate(string value) { _searchText = value; _currentPage = 0; RecomputeFilter(); }); } private void BuildModList(Transform parent) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: 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) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ModList"); val.transform.SetParent(parent, false); ApplyAnchorRect(val.AddComponent(), ModListRect); ((Graphic)val.AddComponent()).color = Color.clear; val.AddComponent(); GameObject val2 = new GameObject("Viewport"); val2.transform.SetParent(val.transform, false); RectTransform val3 = val2.AddComponent(); Stretch(val3); GameObject val4 = new GameObject("Content"); val4.transform.SetParent(val2.transform, false); RectTransform val5 = val4.AddComponent(); val5.anchorMin = new Vector2(0f, 1f); val5.anchorMax = new Vector2(1f, 1f); val5.pivot = new Vector2(0.5f, 1f); val5.sizeDelta = Vector2.zero; VerticalLayoutGroup val6 = val4.AddComponent(); ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val6).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val6).spacing = 2f; val4.AddComponent().verticalFit = (FitMode)2; ScrollRect val7 = val.AddComponent(); val7.content = val5; val7.viewport = val3; val7.horizontal = false; val7.vertical = true; _modListContent = val4.transform; } private void BuildCategoryButton(Transform parent, CategoryToggle category) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown GameObject val = CreateButton(parent, "Show" + category.Key, category.Rect, delegate { ToggleCategory(category.Key); }); GameObject val2 = new GameObject("Overlay"); val2.transform.SetParent(val.transform, false); Stretch(val2.AddComponent()); Image val3 = val2.AddComponent(); if ((Object)(object)_overlaySprite != (Object)null) { val3.sprite = _overlaySprite; } ((Graphic)val3).raycastTarget = false; _categoryOverlays[category.Key] = val3; } private GameObject CreateButton(Transform parent, string name, Rect anchorRect, Action onClick) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_008a: Expected O, but got Unknown GameObject val = new GameObject(name + "Button"); val.transform.SetParent(parent, false); ApplyAnchorRect(val.AddComponent(), anchorRect); Image val2 = val.AddComponent(); ((Graphic)val2).color = new Color(1f, 1f, 1f, 0.02f); Button val3 = val.AddComponent