Please disclose if your mod was created primarily 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 Favorite Items v0.1.5
favoriteItems.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; 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("favoriteItems")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("favoriteItems Mod")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e3c2754a95a2aef0f915ef5eabacc0a60aa6c4d2")] [assembly: AssemblyProduct("favoriteItems")] [assembly: AssemblyTitle("favoriteItems")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace favoriteItems { [BepInPlugin("com.grizzyggs.FavoriteItems", "Favorite Items", "0.1.1")] public class Main : BaseUnityPlugin { [HarmonyPatch(typeof(Humanoid), "IsItemEquiped")] public static class Inventory_MoveItem_Patch { [HarmonyPatch(typeof(Container), "StackAll")] public static class Container_StackAll_Patch { [HarmonyPrefix] public static void Prefix() { logger.LogDebug((object)"Quick stacking now"); IsQuickStacking = true; } [HarmonyPostfix] public static void Postfix() { logger.LogDebug((object)"No longer quick stacking"); IsQuickStacking = false; } } [HarmonyPrefix] public static bool Prefix(Inventory __instance, ItemData item, ref bool __result) { if (!IsQuickStacking) { return true; } if (item.m_customData.ContainsKey(FavoriteKey)) { logger.LogDebug((object)("Item blocked from quick stacking: " + item.m_shared.m_name)); __result = true; return false; } logger.LogDebug((object)("Item allowed to quick stack: " + item.m_shared.m_name)); return true; } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui")] public static class InventoryGrid_Patch { public static void Postfix(InventoryGrid __instance, Player player, ItemData dragItem) { //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null || __instance.m_inventory == null) { return; } foreach (Element element in __instance.m_elements) { if ((Object)(object)element?.m_go == (Object)null) { continue; } Transform val = element.m_go.transform.Find("FavoriteText"); if (!element.m_used) { if (val != null) { ((Component)val).gameObject.SetActive(false); } continue; } ItemData itemAt = __instance.m_inventory.GetItemAt(element.m_pos.x, element.m_pos.y); if (itemAt != null && (itemAt.m_customData?.ContainsKey(FavoriteKey)).GetValueOrDefault()) { TextMeshProUGUI val3; if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("FavoriteText", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(element.m_go.transform, false); val3 = val2.AddComponent<TextMeshProUGUI>(); ((Graphic)val3).raycastTarget = false; if ((Object)(object)element.m_amount != (Object)null) { ((TMP_Text)val3).font = element.m_amount.font; ((TMP_Text)val3).fontSize = element.m_amount.fontSize; } ((Graphic)val3).color = Color.yellow; ((TMP_Text)val3).alignment = (TextAlignmentOptions)1028; RectTransform component = val2.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 0f); component.pivot = new Vector2(1f, 0f); component.anchoredPosition = new Vector2(-2f, 2f); } else { val3 = ((Component)val).GetComponent<TextMeshProUGUI>(); ((Component)val).gameObject.SetActive(true); ((Graphic)val3).raycastTarget = false; } ((TMP_Text)val3).text = "★"; } else if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } } } private const string pluginGUID = "com.grizzyggs.FavoriteItems"; private const string pluginName = "Favorite Items"; private const string pluginVersion = "0.1.1"; private readonly Harmony HarmonyInstance = new Harmony("com.grizzyggs.FavoriteItems"); public static ManualLogSource logger = Logger.CreateLogSource("Favorite Items"); public static bool IsQuickStacking = false; public static string FavoriteKey = "favoriteItems_favorite"; public static ItemData CurrentHoveredItem = null; private ConfigEntry<bool> modEnabled; private static ConfigEntry<KeyCode> favoriteKey; public void Awake() { modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the Favorite Items mod."); favoriteKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "FavoriteHotkey", (KeyCode)308, "Hotkey to toggle favorite status on hovered item."); if (!modEnabled.Value) { logger.LogInfo((object)"Favorite Items mod is disabled in config. Exiting."); return; } logger.LogInfo((object)"Loaded Favorite Items with config file"); Assembly executingAssembly = Assembly.GetExecutingAssembly(); HarmonyInstance.PatchAll(executingAssembly); } private void FixedUpdate() { getHoveredItem(); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown(favoriteKey.Value) && CurrentHoveredItem != null) { logger.LogDebug((object)$"Attempting to toggle favorite status on item: {CurrentHoveredItem}"); if (CurrentHoveredItem.m_customData.ContainsKey(FavoriteKey)) { CurrentHoveredItem.m_customData.Remove(FavoriteKey); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Unfavorited: " + CurrentHoveredItem.m_shared.m_name)); } else { CurrentHoveredItem.m_customData[FavoriteKey] = "true"; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Favorited: " + CurrentHoveredItem.m_shared.m_name)); } } } private void getHoveredItem() { if ((Object)(object)InventoryGui.instance == (Object)null) { logger.LogDebug((object)"inventory is null"); return; } InventoryGrid playerGrid = InventoryGui.instance.m_playerGrid; if ((Object)(object)playerGrid == (Object)null) { logger.LogDebug((object)"playergrid is null"); return; } Element hoveredElement = playerGrid.GetHoveredElement(); if (hoveredElement != null && playerGrid.m_inventory != null) { ItemData val = (CurrentHoveredItem = playerGrid.m_inventory.GetItemAt(hoveredElement.m_pos.x, hoveredElement.m_pos.y)); if (val != null) { logger.LogDebug((object)("hoveredelement item: " + val.m_shared.m_name)); } else { logger.LogDebug((object)"hoveredelement has no item"); } } else { logger.LogDebug((object)"hoveredelement is null"); } } [Conditional("DEBUG")] private static void AddDebugOverlay(Transform parent, Color color) { //IL_0019: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0052: 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) if (!((Object)(object)parent.Find("DebugBorder") != (Object)null)) { GameObject val = new GameObject("DebugBorder"); val.transform.SetParent(parent, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = Vector2.zero; obj.anchorMax = Vector2.one; obj.sizeDelta = Vector2.zero; obj.anchoredPosition = Vector2.zero; Image obj2 = val.AddComponent<Image>(); ((Graphic)obj2).color = color; ((Graphic)obj2).raycastTarget = false; } } } }