Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SortAndSearch v1.0.0
SortAndSearch.dll
Decompiled 21 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("SortAndSearch")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7952970dcc3038318dcc481e9f364ed6b8b1428b")] [assembly: AssemblyProduct("SortAndSearch")] [assembly: AssemblyTitle("SortAndSearch")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DarthJML.SortAndSearch { internal enum SearchCategoryTab { All, Food, Gear, Materials, Ammo } internal enum PullAmountMode { OneStack, SingleItem, AllAvailable } internal sealed class ChestStock { public Container Container; public float Distance; public int Count; public bool IsOwnedLocally; public bool IsInUseRemote; } internal sealed class BaseSearchEntry { public string SharedName; public string LocalizedName; public string PrefabName; public Sprite Icon; public ItemData SampleItem; public int TotalCount; public int AvailableToPull; public int MaxStackSize; public float NearestDistance; public List<ChestStock> Chests = new List<ChestStock>(); } internal static class BaseSearchEngine { private sealed class PingMarker { public Container Target; public GameObject BeamObject; public Material BeamMaterial; public float RemainingSeconds; public string Label; } internal const string CybercratePrefabPrefix = "RoboticInbox"; private static readonly FieldRef<Container, ZNetView> ContainerNView = AccessTools.FieldRefAccess<Container, ZNetView>("m_nview"); private static readonly FieldRef<Container, uint> ContainerLastRevision = AccessTools.FieldRefAccess<Container, uint>("m_lastRevision"); private static readonly Func<Container, long, bool> ContainerCheckAccess = AccessTools.MethodDelegate<Func<Container, long, bool>>(AccessTools.Method(typeof(Container), "CheckAccess", (Type[])null, (Type[])null), (object)null, true); private static readonly FieldRef<InventoryGui, Container> GuiCurrentContainer = AccessTools.FieldRefAccess<InventoryGui, Container>("m_currentContainer"); private static readonly List<PingMarker> ActivePings = new List<PingMarker>(); internal static string LastStatusMessage = ""; internal static float LastStatusTime = -999f; internal static int LastScannedChestCount; internal static Container GetCurrentOpenContainer() { InventoryGui instance = InventoryGui.instance; if (!((Object)(object)instance != (Object)null)) { return null; } return GuiCurrentContainer.Invoke(instance); } internal static bool IsCybercrate(Container c) { if ((Object)(object)c == (Object)null) { return false; } string prefabName = Utils.GetPrefabName(((Component)c).gameObject); if (!string.IsNullOrEmpty(prefabName) && prefabName.StartsWith("RoboticInbox", StringComparison.OrdinalIgnoreCase)) { return true; } if (!string.IsNullOrEmpty(c.m_name)) { return c.m_name.IndexOf("Robotic Inbox", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } internal static bool CanRead(Container c, long playerId) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)c == (Object)null || c.GetInventory() == null) { return false; } ZNetView val = ContainerNView.Invoke(c); if ((Object)(object)val == (Object)null || !val.IsValid()) { return false; } if ((Object)(object)((Component)c).GetComponentInParent<TombStone>() != (Object)null) { return false; } if (!ContainerCheckAccess(c, playerId)) { return false; } if (c.m_checkGuardStone && !PrivateArea.CheckAccess(((Component)c).transform.position, 0f, false, false)) { return false; } return true; } internal static bool IsContainerInUseByAnyone(Container c) { if ((Object)(object)c == (Object)null) { return true; } if (c.IsInUse()) { return true; } ZNetView val = ContainerNView.Invoke(c); if ((Object)(object)val == (Object)null || !val.IsValid()) { return true; } ZDO zDO = val.GetZDO(); if (zDO != null) { return zDO.GetInt(ZDOVars.s_inUse, 0) != 0; } return false; } internal static bool CanWrite(Container c, long playerId) { if (!CanRead(c, playerId)) { return false; } if (!c.IsOwner() || IsContainerInUseByAnyone(c)) { return false; } ZNetView val = ContainerNView.Invoke(c); if ((Object)(object)val != (Object)null && val.IsValid()) { return ContainerLastRevision.Invoke(c) == val.GetZDO().DataRevision; } return false; } internal static bool CanWriteDestination(Container c, long playerId) { if (!CanRead(c, playerId)) { return false; } if (!c.IsOwner()) { return false; } ZNetView val = ContainerNView.Invoke(c); if ((Object)(object)val != (Object)null && val.IsValid()) { return ContainerLastRevision.Invoke(c) == val.GetZDO().DataRevision; } return false; } internal static List<BaseSearchEntry> ScanBase(string query, SearchCategoryTab tab, int keepInChest, Container excludeContainer) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00db: Unknown result type (might be due to invalid IL or missing references) List<BaseSearchEntry> list = new List<BaseSearchEntry>(); LastScannedChestCount = 0; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return list; } SortAndSearchPlugin.Containers.RemoveAll((Container c) => (Object)(object)c == (Object)null); long playerID = localPlayer.GetPlayerID(); Vector3 val = (((Object)(object)excludeContainer != (Object)null) ? ((Component)excludeContainer).transform.position : ((Component)localPlayer).transform.position); float value = SortAndSearchPlugin.SearchRadius.Value; float num = value * value; Dictionary<string, BaseSearchEntry> dictionary = new Dictionary<string, BaseSearchEntry>(StringComparer.Ordinal); for (int num2 = 0; num2 < SortAndSearchPlugin.Containers.Count; num2++) { Container val2 = SortAndSearchPlugin.Containers[num2]; if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)excludeContainer) { continue; } Vector3 val3 = ((Component)val2).transform.position - val; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude > num || !CanRead(val2, playerID)) { continue; } LastScannedChestCount++; float num3 = Mathf.Sqrt(sqrMagnitude); bool isOwnedLocally = val2.IsOwner(); bool flag = IsContainerInUseByAnyone(val2); List<ItemData> allItems = val2.GetInventory().GetAllItems(); if (allItems == null || allItems.Count == 0) { continue; } Dictionary<string, int> dictionary2 = new Dictionary<string, int>(StringComparer.Ordinal); Dictionary<string, ItemData> dictionary3 = new Dictionary<string, ItemData>(StringComparer.Ordinal); for (int num4 = 0; num4 < allItems.Count; num4++) { ItemData val4 = allItems[num4]; if (val4 != null && val4.m_shared != null && val4.m_stack > 0) { string name = val4.m_shared.m_name; if (!dictionary2.TryGetValue(name, out var value2)) { dictionary2[name] = val4.m_stack; dictionary3[name] = val4; } else { dictionary2[name] = value2 + val4.m_stack; } } } foreach (KeyValuePair<string, int> item in dictionary2) { ItemData val5 = dictionary3[item.Key]; SharedData shared = val5.m_shared; if (!MatchesCategoryTab(shared, tab)) { continue; } string text = RecipeSorter.LocalizeSafe(shared.m_name); string prefabName = (((Object)(object)val5.m_dropPrefab != (Object)null) ? ((Object)val5.m_dropPrefab).name : ""); if (MatchesSearchQuery(text, prefabName, shared, query)) { if (!dictionary.TryGetValue(item.Key, out var value3)) { value3 = new BaseSearchEntry { SharedName = item.Key, LocalizedName = text, PrefabName = prefabName, Icon = val5.GetIcon(), SampleItem = val5, MaxStackSize = Mathf.Max(1, shared.m_maxStackSize), NearestDistance = num3 }; dictionary[item.Key] = value3; } value3.TotalCount += item.Value; if (!flag) { int num5 = Math.Max(0, item.Value - keepInChest); value3.AvailableToPull += num5; } if (num3 < value3.NearestDistance) { value3.NearestDistance = num3; } value3.Chests.Add(new ChestStock { Container = val2, Distance = num3, Count = item.Value, IsOwnedLocally = isOwnedLocally, IsInUseRemote = flag }); } } } foreach (BaseSearchEntry value5 in dictionary.Values) { value5.Chests.Sort((ChestStock a, ChestStock b) => a.Distance.CompareTo(b.Distance)); list.Add(value5); } string qTrim = (query ?? "").Trim(); list.Sort(delegate(BaseSearchEntry a, BaseSearchEntry b) { if (qTrim.Length > 0) { bool flag2 = a.LocalizedName.StartsWith(qTrim, StringComparison.OrdinalIgnoreCase); bool flag3 = b.LocalizedName.StartsWith(qTrim, StringComparison.OrdinalIgnoreCase); if (flag2 != flag3) { if (!flag2) { return 1; } return -1; } } if (tab == SearchCategoryTab.Food) { float value4 = ((a.SampleItem?.m_shared != null) ? (a.SampleItem.m_shared.m_food + a.SampleItem.m_shared.m_foodStamina + a.SampleItem.m_shared.m_foodEitr) : 0f); int num6 = ((b.SampleItem?.m_shared != null) ? (b.SampleItem.m_shared.m_food + b.SampleItem.m_shared.m_foodStamina + b.SampleItem.m_shared.m_foodEitr) : 0f).CompareTo(value4); if (num6 != 0) { return num6; } } return string.Compare(a.LocalizedName, b.LocalizedName, StringComparison.CurrentCultureIgnoreCase); }); return list; } private static bool MatchesCategoryTab(SharedData shared, SearchCategoryTab tab) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0028: Invalid comparison between Unknown and I4 //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Invalid comparison between Unknown and I4 //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Invalid comparison between Unknown and I4 //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Invalid comparison between Unknown and I4 //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Invalid comparison between Unknown and I4 //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 if (tab == SearchCategoryTab.All) { return true; } ItemType itemType = shared.m_itemType; switch (tab) { case SearchCategoryTab.Food: return (int)itemType == 2; case SearchCategoryTab.Gear: if ((int)itemType != 3 && (int)itemType != 14 && (int)itemType != 22 && (int)itemType != 4 && (int)itemType != 5 && (int)itemType != 6 && (int)itemType != 7 && (int)itemType != 11 && (int)itemType != 17 && (int)itemType != 12 && (int)itemType != 19 && (int)itemType != 15 && (int)itemType != 18 && (int)itemType != 24) { return (int)itemType == 20; } return true; case SearchCategoryTab.Materials: if ((int)itemType != 1 && (int)itemType != 16 && (int)itemType != 13) { return (int)itemType == 21; } return true; case SearchCategoryTab.Ammo: if ((int)itemType != 9) { return (int)itemType == 23; } return true; default: return true; } } private static bool MatchesSearchQuery(string locName, string prefabName, SharedData shared, string rawQuery) { if (string.IsNullOrWhiteSpace(rawQuery)) { return true; } FoodArchetype foodArchetype = RecipeSorter.ClassifyFood(shared); string[] array = rawQuery.Trim().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { bool flag = RecipeSorter.ContainsIgnoreCase(locName, text) || RecipeSorter.ContainsIgnoreCase(prefabName, text); if (!flag && foodArchetype != FoodArchetype.None) { if (RecipeSorter.ContainsIgnoreCase("food", text) && foodArchetype != FoodArchetype.MeadOrPotion) { flag = true; } else if ((RecipeSorter.ContainsIgnoreCase("health", text) || text.Equals("hp", StringComparison.OrdinalIgnoreCase)) && foodArchetype == FoodArchetype.Health) { flag = true; } else if ((RecipeSorter.ContainsIgnoreCase("stamina", text) || text.Equals("stam", StringComparison.OrdinalIgnoreCase)) && foodArchetype == FoodArchetype.Stamina) { flag = true; } else if (RecipeSorter.ContainsIgnoreCase("eitr", text) && foodArchetype == FoodArchetype.Eitr) { flag = true; } else if (RecipeSorter.ContainsIgnoreCase("mead", text) && foodArchetype == FoodArchetype.MeadOrPotion) { flag = true; } } if (!flag) { return false; } } return true; } internal static void PullItem(BaseSearchEntry entry, Container destContainer, PullAmountMode mode, int keepInChest) { //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || entry == null) { return; } long playerID = localPlayer.GetPlayerID(); Inventory inventory; string text; if ((Object)(object)destContainer != (Object)null) { if (!CanWriteDestination(destContainer, playerID)) { SetStatus("Cannot write to open crate right now (syncing)."); return; } inventory = destContainer.GetInventory(); text = RecipeSorter.LocalizeSafe(destContainer.m_name); } else { inventory = ((Humanoid)localPlayer).GetInventory(); text = "Bag"; } if (inventory == null) { return; } int num = mode switch { PullAmountMode.SingleItem => 1, PullAmountMode.AllAvailable => int.MaxValue, _ => Mathf.Max(1, entry.MaxStackSize), }; int num2 = 0; int num3 = 0; foreach (ChestStock chest in entry.Chests) { if (num <= 0) { break; } Container container = chest.Container; if ((Object)(object)container == (Object)null || (Object)(object)container == (Object)(object)destContainer || IsContainerInUseByAnyone(container) || !CanRead(container, playerID)) { continue; } if (!CanWrite(container, playerID)) { num3++; continue; } int num4 = ExecuteTransferFromChest(container, inventory, entry.SharedName, num, keepInChest); num2 += num4; if (num != int.MaxValue) { num -= num4; } } if (num2 > 0) { if ((Object)(object)InventoryGui.instance != (Object)null) { InventoryGui.instance.m_moveItemEffects.Create(((Component)localPlayer).transform.position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID)); } string text2 = (((Object)(object)destContainer != (Object)null && IsCybercrate(destContainer)) ? " (grab before closing crate)" : ""); string text3 = $"Pulled {num2}x {entry.LocalizedName} -> {text}{text2}"; SetStatus(text3); if (SortAndSearchPlugin.DebugLog.Value) { SortAndSearchPlugin.Log.LogInfo((object)("SortAndSearch: " + text3)); } } else if (num3 > 0) { SetStatus(entry.LocalizedName + " is in a chest owned by another player right now (use Ping to locate it)."); } else if (entry.TotalCount > 0 && keepInChest > 0 && entry.AvailableToPull == 0) { SetStatus($"Keeping {keepInChest} in chest for Cybercrate (uncheck 'Keep {keepInChest}' to take last)."); } else { SetStatus("No room in " + text + " (or chest in use) for " + entry.LocalizedName + "."); } } private static int ExecuteTransferFromChest(Container src, Inventory destInv, string sharedName, int maxToTake, int keepInChest) { if ((Object)(object)src == (Object)null || destInv == null || maxToTake <= 0) { return 0; } Inventory inventory = src.GetInventory(); if (inventory == null) { return 0; } int num = inventory.CountItems(sharedName, -1, false); int num2 = Math.Min(maxToTake, num - keepInChest); if (num2 <= 0) { return 0; } int num3 = 0; List<ItemData> list = new List<ItemData>(inventory.GetAllItems()); for (int i = 0; i < list.Count && num2 > 0; i++) { ItemData val = list[i]; if (val == null || val.m_shared == null || val.m_shared.m_name != sharedName || val.m_stack <= 0) { continue; } int num4 = Math.Min(num2, val.m_stack); if (!destInv.CanAddItem(val, num4)) { int num5 = destInv.FindFreeStackSpace(sharedName, (float)val.m_worldLevel); if (num5 <= 0) { continue; } num4 = Math.Min(num4, num5); } if (num4 <= 0) { continue; } int num6 = destInv.CountItems(sharedName, -1, false); ItemData val2 = val.Clone(); val2.m_stack = num4; destInv.AddItem(val2); int num7 = destInv.CountItems(sharedName, -1, false) - num6; if (num7 > 0) { if (!inventory.RemoveItem(val, num7)) { destInv.RemoveItem(sharedName, num7, val.m_quality, false); break; } num3 += num7; num2 -= num7; } } return num3; } internal static void PingChests(BaseSearchEntry entry) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (entry == null || !SortAndSearchPlugin.ShowPingBeams.Value) { return; } ClearPings(); int num = 0; for (int i = 0; i < entry.Chests.Count; i++) { if (num >= 6) { break; } ChestStock chestStock = entry.Chests[i]; if (!((Object)(object)chestStock.Container == (Object)null)) { Material createdMat; GameObject beamObject = CreatePingBeam(((Component)chestStock.Container).transform.position, out createdMat); ActivePings.Add(new PingMarker { Target = chestStock.Container, BeamObject = beamObject, BeamMaterial = createdMat, RemainingSeconds = 8f, Label = $"{entry.LocalizedName} x{chestStock.Count} ({Mathf.RoundToInt(chestStock.Distance)}m)" }); num++; } } if (num > 0) { SetStatus(string.Format("Pinged {0} chest{1} with {2} (8s).", num, (num == 1) ? "" : "s", entry.LocalizedName)); } } private static GameObject CreatePingBeam(Vector3 chestPos, out Material createdMat) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00b1: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) createdMat = null; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj).name = "SortAndSearch_PingBeam"; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.transform.position = chestPos + Vector3.up * 2.2f; obj.transform.localScale = new Vector3(0.22f, 2.2f, 0.22f); Renderer component2 = obj.GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null) { Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Standard"); if ((Object)(object)val != (Object)null) { createdMat = new Material(val); Color accentColor = SortAndSearchPlugin.GetAccentColor(); createdMat.color = new Color(accentColor.r, accentColor.g, accentColor.b, 0.55f); component2.material = createdMat; } } return obj; } internal static void TickPings(float dt) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0101: Unknown result type (might be due to invalid IL or missing references) for (int num = ActivePings.Count - 1; num >= 0; num--) { PingMarker pingMarker = ActivePings[num]; pingMarker.RemainingSeconds -= dt; if (pingMarker.RemainingSeconds <= 0f || (Object)(object)pingMarker.Target == (Object)null) { if ((Object)(object)pingMarker.BeamObject != (Object)null) { Object.Destroy((Object)(object)pingMarker.BeamObject); } if ((Object)(object)pingMarker.BeamMaterial != (Object)null) { Object.Destroy((Object)(object)pingMarker.BeamMaterial); } ActivePings.RemoveAt(num); } else if ((Object)(object)pingMarker.BeamObject != (Object)null) { float num2 = 0.18f + 0.07f * Mathf.Sin(Time.time * 6f); pingMarker.BeamObject.transform.localScale = new Vector3(num2, 2.2f, num2); if ((Object)(object)pingMarker.BeamMaterial != (Object)null) { Color accentColor = SortAndSearchPlugin.GetAccentColor(); pingMarker.BeamMaterial.color = new Color(accentColor.r, accentColor.g, accentColor.b, 0.55f); } } } } internal static void DrawPingLabels() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) if (ActivePings.Count == 0 || (Object)(object)Camera.main == (Object)null) { return; } for (int i = 0; i < ActivePings.Count; i++) { PingMarker pingMarker = ActivePings[i]; if (!((Object)(object)pingMarker.Target == (Object)null)) { Vector3 val = Camera.main.WorldToScreenPoint(((Component)pingMarker.Target).transform.position + Vector3.up * 1.4f); if (!(val.z <= 0f)) { float x = val.x; float num = (float)Screen.height - val.y; Rect val2 = new Rect(x - 110f, num - 14f, 220f, 24f); Color color = GUI.color; Color accentColor = SortAndSearchPlugin.GetAccentColor(); SearchUI.PingLabelStyle.normal.textColor = accentColor; GUI.color = accentColor; GUI.Label(val2, pingMarker.Label, SearchUI.PingLabelStyle); GUI.color = color; } } } } internal static void ClearPings() { for (int i = 0; i < ActivePings.Count; i++) { if ((Object)(object)ActivePings[i].BeamObject != (Object)null) { Object.Destroy((Object)(object)ActivePings[i].BeamObject); } if ((Object)(object)ActivePings[i].BeamMaterial != (Object)null) { Object.Destroy((Object)(object)ActivePings[i].BeamMaterial); } } ActivePings.Clear(); } internal static void SetStatus(string msg) { LastStatusMessage = msg; LastStatusTime = Time.unscaledTime; } } public enum RecipeSortMode { Smart, Health, Stamina, Eitr, Name, Vanilla } public enum SearchAvailabilityMode { AllChestsAndInventory, CrateOnly, AllChestsOnly, InventoryOnly } [BepInPlugin("com.darthjml.sortandsearch", "SortAndSearch", "1.0.0")] public class SortAndSearchPlugin : BaseUnityPlugin { public const string PluginGuid = "com.darthjml.sortandsearch"; public const string PluginName = "SortAndSearch"; public const string PluginVersion = "1.0.0"; internal static SortAndSearchPlugin Instance; internal static ManualLogSource Log; public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> DebugLog; public static ConfigEntry<bool> RecipeSortEnabled; public static ConfigEntry<RecipeSortMode> ActiveRecipeSortMode; public static ConfigEntry<bool> CraftableFirst; public static ConfigEntry<bool> ShowFoodBadges; public static ConfigEntry<bool> RecipeSearchEnabled; public static ConfigEntry<bool> BaseSearchEnabled; public static ConfigEntry<float> SearchRadius; public static ConfigEntry<SearchAvailabilityMode> SearchAvailability; public static ConfigEntry<bool> AutoOpenOnCybercrate; public static ConfigEntry<bool> AutoOpenOnAnyChest; public static ConfigEntry<KeyboardShortcut> ToggleSearchKey; public static ConfigEntry<int> KeepInChest; public static ConfigEntry<bool> ShowPingBeams; public static ConfigEntry<float> CyberGlowIntensity; public static ConfigEntry<string> CyberColor; public static ConfigEntry<string> CyberEffect; public static ConfigEntry<float> CyberSpeed; internal static readonly Color DefaultCyan = new Color(0.36f, 0.94f, 1f, 1f); internal static readonly string[] ColorPresets = new string[9] { "Cyan", "Gold", "Green", "Purple", "Red", "Blue", "Orange", "Pink", "White" }; internal static readonly List<Container> Containers = new List<Container>(); internal static int FocusGraceFrames; private Harmony _harmony; internal static string ActiveEffectMode() { string text = (CyberEffect?.Value ?? "").Trim(); string text2 = (CyberColor?.Value ?? "").Trim(); if (text2.Equals("Rainbow", StringComparison.OrdinalIgnoreCase)) { return "Rainbow"; } if (text2.Equals("Aurora", StringComparison.OrdinalIgnoreCase)) { return "Aurora"; } if (text.Equals("Rainbow", StringComparison.OrdinalIgnoreCase)) { return "Rainbow"; } if (text.Equals("Aurora", StringComparison.OrdinalIgnoreCase)) { return "Aurora"; } if (text.Equals("Solid", StringComparison.OrdinalIgnoreCase)) { return "Solid"; } return "Pulse"; } internal static bool IsAnimatedColorMode() { string text = ActiveEffectMode(); if (!(text == "Rainbow")) { return text == "Aurora"; } return true; } internal static float GetPulseFactor() { string text = ActiveEffectMode(); if (text == "Solid") { return 1f; } float num = ((CyberSpeed != null) ? Mathf.Clamp(CyberSpeed.Value, 0.2f, 3f) : 1f); float num2 = 0.5f + 0.5f * Mathf.Sin(Time.unscaledTime * 2.6f * num); if (text == "Pulse") { return 0.35f + 0.85f * num2; } return 0.78f + 0.26f * num2; } internal static string CurrentColorLabel() { string text = (CyberColor?.Value ?? "").Trim(); if (text.Length != 0) { return text; } return "Cyan"; } internal static Color ParseStaticColor(string raw) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) string text = (raw ?? "").Trim(); if (text.Length == 0 || text.Equals("Cyan", StringComparison.OrdinalIgnoreCase) || text.Equals("CyberCyan", StringComparison.OrdinalIgnoreCase) || text.Equals("Default", StringComparison.OrdinalIgnoreCase)) { return DefaultCyan; } if (text.Equals("Vanilla", StringComparison.OrdinalIgnoreCase)) { return new Color(1f, 0.71f, 0.33f, 1f); } if (text.Equals("Gold", StringComparison.OrdinalIgnoreCase)) { return new Color(1f, 0.78f, 0.27f, 1f); } if (text.Equals("Green", StringComparison.OrdinalIgnoreCase)) { return new Color(0.23f, 1f, 0.48f, 1f); } if (text.Equals("Purple", StringComparison.OrdinalIgnoreCase)) { return new Color(0.76f, 0.36f, 1f, 1f); } if (text.Equals("Red", StringComparison.OrdinalIgnoreCase)) { return new Color(1f, 0.25f, 0.25f, 1f); } if (text.Equals("Blue", StringComparison.OrdinalIgnoreCase)) { return new Color(0.24f, 0.55f, 1f, 1f); } if (text.Equals("Orange", StringComparison.OrdinalIgnoreCase)) { return new Color(1f, 0.53f, 0.15f, 1f); } if (text.Equals("Pink", StringComparison.OrdinalIgnoreCase)) { return new Color(1f, 0.36f, 0.78f, 1f); } if (text.Equals("White", StringComparison.OrdinalIgnoreCase)) { return Color.white; } Color result = default(Color); if (ColorUtility.TryParseHtmlString(text.StartsWith("#", StringComparison.Ordinal) ? text : ("#" + text), ref result)) { result.a = 1f; return result; } return DefaultCyan; } private static Color EvaluateAurora(float t) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Repeat(t, 3f); Color val = default(Color); ((Color)(ref val))..ctor(0.18f, 0.94f, 1f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.2f, 1f, 0.52f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.72f, 0.34f, 1f, 1f); if (num < 1f) { return Color.Lerp(val, val2, Mathf.SmoothStep(0f, 1f, num)); } if (num < 2f) { return Color.Lerp(val2, val3, Mathf.SmoothStep(0f, 1f, num - 1f)); } return Color.Lerp(val3, val, Mathf.SmoothStep(0f, 1f, num - 2f)); } internal static Color GetAccentColor() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) float num = ((CyberSpeed != null) ? Mathf.Clamp(CyberSpeed.Value, 0.2f, 3f) : 1f); string text = ActiveEffectMode(); if (text == "Rainbow") { return Color.HSVToRGB(Mathf.Repeat(Time.unscaledTime * 0.16f * num, 1f), 0.9f, 1f); } if (text == "Aurora") { return EvaluateAurora(Time.unscaledTime * 0.35f * num); } return ParseStaticColor(CyberColor?.Value); } private void Awake() { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Expected O, but got Unknown //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; RecipeSorter.ValidateReflection(); Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch for Sort & Search."); DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug", false, "Write detailed logs for recipe sorting, base scans, UI init, and item pulls."); RecipeSortEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Recipes", "SortEnabled", true, "Sort crafting and cooking recipes cleanly (Health/Stamina/Eitr food grouping, gear categories, etc.)."); ActiveRecipeSortMode = ((BaseUnityPlugin)this).Config.Bind<RecipeSortMode>("Recipes", "SortMode", RecipeSortMode.Smart, "Active recipe sort mode: Smart (groups foods by HP/Stam/Eitr and gear by type), Health, Stamina, Eitr, Name, or Vanilla."); CraftableFirst = ((BaseUnityPlugin)this).Config.Bind<bool>("Recipes", "CraftableFirst", true, "Keep recipes you can craft right now at the top of the list."); ShowFoodBadges = ((BaseUnityPlugin)this).Config.Bind<bool>("Recipes", "ShowFoodBadges", true, "Show compact color-coded stat badges ([HP], [ST], [EI]) on food recipes so you can tell food types apart at a glance."); RecipeSearchEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Recipes", "SearchBarEnabled", true, "Show a live search/filter bar inside the Craft & Upgrade tabs (matches item names, food stats, and ingredients)."); BaseSearchEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("BaseSearch", "Enabled", true, "Add a native Valheim 'Search' tab beside Craft/Upgrade to search all nearby chests and pull items straight to your Bag or open Cybercrate/chest."); SearchRadius = ((BaseUnityPlugin)this).Config.Bind<float>("BaseSearch", "Radius", 32f, new ConfigDescription("How far (meters) to scan for chests. One floor tile = 2 m, so 32 m = 16 tiles (matches Robotic Inbox & AutoTorch).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(4f, 64f), Array.Empty<object>())); SearchAvailability = ((BaseUnityPlugin)this).Config.Bind<SearchAvailabilityMode>("BaseSearch", "Availability", SearchAvailabilityMode.AllChestsAndInventory, "Where the Search tab is shown: AllChestsAndInventory (anywhere while inventory or any chest is open), CrateOnly (only when a Robotic Inbox / Cybercrate is open), AllChestsOnly (when any chest is open), or InventoryOnly."); AutoOpenOnCybercrate = ((BaseUnityPlugin)this).Config.Bind<bool>("BaseSearch", "AutoOpenOnCybercrate", true, "Automatically switch to the Search tab whenever you open a Robotic Inbox (Cybercrate)."); AutoOpenOnAnyChest = ((BaseUnityPlugin)this).Config.Bind<bool>("BaseSearch", "AutoOpenOnAnyChest", false, "Automatically switch to the Search tab whenever you open any regular chest."); ToggleSearchKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("BaseSearch", "ToggleKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Hotkey to toggle the Search tab while your inventory or a chest is open."); KeepInChest = ((BaseUnityPlugin)this).Config.Bind<int>("BaseSearch", "KeepInChest", 1, new ConfigDescription("Default number of each item to leave behind in source chests when pulling, so Robotic Inbox (Cybercrate) keeps remembering which chest holds that item. Can be toggled live inside the Search tab.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 500), Array.Empty<object>())); ShowPingBeams = ((BaseUnityPlugin)this).Config.Bind<bool>("BaseSearch", "ShowPingBeams", true, "Allow the Ping button to place a temporary glowing cyan marker beam on chests holding a searched item."); CyberGlowIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "CyberGlowIntensity", 1f, new ConfigDescription("Strength of the Cybercrate rune glow on the Search tab and search boxes (0 = off, 1 = subtle default, 2 = bright).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); CyberColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "CyberColor", "Cyan", "Accent color for the Search tab glow, highlights, and Ping beams. Presets: Cyan, Gold, Green, Purple, Red, Blue, Orange, Pink, White, or any #RRGGBB hex code (matches Robotic Inbox & AutoTorch). Client-only, applies live."); CyberColor.SettingChanged += delegate { SearchUI.RefreshAccentColor(); }; CyberEffect = ((BaseUnityPlugin)this).Config.Bind<string>("Visual", "CyberEffect", "Pulse", "Animation mode for the Search tab glow and Ping beams: Solid, Pulse (breathing), Rainbow (RGB cycle), or Aurora (Northern Lights). Client-only, applies live."); CyberEffect.SettingChanged += delegate { SearchUI.RefreshAccentColor(); }; CyberSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "CyberSpeed", 1f, new ConfigDescription("Animation speed multiplier for Pulse, Rainbow, and Aurora effects (0.2 = very slow, 1 = normal, 3 = fast). Client-only.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), Array.Empty<object>())); CyberSpeed.SettingChanged += delegate { SearchUI.RefreshAccentColor(); }; _harmony = new Harmony("com.darthjml.sortandsearch"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"SortAndSearch v1.0.0 loaded (native Valheim UI, pairs with RoboticInbox / Cybercrate & AutoTorch)."); } private void Update() { if (Enabled.Value) { if (FocusGraceFrames > 0) { FocusGraceFrames--; } BaseSearchEngine.TickPings(Time.deltaTime); SearchUI.Tick(); } } private void OnGUI() { if (Enabled.Value) { BaseSearchEngine.DrawPingLabels(); } } private void OnDestroy() { BaseSearchEngine.ClearPings(); SearchUI.DestroyUI(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(Container), "Awake")] internal static class Container_Awake_Patch { private static void Postfix(Container __instance) { if ((Object)(object)__instance != (Object)null && __instance.GetInventory() != null) { SortAndSearchPlugin.Containers.Add(__instance); } } } [HarmonyPatch(typeof(Chat), "HasFocus")] internal static class Chat_HasFocus_Patch { private static void Postfix(ref bool __result) { if (SortAndSearchPlugin.Enabled.Value && (SearchUI.IsTextInputFocused || SortAndSearchPlugin.FocusGraceFrames > 0)) { __result = true; } } } [HarmonyPatch(typeof(InventoryGui), "Awake")] internal static class InventoryGui_Awake_Patch { private static void Postfix(InventoryGui __instance) { if (!SortAndSearchPlugin.Enabled.Value) { return; } try { SearchUI.Initialize(__instance); } catch (Exception arg) { SortAndSearchPlugin.Log.LogError((object)$"SortAndSearch: UI init failed: {arg}"); } } } [HarmonyPatch(typeof(InventoryGui), "Show")] internal static class InventoryGui_Show_Patch { private static void Postfix(InventoryGui __instance, Container container) { if (!SortAndSearchPlugin.Enabled.Value) { return; } try { SearchUI.OnInventoryShow(__instance, container); } catch (Exception arg) { SortAndSearchPlugin.Log.LogError((object)$"SortAndSearch: OnInventoryShow error: {arg}"); } } } [HarmonyPatch(typeof(InventoryGui), "Hide")] internal static class InventoryGui_Hide_Patch { private static void Postfix() { if (SortAndSearchPlugin.Enabled.Value) { SearchUI.OnInventoryHide(); } } } [HarmonyPatch(typeof(InventoryGui), "UpdateCraftingPanel")] internal static class InventoryGui_UpdateCraftingPanel_Patch { private static void Postfix(InventoryGui __instance) { if (SortAndSearchPlugin.Enabled.Value) { SearchUI.OnUpdateCraftingPanel(__instance); } } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] internal static class InventoryGui_UpdateRecipe_Patch { private static void Postfix(InventoryGui __instance) { if (SortAndSearchPlugin.Enabled.Value) { SearchUI.OnUpdateRecipe(__instance); } } } [HarmonyPatch(typeof(InventoryGui), "OnTabCraftPressed")] internal static class InventoryGui_OnTabCraftPressed_Patch { private static void Prefix(InventoryGui __instance) { if (SortAndSearchPlugin.Enabled.Value) { SearchUI.SetSearchTabActive(__instance, active: false, refreshRecipes: false); } } } [HarmonyPatch(typeof(InventoryGui), "OnTabUpgradePressed")] internal static class InventoryGui_OnTabUpgradePressed_Patch { private static void Prefix(InventoryGui __instance) { if (SortAndSearchPlugin.Enabled.Value) { SearchUI.SetSearchTabActive(__instance, active: false, refreshRecipes: false); } } } internal enum FoodArchetype { None, Health, Stamina, Eitr, Balanced, MeadOrPotion } internal static class RecipeSorter { private struct EntryWrapper { public object RawPair; public Recipe Recipe; public ItemData ItemData; public GameObject Element; public bool CanCraft; public SharedData Shared; public string LocalizedName; public int SmartGroup; public int TierHint; public float FoodPrimary; } internal static string RecipeFilterText = ""; internal static int LastMatchedCount; internal static int LastTotalCount; private static readonly FieldInfo AvailableRecipesField = AccessTools.Field(typeof(InventoryGui), "m_availableRecipes"); private static readonly FieldInfo RecipeListBaseSizeField = AccessTools.Field(typeof(InventoryGui), "m_recipeListBaseSize"); private static readonly MethodInfo UpdateCraftingPanelMethod = AccessTools.Method(typeof(InventoryGui), "UpdateCraftingPanel", (Type[])null, (Type[])null); private static readonly Type RecipeDataPairType = AccessTools.Inner(typeof(InventoryGui), "RecipeDataPair"); private static readonly PropertyInfo PairRecipeProp = ((RecipeDataPairType != null) ? AccessTools.Property(RecipeDataPairType, "Recipe") : null); private static readonly PropertyInfo PairItemDataProp = ((RecipeDataPairType != null) ? AccessTools.Property(RecipeDataPairType, "ItemData") : null); private static readonly PropertyInfo PairElementProp = ((RecipeDataPairType != null) ? AccessTools.Property(RecipeDataPairType, "InterfaceElement") : null); private static readonly PropertyInfo PairCanCraftProp = ((RecipeDataPairType != null) ? AccessTools.Property(RecipeDataPairType, "CanCraft") : null); internal static void ValidateReflection() { if (AvailableRecipesField == null || UpdateCraftingPanelMethod == null || RecipeDataPairType == null || PairRecipeProp == null || PairElementProp == null) { SortAndSearchPlugin.Log.LogWarning((object)"SortAndSearch: one or more InventoryGui reflection targets were not found; recipe sorting may be degraded."); } } internal static void RefreshCraftingList() { InventoryGui instance = InventoryGui.instance; if ((Object)(object)instance == (Object)null || !InventoryGui.IsVisible() || UpdateCraftingPanelMethod == null) { return; } try { UpdateCraftingPanelMethod.Invoke(instance, new object[1] { false }); if ((Object)(object)instance.m_recipeListScroll != (Object)null) { instance.m_recipeListScroll.value = 1f; } } catch (Exception ex) { if (SortAndSearchPlugin.DebugLog.Value) { SortAndSearchPlugin.Log.LogWarning((object)("SortAndSearch: RefreshCraftingList error: " + ex.Message)); } } } internal static void CycleSortMode() { int value = (int)(SortAndSearchPlugin.ActiveRecipeSortMode.Value + 1) % Enum.GetValues(typeof(RecipeSortMode)).Length; SortAndSearchPlugin.ActiveRecipeSortMode.Value = (RecipeSortMode)value; RefreshCraftingList(); } internal static FoodArchetype ClassifyFood(SharedData shared) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Invalid comparison between Unknown and I4 if (shared == null || (int)shared.m_itemType != 2) { return FoodArchetype.None; } float food = shared.m_food; float foodStamina = shared.m_foodStamina; float foodEitr = shared.m_foodEitr; if (food <= 0f && foodStamina <= 0f && foodEitr <= 0f) { return FoodArchetype.MeadOrPotion; } if (foodEitr > 0f && foodEitr >= food && foodEitr >= foodStamina) { return FoodArchetype.Eitr; } float num = Mathf.Max(food, foodStamina); float num2 = Mathf.Min(food, foodStamina); if (food > 0f && foodStamina > 0f && num - num2 <= num * 0.15f) { return FoodArchetype.Balanced; } if (food >= foodStamina) { return FoodArchetype.Health; } return FoodArchetype.Stamina; } internal static string GetFoodBadgeText(SharedData shared, bool richText) { switch (ClassifyFood(shared)) { case FoodArchetype.Health: if (!richText) { return $"[HP {Mathf.RoundToInt(shared.m_food)}]"; } return $" <color=#ff8a8a>[HP {Mathf.RoundToInt(shared.m_food)}]</color>"; case FoodArchetype.Stamina: if (!richText) { return $"[ST {Mathf.RoundToInt(shared.m_foodStamina)}]"; } return $" <color=#ffe066>[ST {Mathf.RoundToInt(shared.m_foodStamina)}]</color>"; case FoodArchetype.Eitr: if (!richText) { return $"[EI {Mathf.RoundToInt(shared.m_foodEitr)}]"; } return $" <color=#c59bff>[EI {Mathf.RoundToInt(shared.m_foodEitr)}]</color>"; case FoodArchetype.Balanced: if (!richText) { return $"[BAL {Mathf.RoundToInt(shared.m_food)}/{Mathf.RoundToInt(shared.m_foodStamina)}]"; } return $" <color=#9be59b>[BAL {Mathf.RoundToInt(shared.m_food)}/{Mathf.RoundToInt(shared.m_foodStamina)}]</color>"; case FoodArchetype.MeadOrPotion: if (!richText) { return "[MEAD]"; } return " <color=#7de0ff>[MEAD]</color>"; default: return ""; } } internal static bool MatchesFilter(Recipe recipe, string rawQuery) { //IL_01ab: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(rawQuery)) { return true; } if ((Object)(object)recipe == (Object)null || (Object)(object)recipe.m_item == (Object)null || recipe.m_item.m_itemData == null) { return false; } SharedData shared = recipe.m_item.m_itemData.m_shared; string haystack = LocalizeSafe(shared.m_name); string haystack2 = (((Object)(object)((Component)recipe.m_item).gameObject != (Object)null) ? ((Object)((Component)recipe.m_item).gameObject).name : ""); FoodArchetype foodArchetype = ClassifyFood(shared); string[] array = rawQuery.Trim().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in array) { bool flag = false; if (ContainsIgnoreCase(haystack, text) || ContainsIgnoreCase(haystack2, text)) { flag = true; } if (!flag && foodArchetype != FoodArchetype.None) { if (ContainsIgnoreCase("food", text) && foodArchetype != FoodArchetype.MeadOrPotion) { flag = true; } else if ((ContainsIgnoreCase("health", text) || text.Equals("hp", StringComparison.OrdinalIgnoreCase)) && foodArchetype == FoodArchetype.Health) { flag = true; } else if ((ContainsIgnoreCase("stamina", text) || text.Equals("stam", StringComparison.OrdinalIgnoreCase) || text.Equals("st", StringComparison.OrdinalIgnoreCase)) && foodArchetype == FoodArchetype.Stamina) { flag = true; } else if ((ContainsIgnoreCase("eitr", text) || text.Equals("magic", StringComparison.OrdinalIgnoreCase)) && foodArchetype == FoodArchetype.Eitr) { flag = true; } else if (ContainsIgnoreCase("balanced", text) && foodArchetype == FoodArchetype.Balanced) { flag = true; } else if ((ContainsIgnoreCase("mead", text) || ContainsIgnoreCase("potion", text)) && foodArchetype == FoodArchetype.MeadOrPotion) { flag = true; } } if (!flag && MatchesItemTypeKeyword(shared.m_itemType, text)) { flag = true; } if (!flag && recipe.m_resources != null) { for (int j = 0; j < recipe.m_resources.Length; j++) { Requirement val = recipe.m_resources[j]; if (val?.m_resItem?.m_itemData?.m_shared != null) { string haystack3 = LocalizeSafe(val.m_resItem.m_itemData.m_shared.m_name); string haystack4 = (((Object)(object)((Component)val.m_resItem).gameObject != (Object)null) ? ((Object)((Component)val.m_resItem).gameObject).name : ""); if (ContainsIgnoreCase(haystack3, text) || ContainsIgnoreCase(haystack4, text)) { flag = true; break; } } } } if (!flag) { return false; } } return true; } private static bool MatchesItemTypeKeyword(ItemType t, string token) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 if (ContainsIgnoreCase("weapon", token) && IsWeapon(t)) { return true; } if (ContainsIgnoreCase("armor", token) && IsArmor(t)) { return true; } if (ContainsIgnoreCase("shield", token) && (int)t == 5) { return true; } if ((ContainsIgnoreCase("ammo", token) || ContainsIgnoreCase("arrow", token) || ContainsIgnoreCase("bolt", token)) && ((int)t == 9 || (int)t == 23)) { return true; } if (ContainsIgnoreCase("tool", token) && (int)t == 19) { return true; } return false; } private static bool IsWeapon(ItemType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 if ((int)t != 3 && (int)t != 14 && (int)t != 22 && (int)t != 4 && (int)t != 20) { return (int)t == 15; } return true; } private static bool IsArmor(ItemType t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 if ((int)t != 6 && (int)t != 7 && (int)t != 11 && (int)t != 17) { return (int)t == 12; } return true; } private static int GetSmartGroupRank(SharedData shared) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected I4, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Invalid comparison between Unknown and I4 //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Invalid comparison between Unknown and I4 //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Invalid comparison between Unknown and I4 //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Invalid comparison between Unknown and I4 //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Invalid comparison between Unknown and I4 //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_0107: 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_010e: Expected I4, but got Unknown if (shared == null) { return 999; } if ((int)shared.m_itemType == 2) { return ClassifyFood(shared) switch { FoodArchetype.Health => 10, FoodArchetype.Stamina => 20, FoodArchetype.Eitr => 30, FoodArchetype.Balanced => 40, _ => 50, }; } if (IsWeapon(shared.m_itemType)) { return 100 + shared.m_skillType; } if ((int)shared.m_itemType == 5) { return 200; } if (IsArmor(shared.m_itemType)) { ItemType itemType = shared.m_itemType; if ((int)itemType <= 7) { if ((int)itemType == 6) { return 300; } if ((int)itemType == 7) { return 301; } } else { if ((int)itemType == 11) { return 302; } if ((int)itemType == 17) { return 303; } } return 304; } if ((int)shared.m_itemType == 9 || (int)shared.m_itemType == 23) { return 400; } if ((int)shared.m_itemType == 19 || (int)shared.m_itemType == 18 || (int)shared.m_itemType == 24) { return 500; } if ((int)shared.m_itemType == 1) { return 600; } return 700 + shared.m_itemType; } private static float GetFoodPrimaryScore(SharedData shared) { if (shared == null) { return 0f; } return ClassifyFood(shared) switch { FoodArchetype.Health => shared.m_food * 100f + shared.m_foodStamina, FoodArchetype.Stamina => shared.m_foodStamina * 100f + shared.m_food, FoodArchetype.Eitr => shared.m_foodEitr * 100f + shared.m_food + shared.m_foodStamina, FoodArchetype.Balanced => (shared.m_food + shared.m_foodStamina + shared.m_foodEitr) * 100f, _ => 0f, }; } private static int GetMaterialTierHint(Recipe recipe) { if (recipe?.m_resources == null) { return 0; } int num = 0; Requirement[] resources = recipe.m_resources; foreach (Requirement obj in resources) { object obj2; if (obj == null) { obj2 = null; } else { ItemDrop resItem = obj.m_resItem; if (resItem == null) { obj2 = null; } else { GameObject gameObject = ((Component)resItem).gameObject; obj2 = ((gameObject != null) ? ((Object)gameObject).name : null); } } string text = (string)obj2; if (!string.IsNullOrEmpty(text)) { int num2 = 0; if (text.IndexOf("Flametal", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("AskHide", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 80; } else if (text.IndexOf("Carapace", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Eitr", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("ScaleHide", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 70; } else if (text.IndexOf("BlackMetal", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("LinenThread", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("LoxPelt", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 60; } else if (text.IndexOf("Silver", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("WolfPelt", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 50; } else if (text.IndexOf("Iron", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Root", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 40; } else if (text.IndexOf("Bronze", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("TrollHide", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 30; } else if (text.IndexOf("Copper", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Tin", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 25; } else if (text.IndexOf("Flint", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("DeerHide", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 20; } else if (text.IndexOf("LeatherScraps", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Wood", StringComparison.OrdinalIgnoreCase) >= 0) { num2 = 10; } if (num2 > num) { num = num2; } } } return num; } internal static void ApplySortingAndBadges(InventoryGui gui) { //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Invalid comparison between Unknown and I4 if ((Object)(object)gui == (Object)null || AvailableRecipesField == null || PairRecipeProp == null) { return; } RecipeSortMode mode = SortAndSearchPlugin.ActiveRecipeSortMode.Value; if (!SortAndSearchPlugin.RecipeSortEnabled.Value || !(AvailableRecipesField.GetValue(gui) is IList { Count: not 0 } list)) { return; } List<EntryWrapper> list2 = new List<EntryWrapper>(list.Count); for (int i = 0; i < list.Count; i++) { object obj = list[i]; object? value = PairRecipeProp.GetValue(obj); Recipe val = (Recipe)((value is Recipe) ? value : null); object? obj2 = PairItemDataProp?.GetValue(obj); ItemData itemData = (ItemData)((obj2 is ItemData) ? obj2 : null); object? obj3 = PairElementProp?.GetValue(obj); GameObject element = (GameObject)((obj3 is GameObject) ? obj3 : null); bool canCraft = PairCanCraftProp != null && (bool)PairCanCraftProp.GetValue(obj); SharedData val2 = val?.m_item?.m_itemData?.m_shared; string localizedName = ((val2 != null) ? LocalizeSafe(val2.m_name) : ""); list2.Add(new EntryWrapper { RawPair = obj, Recipe = val, ItemData = itemData, Element = element, CanCraft = canCraft, Shared = val2, LocalizedName = localizedName, SmartGroup = GetSmartGroupRank(val2), TierHint = GetMaterialTierHint(val), FoodPrimary = GetFoodPrimaryScore(val2) }); } bool craftableFirst = SortAndSearchPlugin.CraftableFirst.Value; if (mode != RecipeSortMode.Vanilla) { list2.Sort(delegate(EntryWrapper a, EntryWrapper b) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (craftableFirst) { int num4 = b.CanCraft.CompareTo(a.CanCraft); if (num4 != 0) { return num4; } } switch (mode) { case RecipeSortMode.Smart: { bool flag = a.Shared != null && IsArmor(a.Shared.m_itemType); bool flag2 = b.Shared != null && IsArmor(b.Shared.m_itemType); int num6 = (flag ? 300 : a.SmartGroup); int value4 = (flag2 ? 300 : b.SmartGroup); int num7 = num6.CompareTo(value4); if (num7 != 0) { return num7; } if (flag && flag2) { int num8 = b.TierHint.CompareTo(a.TierHint); if (num8 != 0) { return num8; } int num9 = a.SmartGroup.CompareTo(b.SmartGroup); if (num9 != 0) { return num9; } } else if (a.SmartGroup <= 40) { int num10 = b.FoodPrimary.CompareTo(a.FoodPrimary); if (num10 != 0) { return num10; } } else if (a.SmartGroup >= 100 && a.SmartGroup < 200) { int num11 = b.TierHint.CompareTo(a.TierHint); if (num11 != 0) { return num11; } } break; } case RecipeSortMode.Health: { float value5 = ((a.Shared != null) ? a.Shared.m_food : 0f); int num12 = ((b.Shared != null) ? b.Shared.m_food : 0f).CompareTo(value5); if (num12 != 0) { return num12; } break; } case RecipeSortMode.Stamina: { float value6 = ((a.Shared != null) ? a.Shared.m_foodStamina : 0f); int num13 = ((b.Shared != null) ? b.Shared.m_foodStamina : 0f).CompareTo(value6); if (num13 != 0) { return num13; } break; } case RecipeSortMode.Eitr: { float value3 = ((a.Shared != null) ? a.Shared.m_foodEitr : 0f); int num5 = ((b.Shared != null) ? b.Shared.m_foodEitr : 0f).CompareTo(value3); if (num5 != 0) { return num5; } break; } } int num14 = string.Compare(a.LocalizedName, b.LocalizedName, StringComparison.CurrentCultureIgnoreCase); if (num14 != 0) { return num14; } int value7 = ((a.ItemData != null) ? a.ItemData.m_quality : 0); return ((b.ItemData != null) ? b.ItemData.m_quality : 0).CompareTo(value7); }); list.Clear(); for (int num = 0; num < list2.Count; num++) { list.Add(list2[num].RawPair); } } bool value2 = SortAndSearchPlugin.ShowFoodBadges.Value; float num2 = Mathf.Max((RecipeListBaseSizeField != null) ? ((float)RecipeListBaseSizeField.GetValue(gui)) : 0f, (float)list2.Count * gui.m_recipeListSpace); if ((Object)(object)gui.m_recipeListRoot != (Object)null) { gui.m_recipeListRoot.SetSizeWithCurrentAnchors((Axis)1, num2); } for (int num3 = 0; num3 < list2.Count; num3++) { GameObject element2 = list2[num3].Element; if ((Object)(object)element2 == (Object)null) { continue; } Transform transform = element2.transform; RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val3 != (Object)null) { val3.anchoredPosition = new Vector2(0f, (float)num3 * (0f - gui.m_recipeListSpace)); } if (!value2 || list2[num3].Shared == null || (int)list2[num3].Shared.m_itemType != 2) { continue; } string foodBadgeText = GetFoodBadgeText(list2[num3].Shared, richText: true); if (!string.IsNullOrEmpty(foodBadgeText)) { Transform val4 = element2.transform.Find("name"); TMP_Text val5 = (((Object)(object)val4 != (Object)null) ? ((Component)val4).GetComponent<TMP_Text>() : null); if ((Object)(object)val5 != (Object)null && !val5.text.Contains("[")) { val5.text += foodBadgeText; } } } } internal static string LocalizeSafe(string token) { if (string.IsNullOrEmpty(token)) { return ""; } if (Localization.instance == null) { return token; } return Localization.instance.Localize(token); } internal static bool ContainsIgnoreCase(string haystack, string needle) { if (string.IsNullOrEmpty(haystack) || string.IsNullOrEmpty(needle)) { return false; } return haystack.IndexOf(needle, StringComparison.OrdinalIgnoreCase) >= 0; } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList")] internal static class InventoryGui_UpdateRecipeList_Patch { private static void Prefix(ref List<Recipe> recipes) { if (!SortAndSearchPlugin.Enabled.Value || recipes == null) { return; } RecipeSorter.LastTotalCount = recipes.Count; if (!SortAndSearchPlugin.RecipeSearchEnabled.Value || string.IsNullOrWhiteSpace(RecipeSorter.RecipeFilterText)) { RecipeSorter.LastMatchedCount = recipes.Count; return; } List<Recipe> list = new List<Recipe>(recipes.Count); for (int i = 0; i < recipes.Count; i++) { if (RecipeSorter.MatchesFilter(recipes[i], RecipeSorter.RecipeFilterText)) { list.Add(recipes[i]); } } RecipeSorter.LastMatchedCount = list.Count; recipes = list; } private static void Postfix(InventoryGui __instance) { if (!SortAndSearchPlugin.Enabled.Value) { return; } try { RecipeSorter.ApplySortingAndBadges(__instance); } catch (Exception arg) { if (SortAndSearchPlugin.DebugLog.Value) { SortAndSearchPlugin.Log.LogError((object)$"SortAndSearch: Recipe sort error: {arg}"); } } } } internal static class SearchUI { private readonly struct TabGeometry { private readonly Vector2 _anchorMin; private readonly Vector2 _anchorMax; private readonly Vector2 _offsetMin; private readonly Vector2 _offsetMax; internal TabGeometry(RectTransform rt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) _anchorMin = rt.anchorMin; _anchorMax = rt.anchorMax; _offsetMin = rt.offsetMin; _offsetMax = rt.offsetMax; } internal void Restore(RectTransform rt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) rt.anchorMin = _anchorMin; rt.anchorMax = _anchorMax; rt.offsetMin = _offsetMin; rt.offsetMax = _offsetMax; } } private sealed class ResultRow { internal GameObject Root; internal Image Background; internal Image Icon; internal TMP_Text Name; internal TMP_Text Stats; internal TMP_Text BagLabel; internal Button DestinationButton; internal TMP_Text DestinationLabel; internal Button PingButton; internal BaseSearchEntry Entry; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__110_0; public static UnityAction <>9__113_0; public static UnityAction <>9__113_1; public static UnityAction<string> <>9__113_2; public static UnityAction <>9__113_3; public static UnityAction<string> <>9__115_0; public static UnityAction <>9__115_1; public static UnityAction <>9__115_2; public static UnityAction <>9__115_3; public static UnityAction <>9__117_0; public static UnityAction <>9__117_1; public static UnityAction <>9__117_2; public static UnityAction <>9__117_3; public static UnityAction <>9__117_4; public static UnityAction<string> <>9__162_0; internal void <BuildSearchTabButton>b__110_0() { SetSearchTabActive(_gui, active: true); } internal void <BuildRecipeSortBar>b__113_0() { RecipeSorter.CycleSortMode(); UpdateRecipeBarLabels(); } internal void <BuildRecipeSortBar>b__113_1() { SortAndSearchPlugin.CraftableFirst.Value = !SortAndSearchPlugin.CraftableFirst.Value; RecipeSorter.RefreshCraftingList(); UpdateRecipeBarLabels(); } internal void <BuildRecipeSortBar>b__113_2(string val) { RecipeSorter.RecipeFilterText = val ?? ""; if ((Object)(object)_recipeClearBtn != (Object)null) { _recipeClearBtn.SetActive(!string.IsNullOrEmpty(val)); } RecipeSorter.RefreshCraftingList(); } internal void <BuildRecipeSortBar>b__113_3() { _recipeFilterInput.text = ""; RecipeSorter.RecipeFilterText = ""; RecipeSorter.RefreshCraftingList(); } internal void <BuildSearchTabPanel>b__115_0(string val) { _baseQuery = val ?? ""; if ((Object)(object)_baseClearBtn != (Object)null) { _baseClearBtn.SetActive(!string.IsNullOrEmpty(_baseQuery)); } _resultsDirty = true; _scrollResultsToTop = true; } internal void <BuildSearchTabPanel>b__115_1() { _baseSearchInput.text = ""; } internal void <BuildSearchTabPanel>b__115_2() { _keepOneEnabled = !_keepOneEnabled; UpdateKeepOneVisual(); _resultsDirty = true; } internal void <BuildSearchTabPanel>b__115_3() { SetThemeViewVisible(visible: true); } internal void <BuildThemeStudioPanel>b__117_0() { GetActiveTargetValues(out var color, out var effect, out var speed); ThemeBridge.SyncAll(color, effect, speed); RefreshThemeStudioVisuals(); } internal void <BuildThemeStudioPanel>b__117_1() { SetThemeViewVisible(visible: false); } internal void <BuildThemeStudioPanel>b__117_2() { AdjustCrateGlow(-1f); } internal void <BuildThemeStudioPanel>b__117_3() { AdjustCrateGlow(1f); } internal void <BuildThemeStudioPanel>b__117_4() { bool colorWoodFires = !ThemeBridge.GetTorchWoodFires(); ThemeBridge.SetTorches(ThemeBridge.GetTorchColor(), ThemeBridge.GetTorchEffect(), ThemeBridge.GetTorchSpeed(), colorWoodFires); RefreshThemeStudioVisuals(); } internal void <CreateValheimInputField>b__162_0(string _) { SortAndSearchPlugin.FocusGraceFrames = 2; } } private static readonly Color ValheimGold = new Color(0.96f, 0.83f, 0.5f, 1f); private static readonly Color ValheimText = new Color(0.94f, 0.92f, 0.87f, 1f); private static readonly Color ValheimMuted = new Color(0.73f, 0.76f, 0.8f, 1f); private static readonly Color DarkPanelBg = new Color(0.11f, 0.12f, 0.14f, 0.98f); private static readonly Color DarkInputBg = new Color(0.05f, 0.06f, 0.08f, 0.94f); private static readonly Color RowTintEven = new Color(0.18f, 0.19f, 0.22f, 0.85f); private static readonly Color RowTintOdd = new Color(0.13f, 0.14f, 0.17f, 0.85f); private static bool _initialized; private static InventoryGui _gui; private static TMP_FontAsset _valheimFont; private static Material _valheimFontMat; private static Sprite _valheimPanelSprite; private static Sprite _valheimButtonSprite; private static Transition _valheimButtonTransition; private static SpriteState _valheimButtonSpriteState; private static Sprite _valheimInsetSprite; private static Sprite _valheimRowSprite; private static Sprite _softGlowSprite; private static Sprite _roundedRectSprite; private const float RecipeBarHeight = 28f; private const float RecipeBarGap = 4f; private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[4]; private static TabGeometry _craftTabGeometry; private static TabGeometry _upgradeTabGeometry; private static Rect _laidOutTabParentRect; private static Rect _laidOutCraftingRect; private static int _laidOutTabs = -1; private static bool _tabRectsModified; private static Button _searchTabButton; private static TMP_Text _searchTabLabel; private static Color _nativeTabTextColor; private static Material _searchTabGlowMaterial; private static float _lastGlowStrength = -1f; private static Image _searchTabGlow; private static GameObject _craftTabReturn; private static GameObject _upgradeTabReturn; private static Button _vanillaTabBeforeSearch; private static GameObject _recipeBarRoot; private static RectTransform _recipeScrollRect; private static RectTransform _recipeScrollbarRect; private static Traverse _recipeListBaseSize; private static float _originalRecipeListBaseSize; private static bool _recipeBarReserved; private static Button _sortModeButton; private static TMP_Text _sortModeLabel; private static Button _craftableButton; private static TMP_Text _craftableLabel; private static Image _craftableGlow; private static TMP_InputField _recipeFilterInput; private static GameObject _recipeClearBtn; private static Image _recipeInputGlow; private static GameObject _searchPanelRoot; private static CanvasGroup _vanillaRecipeList; private static CanvasGroup _vanillaRecipeDetails; private static Image _searchPanelGlow; private static TMP_InputField _baseSearchInput; private static Image _baseSearchInputGlow; private static GameObject _baseClearBtn; private static TMP_Text _chestStatsText; private static TMP_Text _itemCountText; private static TMP_Text _statusFooterText; private static Button _keepOneButton; private static TMP_Text _keepOneLabel; private static Image _keepOneGlow; private static Button _colorButton; private static TMP_Text _colorLabel; private static Image _colorGlow; private static GameObject _searchBodyRoot; private static GameObject _themeBodyRoot; private static bool _inThemeView; private static int _themeTarget; private static readonly Dictionary<int, (TMP_Text label, Image glow)> _themeTargetUi = new Dictionary<int, (TMP_Text, Image)>(); private static readonly Dictionary<string, (TMP_Text label, Image glow)> _themeColorUi = new Dictionary<string, (TMP_Text, Image)>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, (TMP_Text label, Image glow)> _themeEffectUi = new Dictionary<string, (TMP_Text, Image)>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, (TMP_Text label, Image glow, float speed)> _themeSpeedUi = new Dictionary<string, (TMP_Text, Image, float)>(StringComparer.OrdinalIgnoreCase); private static TMP_Text _themeCrateGlowText; private static TMP_Text _themeWoodFiresLabel; private static Image _themeWoodFiresGlow; private static TMP_Text _themeSummaryText; private static RectTransform _resultsContent; private static ScrollRect _resultsScrollRect; private static GameObject _emptyResults; private static Container _resultsDestination; private static bool _scrollResultsToTop; private static readonly Dictionary<SearchCategoryTab, Button> _catButtons = new Dictionary<SearchCategoryTab, Button>(); private static readonly Dictionary<SearchCategoryTab, Image> _catGlows = new Dictionary<SearchCategoryTab, Image>(); private static readonly Dictionary<SearchCategoryTab, TMP_Text> _catLabels = new Dictionary<SearchCategoryTab, TMP_Text>(); private static readonly Dictionary<string, ResultRow> ResultRows = new Dictionary<string, ResultRow>(StringComparer.Ordinal); private static readonly HashSet<string> StaleResultKeys = new HashSet<string>(StringComparer.Ordinal); internal static bool InSearchTab; private static string _baseQuery = ""; private static SearchCategoryTab _activeTab = SearchCategoryTab.All; private static bool _keepOneEnabled = true; private static bool _resultsDirty = true; private static float _nextAutoRefresh; private static Container _lastContainerRef; private static GUIStyle _pingLabelStyle; private static Color CyberCyan => SortAndSearchPlugin.GetAccentColor(); internal static GUIStyle PingLabelStyle { get { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (_pingLabelStyle == null) { _pingLabelStyle = new GUIStyle(GUI.skin.label) { fontSize = 13, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; _pingLabelStyle.normal.textColor = CyberCyan; } return _pingLabelStyle; } } internal static bool IsTextInputFocused { get { if (!IsFocused(_recipeFilterInput)) { return IsFocused(_baseSearchInput); } return true; } } private static float GlowStrength => Mathf.Clamp(SortAndSearchPlugin.CyberGlowIntensity.Value, 0f, 2f); private static int KeepCount { get { if (!_keepOneEnabled) { return 0; } return Math.Max(1, SortAndSearchPlugin.KeepInChest.Value); } } internal static void MarkResultsDirty() { _resultsDirty = true; } internal static void Initialize(InventoryGui gui) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown if (!((Object)(object)gui == (Object)null) && !((Object)(object)gui.m_crafting == (Object)null) && !((Object)(object)gui.m_tabCraft == (Object)null) && !((Object)(object)gui.m_tabUpgrade == (Object)null) && (!_initialized || !((Object)(object)_gui == (Object)(object)gui) || !((Object)(object)_searchTabButton != (Object)null))) { DestroyUI(); _gui = gui; CacheNativeAssets(gui); _craftTabGeometry = new TabGeometry((RectTransform)((Component)gui.m_tabCraft).transform); _upgradeTabGeometry = new TabGeometry((RectTransform)((Component)gui.m_tabUpgrade).transform); BuildSearchTabButton(gui); BuildRecipeSortBar(gui); BuildSearchTabPanel(gui); _initialized = true; InSearchTab = false; ApplyTabVisibilityAndLayout(gui, BaseSearchEngine.GetCurrentOpenContainer()); if (SortAndSearchPlugin.DebugLog.Value) { SortAndSearchPlugin.Log.LogInfo((object)"SortAndSearch: Native Valheim uGUI initialized inside InventoryGui.m_crafting."); } } } internal static void DestroyUI() { //IL_002a: 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_0048: Expected O, but got Unknown //IL_0048: Expected O, but got Unknown SetRecipeBarSpace(reserve: false); if (_tabRectsModified && (Object)(object)_gui != (Object)null) { RestoreTabGeometry((RectTransform)((Component)_gui.m_tabCraft).transform, (RectTransform)((Component)_gui.m_tabUpgrade).transform); } _tabRectsModified = false; if ((Object)(object)_searchTabButton != (Object)null) { Object.Destroy((Object)(object)((Component)_searchTabButton).gameObject); } if ((Object)(object)_craftTabReturn != (Object)null) { Object.Destroy((Object)(object)_craftTabReturn); } if ((Object)(object)_upgradeTabReturn != (Object)null) { Object.Destroy((Object)(object)_upgradeTabReturn); } if ((Object)(object)_recipeBarRoot != (Object)null) { Object.Destroy((Object)(object)_recipeBarRoot); } if ((Object)(object)_searchPanelRoot != (Object)null) { Object.Destroy((Object)(object)_searchPanelRoot); } SetRecipeLayerVisible(visible: true); if ((Object)(object)_vanillaRecipeList != (Object)null) { Object.Destroy((Object)(object)_vanillaRecipeList); } if ((Object)(object)_vanillaRecipeDetails != (Object)null) { Object.Destroy((Object)(object)_vanillaRecipeDetails); } if ((Object)(object)_searchTabGlowMaterial != (Object)null) { Object.Destroy((Object)(object)_searchTabGlowMaterial); } _vanillaRecipeList = null; _vanillaRecipeDetails = null; _searchTabGlowMaterial = null; _lastGlowStrength = -1f; _searchTabButton = null; _craftTabReturn = null; _upgradeTabReturn = null; _vanillaTabBeforeSearch = null; _searchTabLabel = null; _searchTabGlow = null; _recipeBarRoot = null; _recipeScrollRect = null; _recipeScrollbarRect = null; _recipeListBaseSize = null; _searchPanelRoot = null; _searchBodyRoot = null; _themeBodyRoot = null; _inThemeView = false; _themeTargetUi.Clear(); _themeColorUi.Clear(); _themeEffectUi.Clear(); _themeSpeedUi.Clear(); _themeCrateGlowText = null; _themeWoodFiresLabel = null; _themeWoodFiresGlow = null; _themeSummaryText = null; _colorButton = null; _colorLabel = null; _colorGlow = null; _recipeFilterInput = null; _baseSearchInput = null; _resultsContent = null; _resultsScrollRect = null; _catButtons.Clear(); _catGlows.Clear(); _catLabels.Clear(); ResultRows.Clear(); StaleResultKeys.Clear(); _baseQuery = ""; _emptyResults = null; _resultsDestination = null; _initialized = false; _laidOutTabs = -1; InSearchTab = false; _gui = null; } private static void CacheNativeAssets(InventoryGui gui) { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) Transform obj = ((Component)gui.m_tabCraft).transform.Find("Text"); TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null) ?? gui.m_recipeName; _valheimFont = (((Object)(object)val != (Object)null) ? val.font : null); _valheimFontMat = (((Object)(object)val != (Object)null) ? val.fontSharedMaterial : null); Transform obj2 = ((Transform)gui.m_crafting).Find("Bkg"); object valheimPanelSprite; if (obj2 == null) { valheimPanelSprite = null; } else { Image component = ((Component)obj2).GetComponent<Image>(); valheimPanelSprite = ((component != null) ? component.sprite : null); } _valheimPanelSprite = (Sprite)valheimPanelSprite; RectTransform recipeListRoot = gui.m_recipeListRoot; ScrollRect obj3 = ((recipeListRoot != null) ? ((Component)recipeListRoot).GetComponentInParent<ScrollRect>(true) : null); object valheimInsetSprite; if (obj3 == null) { valheimInsetSprite = null; } else { Image component2 = ((Component)obj3).GetComponent<Image>(); valheimInsetSprite = ((component2 != null) ? component2.sprite : null); } _valheimInsetSprite = (Sprite)valheimInsetSprite; GameObject recipeElementPrefab = gui.m_recipeElementPrefab; object valheimRowSprite; if (recipeElementPrefab == null) { valheimRowSprite = null; } else { Transform obj4 = recipeElementPrefab.transform.Find("bkg"); if (obj4 == null) { valheimRowSprite = null; } else { Image component3 = ((Component)obj4).GetComponent<Image>(); valheimRowSprite = ((component3 != null) ? component3.sprite : null); } } _valheimRowSprite = (Sprite)valheimRowSprite; Button obj5 = (((Object)(object)gui.m_craftButton != (Object)null) ? gui.m_craftButton : gui.m_tabCraft); Graphic targetGraphic = ((Selectable)obj5).targetGraphic; Graphic obj6 = ((targetGraphic is Image) ? targetGraphic : null); _valheimButtonSprite = ((obj6 != null) ? ((Image)obj6).sprite : null); _valheimButtonTransition = ((Selectable)obj5).transition; _valheimButtonSpriteState = ((Selectable)obj5).spriteState; if ((Object)(object)_softGlowSprite == (Object)null) { _softGlowSprite = CreateSoftGlowFrameSprite(64, 14, 10); } if ((Object)(object)_roundedRectSprite == (Object)null) { _roundedRectSprite = CreateRoundedPanelSprite(48, 10); } } private static void RestoreTabGeometry(RectTransform craft, RectTransform upgrade) { _craftTabGeometry.Restore(craft); _upgradeTabGeometry.Restore(upgrade); } private static Rect GetLocalRect(RectTransform rt, RectTransform parent) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) rt.GetWorldCorners(Corners); Vector2 val = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(Corners[0])); Vector2 val2 = val; for (int i = 1; i < Corners.Length; i++) { Vector2 val3 = Vector2.op_Implicit(((Transform)parent).InverseTransformPoint(Corners[i])); val = Vector2.Min(val, val3); val2 = Vector2.Max(val2, val3); } return Rect.MinMaxRect(val.x, val.y, val2.x, val2.y); } private static void PlaceTab(RectTransform rt, Rect parentRect, float left, float bottom, float width, float height) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); rt.anchorMax = val; rt.anchorMin = val; rt.sizeDelta = new Vector2(width, height); rt.anchoredPosition = new Vector2(left + width * rt.pivot.x - ((Rect)(ref parentRect)).xMin, bottom + height * rt.pivot.y - ((Rect)(ref parentRect)).yMax); } private static void BuildSearchTabButton(InventoryGui gui) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0196: 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) GameObject val = Object.Instantiate<GameObject>(((Component)gui.m_tabUpgrade).gameObject, ((Component)gui.m_tabUpgrade).transform.parent, false); val.SetActive(false); ((Object)val).name = "Tab_SortAndSearch"; val.transform.SetSiblingIndex(((Component)gui.m_tabUpgrade).transform.GetSiblingIndex() + 1); UIGamePad val2 = default(UIGamePad); if (val.TryGetComponent<UIGamePad>(ref val2)) { Object.DestroyImmediate((Object)(object)val2); } ButtonTextColor val3 = default(ButtonTextColor); if (val.TryGetComponent<ButtonTextColor>(ref val3)) { Object.DestroyImmediate((Object)(object)val3); } _searchTabButton = val.GetComponent<Button>(); _searchTabButton.onClick = new ButtonClickedEvent(); ((Selectable)_searchTabButton).interactable = true; ButtonClickedEvent onClick = _searchTabButton.onClick; object obj = <>c.<>9__110_0; if (obj == null) { UnityAction val4 = delegate { SetSearchTabActive(_gui, active: true); }; <>c.<>9__110_0 = val4; obj = (object)val4; } ((UnityEvent)onClick).AddListener((UnityAction)obj); for (int num = val.transform.childCount - 1; num >= 0; num--) { Transform child = val.transform.GetChild(num); if (((Object)child).name.IndexOf("gamepad", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)child).name.IndexOf("hint", StringComparison.OrdinalIgnoreCase) >= 0) { Object.DestroyImmediate((Object)(object)((Component)child).gameObject); } } _craftTabReturn = BuildSelectedTabReturn(gui.m_tabCraft, new UnityAction(gui.OnTabCraftPressed)); _upgradeTabReturn = BuildSelectedTabReturn(gui.m_tabUpgrade, new UnityAction(gui.OnTabUpgradePressed)); Transform obj2 = val.transform.Find("Text"); _searchTabLabel = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null) ?? val.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)_searchTabLabel != (Object)null) { _nativeTabTextColor = ((Graphic)_searchTabLabel).color; _searchTabLabel.text = "Search"; ((Graphic)_searchTabLabel).raycastTarget = false; AddSearchTabTextGlow(); } _searchTabGlow = CreateGlowOverlay(val.transform, "CyberGlow", 5f, 0f); } private static void AddSearchTabTextGlow() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) Material fontSharedMaterial = _searchTabLabel.fontSharedMaterial; if (!((Object)(object)fontSharedMaterial == (Object)null) && fontSharedMaterial.HasProperty(ShaderUtilities.ID_GlowColor)) { _searchTabGlowMaterial = new Material(fontSharedMaterial); _searchTabGlowMaterial.EnableKeyword(ShaderUtilities.Keyword_Glow); _searchTabGlowMaterial.SetFloat(ShaderUtilities.ID_GlowOffset, 0f); _searchTabGlowMaterial.SetFloat(ShaderUtilities.ID_GlowInner, 0.04f); _searchTabGlowMaterial.SetFloat(ShaderUtilities.ID_GlowOuter, 0.22f); _searchTabGlowMaterial.SetFloat(ShaderUtilities.ID_GlowPower, 0.65f); _searchTabGlowMaterial.SetColor(ShaderUtilities.ID_GlowColor, Color.clear); _searchTabLabel.fontSharedMaterial = _searchTabGlowMaterial; _searchTabLabel.UpdateMeshPadding(); } } private static GameObject BuildSelectedTabReturn(Button vanillaTab, UnityAction onClick) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown GameObject val = new GameObject("SortAndSearch_ReturnToTab", new Type[3] { typeof(RectTransform), typeof(Image), typeof(Button) }); val.SetActive(false); val.transform.SetParent(((Component)vanillaTab).transform, false); StretchFill(val.GetComponent<RectTransform>()); ((Graphic)val.GetComponent<Image>()).color = Color.clear; Button component = val.GetComponent<Button>(); ((Selectable)component).transition = (Transition)0; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)component).navigation = navigation; ((UnityEvent)component.onClick).AddListener(onClick); return val; } private static void BuildRecipeSortBar(InventoryGui gui) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to