using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using AzuExtendedPlayerInventory; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using ExtraSlotsAPI; using GUIFramework; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using MyLittleUI; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("My Little UI")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("My Little UI")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("345181bf-e9ed-4c88-a4f4-38450f53cc41")] [assembly: AssemblyFileVersion("1.2.12")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.12.0")] [module: UnverifiableCode] [HarmonyPatch] public static class Advize_StumpsRegrow_Compat { internal const string GUID = "advize.StumpsRegrow"; private static ConfigEntry stumpGrowthTime; private static bool initialized; private static bool hasGrowthTime; public static MethodBase target; private static double GetTimeSincePlanted(ZNetView nview) { return (ZNet.instance.GetTime() - new DateTime(nview.GetZDO().GetLong(ZDOVars.s_plantTime, 0L))).TotalSeconds; } private static float GetGrowTime() { return (stumpGrowthTime != null) ? Mathf.Max(stumpGrowthTime.Value, 1f) : 1f; } private static void Postfix(object __instance, ref string __result) { if (!global::MyLittleUI.MyLittleUI.modEnabled.Value || __instance == null || !global::MyLittleUI.MyLittleUI.hoverStumpGrowerEnabled.Value || global::MyLittleUI.MyLittleUI.hoverStumpGrower.Value == global::MyLittleUI.MyLittleUI.StationHover.Vanilla || string.IsNullOrWhiteSpace(__result)) { return; } if (!initialized) { initialized = true; hasGrowthTime = Chainloader.PluginInfos.TryGetValue("advize.StumpsRegrow", out var value) && value.Instance.Config.TryGetEntry("General", "StumpGrowthTime", ref stumpGrowthTime); } if (!hasGrowthTime) { return; } object obj = ((__instance is MonoBehaviour) ? __instance : null); ZNetView val = ((obj != null) ? ((Component)obj).GetComponent() : null); if (!((Object)(object)val == (Object)null) && val.IsValid()) { if (global::MyLittleUI.MyLittleUI.hoverStumpGrower.Value == global::MyLittleUI.MyLittleUI.StationHover.Percentage) { __result += $"\n{GetTimeSincePlanted(val) / (double)GetGrowTime():P0}"; } else if (global::MyLittleUI.MyLittleUI.hoverStumpGrower.Value == global::MyLittleUI.MyLittleUI.StationHover.Bar) { __result = __result + "\n" + global::MyLittleUI.MyLittleUI.FromPercent(GetTimeSincePlanted(val) / (double)GetGrowTime()); } else if (global::MyLittleUI.MyLittleUI.hoverStumpGrower.Value == global::MyLittleUI.MyLittleUI.StationHover.MinutesSeconds) { __result = __result + "\n" + global::MyLittleUI.MyLittleUI.FromSeconds((double)GetGrowTime() - GetTimeSincePlanted(val)); } } } public static bool Prepare(MethodBase original) { if (!Chainloader.PluginInfos.TryGetValue("advize.StumpsRegrow", out var value)) { return false; } if ((object)target == null) { target = AccessTools.Method(((object)value.Instance).GetType().Assembly.GetType("Advize_StumpsRegrow.StumpGrower"), "GetHoverText", (Type[])null, (Type[])null); } if (target == null) { return false; } if (original == null) { global::MyLittleUI.MyLittleUI.LogInfo("Advize_StumpsRegrow.StumpGrower:GetHoverText method is patched to show configurable hover"); } return true; } public static MethodBase TargetMethod() { return target; } } namespace MyLittleUI { internal class AmmoCountIcon { public class ElementExtraData { public TMP_Text m_ammo; public Image m_icon; public Image m_bait; public Image m_mead; public ItemData m_item; public void UpdateState(ElementData elementData) { if (m_item == null) { TMP_Text ammo = m_ammo; if (ammo != null) { ((Component)ammo).gameObject.SetActive(false); } Image icon = m_icon; if (icon != null) { ((Component)icon).gameObject.SetActive(false); } Image bait = m_bait; if (bait != null) { ((Component)bait).gameObject.SetActive(false); } Image mead = m_mead; if (mead != null) { ((Component)mead).gameObject.SetActive(false); } return; } ItemData currentAmmo = GetCurrentAmmo(); int num = ((currentAmmo != null) ? ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(currentAmmo.m_shared.m_name, -1, true) : 0); TMP_Text ammo2 = m_ammo; if (ammo2 != null) { ((Component)ammo2).gameObject.SetActive(MyLittleUI.ammoCountEnabled.Value && num > 0); } if (num > 0) { TMP_Text ammo3 = m_ammo; if (ammo3 != null) { ammo3.SetText(num.ToString()); } } Sprite val = ((currentAmmo != null) ? currentAmmo.GetIcon() : null); Image icon2 = m_icon; if (icon2 != null) { ((Component)icon2).gameObject.SetActive(MyLittleUI.ammoIconEnabled.Value && (Object)(object)val != (Object)null); } if ((Object)(object)val != (Object)null && (Object)(object)m_icon != (Object)null) { m_icon.overrideSprite = val; } ItemData currentBait = GetCurrentBait(); Sprite val2 = ((currentBait != null) ? currentBait.GetIcon() : null); Image bait2 = m_bait; if (bait2 != null) { ((Component)bait2).gameObject.SetActive(MyLittleUI.baitIconEnabled.Value && (Object)(object)val2 != (Object)null); } if ((Object)(object)val2 != (Object)null && (Object)(object)m_bait != (Object)null) { m_bait.overrideSprite = val2; } int num2 = ((currentBait != null) ? ((Humanoid)Player.m_localPlayer).GetInventory().CountItems(currentBait.m_shared.m_name, -1, true) : 0); if (num2 > 0 && MyLittleUI.baitCountEnabled.Value && !((Component)elementData.m_amount).gameObject.activeSelf) { ((Component)elementData.m_amount).gameObject.SetActive(true); elementData.m_amount.SetText(num2.ToString()); } ItemData currentMead = GetCurrentMead(); Sprite val3 = ((currentMead != null) ? currentMead.GetIcon() : null); Image mead2 = m_mead; if (mead2 != null) { ((Component)mead2).gameObject.SetActive(MyLittleUI.meadIconEnabled.Value && (Object)(object)val3 != (Object)null); } if ((Object)(object)val3 != (Object)null && (Object)(object)m_mead != (Object)null) { m_mead.overrideSprite = val3; } } private ItemData GetCurrentAmmo() { if (m_item == null || Utility.IsNullOrWhiteSpace(m_item.m_shared.m_ammoType) || IsBaitAmmo() || IsAmmo() || IsMeadAmmo()) { return null; } ItemData ammoItem = ((Humanoid)Player.m_localPlayer).GetAmmoItem(); if (ammoItem == null || ammoItem.m_shared.m_ammoType != m_item.m_shared.m_ammoType || !((Humanoid)Player.m_localPlayer).GetInventory().ContainsItem(ammoItem)) { ammoItem = ((Humanoid)Player.m_localPlayer).GetInventory().GetAmmoItem(m_item.m_shared.m_ammoType, (string)null); } return ammoItem; } private ItemData GetCurrentBait() { if (m_item == null || Utility.IsNullOrWhiteSpace(m_item.m_shared.m_ammoType) || !IsBaitAmmo() || IsAmmo()) { return null; } ItemData ammoItem = ((Humanoid)Player.m_localPlayer).GetAmmoItem(); if (ammoItem == null || ammoItem.m_shared.m_ammoType != m_item.m_shared.m_ammoType || !((Humanoid)Player.m_localPlayer).GetInventory().ContainsItem(ammoItem)) { ammoItem = ((Humanoid)Player.m_localPlayer).GetInventory().GetAmmoItem(m_item.m_shared.m_ammoType, (string)null); } return ammoItem; } private ItemData GetCurrentMead() { if (m_item == null || Utility.IsNullOrWhiteSpace(m_item.m_shared.m_ammoType) || IsBaitAmmo() || IsAmmo() || !IsMeadAmmo()) { return null; } return ((Humanoid)Player.m_localPlayer).GetInventory().GetAmmoItem(m_item.m_shared.m_ammoType, (string)null); } private bool IsAmmo() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 return (int)m_item.m_shared.m_itemType == 9 || (int)m_item.m_shared.m_itemType == 23 || (int)m_item.m_shared.m_itemType == 2; } private bool IsBaitAmmo() { return m_item.m_shared.m_ammoType == "$item_fishingbait"; } private bool IsMeadAmmo() { return m_item.m_shared.m_ammoType == "mead"; } } [HarmonyPatch(typeof(HotkeyBar), "OnEnable")] public static class HotkeyBar_OnEnable_AddCustomElementsToHotkeyPrefab { private static void FillFields(RectTransform rtSource, RectTransform rtDestination) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) rtDestination.anchoredPosition = rtSource.anchoredPosition; rtDestination.sizeDelta = rtSource.sizeDelta; } public static void Postfix(HotkeyBar __instance) { if (!((Object)(object)__instance.m_elementPrefab == (Object)null)) { isDirty[__instance] = false; elementPrefab = __instance.m_elementPrefab; int num = __instance.m_elementPrefab.transform.Find("icon").GetSiblingIndex() + 1; Transform obj = __instance.m_elementPrefab.transform.Find("MLUI_AmmoAmount"); ammoCount = ((obj != null) ? ((Component)obj).gameObject : null); if ((Object)(object)ammoCount == (Object)null) { GameObject gameObject = ((Component)__instance.m_elementPrefab.transform.Find("amount")).gameObject; ammoCount = Object.Instantiate(gameObject); ((Object)ammoCount).name = "MLUI_AmmoAmount"; ammoCount.transform.SetParent(__instance.m_elementPrefab.transform); ammoCount.transform.SetSiblingIndex(num); num++; ammoCount.SetActive(false); FillFields(gameObject.GetComponent(), ammoCount.GetComponent()); } Transform obj2 = __instance.m_elementPrefab.transform.Find("MLUI_AmmoIcon"); ammoIcon = ((obj2 != null) ? ((Component)obj2).gameObject : null); if ((Object)(object)ammoIcon == (Object)null) { GameObject gameObject2 = ((Component)__instance.m_elementPrefab.transform.Find("icon")).gameObject; ammoIcon = Object.Instantiate(gameObject2); ((Object)ammoIcon).name = "MLUI_AmmoIcon"; ammoIcon.transform.SetParent(__instance.m_elementPrefab.transform); ammoIcon.transform.SetSiblingIndex(num); num++; ammoIcon.SetActive(false); FillFields(gameObject2.GetComponent(), ammoIcon.GetComponent()); } Transform obj3 = __instance.m_elementPrefab.transform.Find("MLUI_AmmoBait"); ammoBait = ((obj3 != null) ? ((Component)obj3).gameObject : null); if ((Object)(object)ammoBait == (Object)null) { GameObject gameObject3 = ((Component)__instance.m_elementPrefab.transform.Find("icon")).gameObject; ammoBait = Object.Instantiate(gameObject3); ((Object)ammoBait).name = "MLUI_AmmoBait"; ammoBait.transform.SetParent(__instance.m_elementPrefab.transform); ammoBait.transform.SetSiblingIndex(num); num++; ammoBait.SetActive(false); FillFields(gameObject3.GetComponent(), ammoBait.GetComponent()); } Transform obj4 = __instance.m_elementPrefab.transform.Find("MLUI_AmmoMead"); ammoMead = ((obj4 != null) ? ((Component)obj4).gameObject : null); if ((Object)(object)ammoMead == (Object)null) { GameObject gameObject4 = ((Component)__instance.m_elementPrefab.transform.Find("icon")).gameObject; ammoMead = Object.Instantiate(gameObject4); ((Object)ammoMead).name = "MLUI_AmmoMead"; ammoMead.transform.SetParent(__instance.m_elementPrefab.transform); ammoMead.transform.SetSiblingIndex(num); num++; ammoMead.SetActive(false); FillFields(gameObject4.GetComponent(), ammoMead.GetComponent()); } UpdateVisibility(); } } } [HarmonyPatch(typeof(HotkeyBar), "Update")] public static class HotkeyBar_Update_UpdateAmmoIconCountDirtyState { [HarmonyPriority(0)] [HarmonyBefore(new string[] { "Azumatt.AzuExtendedPlayerInventory", "shudnal.ExtraSlots" })] public static void Prefix(HotkeyBar __instance) { if (MyLittleUI.modEnabled.Value && GeneralExtensions.GetValueSafe(isDirty, __instance)) { isDirty[__instance] = false; if (__instance.m_elements.Count > 0) { __instance.m_items.Clear(); __instance.UpdateIcons((Player)null); } } } } [HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")] public static class HotkeyBar_UpdateIcons_UpdateAmmoCountAndIcon { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "Azumatt.AzuExtendedPlayerInventory", "shudnal.ExtraSlots" })] public static void Postfix(HotkeyBar __instance, Player player) { if (!MyLittleUI.modEnabled.Value) { return; } if (!elementExtraDatas.ContainsKey(__instance)) { elementExtraDatas.Add(__instance, new Dictionary()); } Dictionary dictionary = elementExtraDatas[__instance]; if (!Object.op_Implicit((Object)(object)player) || ((Character)player).IsDead()) { dictionary.Clear(); return; } if (dictionary.Count != __instance.m_elements.Count) { dictionary.Clear(); } if (dictionary.Count > 0 && __instance.m_elements.Count > 0 && !dictionary.ContainsKey(__instance.m_elements[0])) { dictionary.Clear(); } if (dictionary.Count == 0) { for (int i = 0; i < __instance.m_elements.Count; i++) { ElementData val = __instance.m_elements[i]; ElementExtraData value = new ElementExtraData { m_ammo = ((Component)val.m_go.transform.Find("MLUI_AmmoAmount")).GetComponent(), m_icon = ((Component)val.m_go.transform.Find("MLUI_AmmoIcon")).GetComponent(), m_bait = ((Component)val.m_go.transform.Find("MLUI_AmmoBait")).GetComponent(), m_mead = ((Component)val.m_go.transform.Find("MLUI_AmmoMead")).GetComponent() }; dictionary.Add(val, value); } } int num = 0; for (int j = 0; j < __instance.m_elements.Count; j++) { ElementData val2 = __instance.m_elements[j]; ElementExtraData elementExtraData = dictionary[val2]; if (elementExtraData == null) { continue; } if (!val2.m_used || num > __instance.m_items.Count) { elementExtraData.m_item = null; } else { elementExtraData.m_item = __instance.m_items[num]; if ((Object)(object)elementExtraData.m_item.GetIcon() != (Object)(object)val2.m_icon.sprite) { elementExtraData.m_item = null; } num++; } elementExtraData.UpdateState(val2); } } } internal const string objectAmmoName = "MLUI_AmmoAmount"; internal const string objectIconName = "MLUI_AmmoIcon"; internal const string objectBaitName = "MLUI_AmmoBait"; internal const string objectMeadName = "MLUI_AmmoMead"; internal static GameObject elementPrefab; internal static GameObject ammoCount; internal static GameObject ammoIcon; internal static GameObject ammoBait; internal static GameObject ammoMead; internal static readonly Dictionary isDirty = new Dictionary(); internal static readonly Dictionary> elementExtraDatas = new Dictionary>(); public static void UpdateVisibility() { //IL_0012: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) RectTransform component = ammoCount.GetComponent(); component.anchoredPosition = MyLittleUI.ammoCountPosition.Value; TMP_Text component2 = ammoCount.GetComponent(); component2.fontSize = MyLittleUI.ammoCountFontSize.Value; ((Graphic)component2).color = ((MyLittleUI.ammoCountColor.Value == Color.clear) ? ((Graphic)((Component)elementPrefab.transform.Find("amount")).GetComponent()).color : MyLittleUI.ammoCountColor.Value); component2.horizontalAlignment = MyLittleUI.ammoCountAlignment.Value; RectTransform component3 = ammoIcon.GetComponent(); component3.anchoredPosition = MyLittleUI.ammoIconPosition.Value; component3.sizeDelta = MyLittleUI.ammoIconSize.Value; RectTransform component4 = ammoBait.GetComponent(); component4.anchorMin = new Vector2(0.5f, 0f); component4.anchorMax = new Vector2(1f, 0.5f); RectTransform component5 = ammoMead.GetComponent(); component5.anchorMin = new Vector2(0.6f, 0.6f); component5.anchorMax = new Vector2(1f, 1f); foreach (HotkeyBar item in isDirty.Keys.ToList()) { isDirty[item] = true; } } } internal class ChestItem { public int m_stack; public int m_value; public string m_name; public float m_weight; public ItemType m_itemType; public ChestItem(ItemData itemData) { //IL_0020: 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) m_name = itemData.m_shared.m_name; m_itemType = itemData.m_shared.m_itemType; } } internal static class ChestHoverText { [HarmonyPatch(typeof(Container), "OnContainerChanged")] private static class Container_OnContainerChanged_HoverCacheReset { private static void Postfix(Container __instance) { if (MyLittleUI.modEnabled.Value) { ResetCache(__instance); } } } [HarmonyPatch(typeof(Container), "GetHoverText")] private static class Container_GetHoverText_Duration { private static readonly StringBuilder result = new StringBuilder(); private static void ReorderItemList(ref List itemsInChest) { if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Position) { return; } if (MyLittleUI.chestContentSortDir.Value == MyLittleUI.ContentSortDir.Desc) { if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Name) { itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_name).ToList(); } else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Weight) { itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_weight).ToList(); } else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Amount) { itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_stack).ToList(); } else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Value) { itemsInChest = itemsInChest.OrderByDescending((ChestItem item) => item.m_value).ToList(); } } else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Name) { itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_name).ToList(); } else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Weight) { itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_weight).ToList(); } else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Amount) { itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_stack).ToList(); } else if (MyLittleUI.chestContentSortType.Value == MyLittleUI.ContentSortType.Value) { itemsInChest = itemsInChest.OrderBy((ChestItem item) => item.m_value).ToList(); } } private static void AddChestContent(Container container) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected I4, but got Unknown if (container.GetInventory().NrOfItems() == 0) { return; } result.Append("\n"); List itemsInChest = new List(); foreach (ItemData itemData in container.GetInventory().GetAllItemsInGridOrder()) { ChestItem chestItem = itemsInChest.Find((ChestItem item) => item.m_name == itemData.m_shared.m_name); if (chestItem == null) { chestItem = new ChestItem(itemData); itemsInChest.Add(chestItem); } chestItem.m_stack += itemData.m_stack; chestItem.m_value += itemData.GetValue(); chestItem.m_weight += itemData.GetWeight(-1); } ReorderItemList(ref itemsInChest); string itemFormat = "{0}"; string amountFormat = "{0}"; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; for (int i = 0; i < itemsInChest.Count; i++) { ChestItem chestItem2 = itemsInChest[i]; if (i < MyLittleUI.chestContentLinesToShow.Value) { AddItemLine(chestItem2.m_name, chestItem2.m_stack); continue; } ItemType itemType = chestItem2.m_itemType; ItemType val = itemType; switch (val - 1) { case 1: num3++; break; case 0: num5++; break; case 2: case 3: case 4: case 13: case 14: case 18: case 19: case 21: num4++; break; case 5: case 6: case 9: case 10: case 11: case 16: case 17: num2++; break; default: num++; break; } } if (num + num2 + num3 + num4 + num5 != 0) { result.Append("\n+"); if (num4 != 0) { AddItemLine("$radial_handitems", num4); } if (num2 != 0) { AddItemLine("$radial_armor_utility", num2); } if (num3 != 0) { AddItemLine("$radial_consumables", num3); } if (num5 != 0) { AddItemLine("$hud_crafting", num5); } if (num != 0) { AddItemLine("$hud_misc", num); } } void AddItemLine(string itemName, int amount) { result.AppendFormat("\n" + MyLittleUI.chestContentEntryFormat.Value, string.Format(itemFormat, itemName), string.Format(amountFormat, amount)); } } private static void Postfix(Container __instance, ref string __result, bool ___m_checkGuardStone, string ___m_name, Inventory ___m_inventory) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!MyLittleUI.modEnabled.Value || (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.Vanilla && MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.Vanilla) || (Object)(object)__instance.m_nview == (Object)null || !__instance.m_nview.IsValid() || (___m_checkGuardStone && !PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, false, false))) { return; } string key = ((object)__instance.m_nview.GetZDO()).ToString(); if (hoverTextCache.TryGetValue(key, out var value)) { __result = value; return; } result.Clear(); string @string = __instance.m_nview.GetZDO().GetString(ZDOVars.s_text, ""); if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.Vanilla || !MyLittleUI.chestCustomName.Value || Utility.IsNullOrWhiteSpace(@string)) { result.Append(___m_name); } else if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.CustomName) { result.Append(@string); } else if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.TypeThenCustomName) { result.Append(___m_name); result.Append(" ("); result.Append(@string); result.Append(")"); } else if (MyLittleUI.chestHoverName.Value == MyLittleUI.ChestNameHover.CustomNameThenType) { result.Append(@string); result.Append(" ("); result.Append(___m_name); result.Append(")"); } if (__instance.CheckAccess(Game.instance.GetPlayerProfile().GetPlayerID())) { result.Append(" "); if (MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.Percentage) { result.Append($"{___m_inventory.SlotsUsedPercentage():F0}%"); } else if (MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.FreeSlots) { result.Append($"{___m_inventory.GetEmptySlots()}"); } else if (MyLittleUI.chestHoverItems.Value == MyLittleUI.ChestItemsHover.ItemsMaxRoom) { result.Append($"{___m_inventory.NrOfItems()}/{___m_inventory.GetWidth() * ___m_inventory.GetHeight()}"); } else if (___m_inventory.NrOfItems() == 0) { result.Append("( $piece_container_empty )"); } result.Append("\n[$KEY_Use] $piece_container_open"); if (MyLittleUI.chestShowHoldToStack.Value) { result.Append(" $msg_stackall_hover"); } if (MyLittleUI.chestShowRename.Value) { if (!ZInput.IsNonClassicFunctionality() || !ZInput.IsGamepadActive()) { result.Append("\n[$KEY_AltPlace + $KEY_Use] $hud_rename"); } else { result.Append("\n[$KEY_JoyAltKeys + $KEY_Use] $hud_rename"); } } if (MyLittleUI.chestContentEnabled.Value) { AddChestContent(__instance); } } __result = Localization.instance.Localize(result.ToString()); hoverTextCache.Add(key, __result); } } [HarmonyPatch(typeof(Container), "Interact")] private class Container_Interact_ChestRename { private static bool Prefix(Container __instance, Humanoid character, bool hold, bool alt, bool ___m_checkGuardStone) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) if (!MyLittleUI.modEnabled.Value) { return true; } if (!MyLittleUI.chestCustomName.Value) { return true; } if (!alt) { return true; } if (hold) { return true; } if (___m_checkGuardStone && !PrivateArea.CheckAccess(((Component)__instance).transform.position, 0f, true, false)) { ((Character)character).Message((MessageType)2, "$piece_noaccess", 0, (Sprite)null); return true; } long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); if (!__instance.CheckAccess(playerID)) { ((Character)character).Message((MessageType)2, "$piece_noaccess", 0, (Sprite)null); return true; } textInputForContainer = __instance; TextInput.instance.Show("$hud_rename " + __instance.m_name, __instance.m_nview.GetZDO().GetString(ZDOVars.s_text, ""), 32); return false; } } [HarmonyPatch(typeof(TextInput), "setText")] private class TextInput_setText_ChestRename { private static void Postfix(string text) { if (MyLittleUI.modEnabled.Value && !((Object)(object)textInputForContainer == (Object)null)) { textInputForContainer.m_nview.GetZDO().Set(ZDOVars.s_text, text); textInputForContainer.OnContainerChanged(); textInputForContainer = null; } } } [HarmonyPatch(typeof(TextInput), "Hide")] private class TextInput_Hide_ChestRename { private static void Postfix() { if (MyLittleUI.modEnabled.Value && !((Object)(object)textInputForContainer == (Object)null)) { textInputForContainer = null; } } } private static Container textInputForContainer; private static readonly Dictionary hoverTextCache = new Dictionary(); internal static void ResetCache(Container container) { if (!((Object)(object)container == (Object)null) && !((Object)(object)container.m_nview == (Object)null) && container.m_nview.IsValid()) { hoverTextCache.Remove(((object)container.m_nview.GetZDO()).ToString()); } } internal static void ResetHoverCache() { hoverTextCache.Clear(); } } public static class CookingStationRemoveItem { [HarmonyPatch(typeof(CookingStation), "RPC_AddItem")] public static class CookingStation_RPC_AddItem_SetItemAuthor { public static long author; public static void Prefix(long sender) { author = sender; } public static void Postfix() { author = 0L; } } [HarmonyPatch(typeof(CookingStation), "SetSlot")] public static class CookingStation_SetSlot_RemoveLastItem { public static void Postfix(CookingStation __instance, int slot) { if (__instance.m_nview.IsValid() && CookingStation_RPC_AddItem_SetItemAuthor.author != 0) { __instance.m_nview.GetZDO().Set(ZDOSlotAuthor(slot), CookingStation_RPC_AddItem_SetItemAuthor.author); } } } [HarmonyPatch(typeof(CookingStation), "Interact")] public static class CookingStation_Interact_RemoveLastItem { public static bool Prefix(CookingStation __instance, Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)__instance.m_addFoodSwitch != (Object)null || !alt) { return true; } RemoveLastItemFromStation(__instance, user); return false; } } [HarmonyPatch(typeof(Switch), "Interact")] public static class Switch_Interact_RemoveLastItem { public static bool Prefix(Switch __instance, Humanoid character, bool hold, bool alt) { if (hold || !alt || !MyLittleUI.hoverCookingRemoveLastItem.Value) { return true; } if (__instance.m_onUse != null) { CookingStation componentInParent = ((Component)__instance).GetComponentInParent(); if (componentInParent != null && (Object)(object)componentInParent.m_addFoodSwitch == (Object)(object)__instance) { RemoveLastItemFromStation(componentInParent, character); return false; } } return true; } } [HarmonyPatch(typeof(ZoneSystem), "Start")] public static class ZoneSystem_Start_Taxi { private static void Postfix() { ZRoutedRpc.instance.Register("RPC_MLUI_RemoveLastUncookedItem", (Action)RPC_MLUI_RemoveLastUncookedItem); ZRoutedRpc.instance.Register("RPC_MLUI_UndoCookingSkillRaise", (Action)RPC_MLUI_UndoCookingSkillRaise); } } private static string ZDOSlotAuthor(int slot) { return "slotauthor" + slot; } private static long GetCurrentAuthor(CookingStation __instance, int slot) { return __instance.m_nview.GetZDO().GetLong(ZDOSlotAuthor(slot), 0L); } public static int GetSlotToRemove(CookingStation station, out string itemName, out long author) { float num2 = default(float); Status val = default(Status); for (int num = station.m_slots.Length - 1; num >= 0; num--) { station.GetSlot(num, ref itemName, ref num2, ref val); if (!(itemName == "") && !station.IsItemDone(itemName)) { author = GetCurrentAuthor(station, num); return num; } } author = 0L; itemName = ""; return -1; } public static void RPC_MLUI_RemoveLastUncookedItem(long sender, ZDOID targetZDO, Vector3 userPoint) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (((ZDOID)(ref targetZDO)).IsNone()) { return; } ZDO zDO = ZDOMan.instance.GetZDO(targetZDO); if (zDO == null) { return; } ZNetView val = ZNetScene.instance.FindInstance(zDO); if ((Object)(object)val != (Object)null && val.IsValid() && val.IsOwner()) { CookingStation componentInParent = ((Component)val).GetComponentInParent(); if (componentInParent != null) { RemoveLastItem(sender, componentInParent, userPoint); } } } internal static void RemoveLastItem(long sender, CookingStation station, Vector3 userPoint) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) string itemName; long author; int slotToRemove = GetSlotToRemove(station, out itemName, out author); if (slotToRemove != -1) { station.SpawnItem(itemName, slotToRemove, userPoint); station.SetSlot(slotToRemove, "", 0f, (Status)0); station.m_nview.InvokeRPC(ZNetView.Everybody, "RPC_SetSlotVisual", new object[2] { slotToRemove, "" }); if (author != 0) { ZRoutedRpc.instance.InvokeRoutedRPC(author, "RPC_MLUI_UndoCookingSkillRaise", Array.Empty()); } } } internal static void RPC_MLUI_UndoCookingSkillRaise(long sender) { ((Character)Player.m_localPlayer).RaiseSkill((SkillType)105, -0.4f); } private static void RemoveLastItemFromStation(CookingStation station, Humanoid user) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)station.m_nview != (Object)null && station.m_nview.IsValid()) { ZRoutedRpc.instance.InvokeRoutedRPC(station.m_nview.GetZDO().GetOwner(), "RPC_MLUI_RemoveLastUncookedItem", new object[2] { station.m_nview.GetZDO().m_uid, ((Component)user).transform.position }); } } } public static class CraftFilter { [HarmonyPatch(typeof(InventoryGui), "Awake")] public static class StoreGui_Awake_InitializePanel { [HarmonyPriority(800)] private static void Postfix() { InitFilterField(); UpdateVisibility(); } } [HarmonyPatch(typeof(InventoryGui), "Show")] public static class InventoryGui_Show_ClearCache { public static void Postfix() { ClearText(); } } [HarmonyPatch(typeof(InventoryGui), "OnDestroy")] public static class InventoryGui_OnDestroy_ClearCache { public static void Postfix() { recipeCache.Clear(); } } [HarmonyPatch(typeof(Chat), "HasFocus")] public static class Chat_HasFocus_FocusOverride { public static void Postfix(ref bool __result) { __result = __result || (IsCraftingFilterEnabled && ((TMP_InputField)playerFilter).isFocused); } } [HarmonyPatch(typeof(Player), "GetAvailableRecipes")] public static class Player_GetAvailableRecipes_FilterRecipeList { [HarmonyPriority(0)] public static void Postfix(ref List available) { if (IsCraftingFilterEnabled && applyFilter) { Stopwatch stopwatch = Stopwatch.StartNew(); CollectionExtensions.Do((IEnumerable)available, (Action)CacheRecipe); MyLittleUI.LogInfo($"Recipe cache: verified {recipeCache.Count} in {(double)stopwatch.ElapsedTicks / (double)Stopwatch.Frequency * 1000.0:F2} ms"); stopwatch.Reset(); MyLittleUI.LogInfo($"Recipe filter: removed {available.RemoveAll((Recipe recipe) => !FitsFilterString(recipe))} in {(double)stopwatch.ElapsedTicks / (double)Stopwatch.Frequency * 1000.0:F2} ms"); stopwatch.Stop(); } } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")] public static class InventoryGui_UpdateRecipe_HandleFieldFocus { public static void Postfix() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (!IsCraftingFilterEnabled) { return; } bool flag = (int)ZInput.InputLayout == 1; bool button = ZInput.GetButton("JoyLBumper"); bool button2 = ZInput.GetButton("JoyLTrigger"); if (((TMP_InputField)playerFilter).isFocused) { if (ZInput.GetButtonDown("Chat") || ZInput.GetButtonDown("Block") || ZInput.GetButtonDown("Console") || ZInput.GetButtonDown("Escape") || ZInput.GetButtonDown("Inventory") || (ZInput.GetButtonDown("JoyChat") && ZInput.GetButton("JoyAltKeys") && !(flag && button2) && !(!flag && button))) { ((TMP_InputField)playerFilter).DeactivateInputField(false); } } else if ((Object)(object)Player.m_localPlayer != (Object)null && !Console.IsVisible() && !TextInput.IsVisible() && !Minimap.InTextInput() && !Menu.IsVisible() && (ZInput.GetButtonDown("Chat") || (ZInput.GetButtonDown("JoyChat") && ZInput.GetButton("JoyAltKeys") && !(flag && button2) && !(!flag && button)))) { playerFilter.ActivateInputField(); } } } private const float fieldHeight = 32f; private static Vector2 listAnchorMin = new Vector2(-1f, -1f); private static readonly Dictionary recipeCache = new Dictionary(); private static GuiInputField playerFilter; private static string[] filterString = Array.Empty(); private static bool applyFilter; private static readonly StringBuilder sb = new StringBuilder(); private static readonly StringBuilder sbItem = new StringBuilder(); public static bool IsCraftingFilterEnabled => MyLittleUI.modEnabled.Value && MyLittleUI.craftingFilterEnabled.Value && !MyLittleUI.AAA_Crafting && !MyLittleUI.ZenUI; private static void InitFilterField() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) if (!MyLittleUI.AAA_Crafting && !MyLittleUI.ZenUI) { Transform parent = ((Component)InventoryGui.instance.m_recipeListScroll).transform.parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); GameObject val2 = Object.Instantiate(((Component)TextInput.instance.m_inputField).gameObject, ((Transform)val).parent); ((Object)val2).name = "MLUI_FilterField"; val2.transform.SetSiblingIndex(((Transform)val).GetSiblingIndex() + 1); RectTransform component = val2.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.zero; Rect rect = val.rect; component.sizeDelta = new Vector2(((Rect)(ref rect)).width, 32f); component.anchoredPosition = new Vector2(val.anchoredPosition.x, 4f); component.pivot = Vector2.zero; playerFilter = val2.GetComponent(); playerFilter.VirtualKeyboardTitle = "$menu_filter"; ((Component)((Component)playerFilter).transform.Find("Text Area/Placeholder")).GetComponent().SetText(Localization.instance.Localize("$menu_filter")); ((TMP_InputField)playerFilter).restoreOriginalTextOnEscape = false; Button val3 = Object.Instantiate