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 UniversalGrasp v0.2.0
plugins\UniversalGrasp.dll
Decompiled a year agousing System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using EquipmentAndQuickSlots; using HarmonyLib; using Jotunn; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("JotunnModStub")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("JotunnModStub")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("0.0.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.1.0")] namespace UniversalGrasp { [BepInPlugin("org.bepinex.plugins.bid.universalgrasp", "UniversalGrasp", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class UniversalGrasp : BaseUnityPlugin { public const string PluginGUID = "org.bepinex.plugins.bid.universalgrasp"; public const string PluginName = "UniversalGrasp"; public const string PluginVersion = "0.2.0"; public static ConfigEntry<bool> EnabledConfig; private readonly Harmony harmony = new Harmony("org.bepinex.plugins.bid.universalgrasp"); public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) Logger.LogInfo((object)"UniversalGrasp has landed"); CreateConfigValues(); AddInputs(); new Harmony("org.bepinex.plugins.bid.universalgrasp").PatchAll(); CreatureManager.OnVanillaCreaturesAvailable += ModifyAndCloneVanillaCreatures; } private void OnDestroy() { harmony.UnpatchSelf(); } private void AddInputs() { } private void CreateConfigValues() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; EnabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Client config", "enabled", true, new ConfigDescription("enable or disable the mod", (AcceptableValueBase)null, Array.Empty<object>())); } private void Update() { if (ZInput.instance != null && ZInput.GetButtonDown("Hide") && (Object)(object)Player.m_localPlayer != (Object)null) { bool flag = false; if (((Humanoid)Player.m_localPlayer).m_rightItem == null && ((Humanoid)Player.m_localPlayer).m_visEquipment.m_rightItem != null) { ((Humanoid)Player.m_localPlayer).m_visEquipment.SetRightItem((string)null); flag = true; } if (((Humanoid)Player.m_localPlayer).m_leftItem == null && ((Humanoid)Player.m_localPlayer).m_visEquipment.m_leftItem != null) { ((Humanoid)Player.m_localPlayer).m_visEquipment.SetLeftItem((string)null, -1); flag = true; } if (flag) { ((Character)Player.m_localPlayer).m_zanim.SetTrigger("equip_hip"); } } } private void ModifyAndCloneVanillaCreatures() { CreatureManager.OnVanillaCreaturesAvailable -= ModifyAndCloneVanillaCreatures; } private static GameObject GetTransform(GameObject item, string name) { Transform val = item.transform.Find(name); if (!Object.op_Implicit((Object)(object)val)) { return null; } return ((Component)val).gameObject; } private static bool TwoHandedEquipped(Player player) { return false; } public static void SetRightItem(Player player, ItemData item) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 if (!Utility.IsNullOrWhiteSpace(((Humanoid)player).m_visEquipment.m_rightItem) || TwoHandedEquipped(Player.m_localPlayer)) { ((Humanoid)Player.m_localPlayer).UseItem((Inventory)(object)InventoryExtensions.Extended(((Humanoid)Player.m_localPlayer).m_inventory), item, true); if ((int)item.m_shared.m_itemType == 2 && ((Humanoid)player).m_visEquipment.m_rightItem == ((Object)item.m_dropPrefab).name) { ((Humanoid)player).m_visEquipment.SetRightItem((string)null); } } else { ((Humanoid)player).UnequipItem(((Humanoid)player).m_rightItem, false); ((Humanoid)player).m_visEquipment.SetRightItem(((Object)item.m_dropPrefab).name); ((Character)player).m_zanim.SetTrigger("equip_hip"); } } public static void SetLeftItem(Player player, ItemData item) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 if (!Utility.IsNullOrWhiteSpace(((Humanoid)player).m_visEquipment.m_leftItem) || TwoHandedEquipped(Player.m_localPlayer)) { ((Humanoid)Player.m_localPlayer).UseItem((Inventory)(object)InventoryExtensions.Extended(((Humanoid)Player.m_localPlayer).m_inventory), item, true); if ((int)item.m_shared.m_itemType == 2 && ((Humanoid)player).m_visEquipment.m_leftItem == ((Object)item.m_dropPrefab).name) { ((Humanoid)player).m_visEquipment.SetLeftItem((string)null, -1); } } else { ((Humanoid)player).UnequipItem(((Humanoid)player).m_leftItem, false); ((Humanoid)player).m_visEquipment.SetLeftItem(((Object)item.m_dropPrefab).name, -1); ((Character)player).m_zanim.SetTrigger("equip_hip"); } } public static GameObject GetAttach(GameObject item) { GameObject transform = GetTransform(item, "attach"); if ((Object)(object)transform != (Object)null && transform.GetComponentsInChildren<Renderer>().Count() > 0) { return transform; } transform = GetChildModel(item); if ((Object)(object)transform != (Object)null) { return transform; } return item; } public static GameObject GetAttachObjectLegacy(GameObject item) { Collider componentInChildren = ((Component)item.transform).GetComponentInChildren<Collider>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return null; } return ((Component)((Component)componentInChildren).transform).gameObject; } public static GameObject GetChildModel(GameObject item) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown GameObject val = null; foreach (Transform item2 in item.transform) { Transform val2 = item2; if (((Component)val2).gameObject.layer == item.layer) { if (Object.op_Implicit((Object)(object)val)) { return null; } val = ((Component)val2).gameObject; } } if (Object.op_Implicit((Object)(object)val)) { return val; } foreach (Transform item3 in item.transform) { Transform val3 = item3; if (Object.op_Implicit((Object)(object)val)) { return null; } val = ((Component)val3).gameObject; } return val; } public static void CleanUpGameObject(GameObject item, bool removeall = true) { if (removeall) { Rigidbody[] componentsInChildren = item.GetComponentsInChildren<Rigidbody>(); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } MonoBehaviour[] componentsInChildren2 = item.GetComponentsInChildren<MonoBehaviour>(); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } } VisEquipment.CleanupInstance(item); } } } namespace UniversalGrasp.patches { [HarmonyPatch(typeof(Player), "Update")] public class Humanoid_HideHandItems_Patch { } [HarmonyPatch(typeof(InventoryGui_Awake_Patch), "OnRightClicked", new Type[] { typeof(InventoryGui) })] public class InventoryGui_OnRightClick_Patch { private static bool Prefix(InventoryGui inventoryGui, ref Action<InventoryGrid, ItemData, Vector2i> __result) { if (!UniversalGrasp.EnabledConfig.Value) { return true; } __result = delegate(InventoryGrid inventoryGrid, ItemData item, Vector2i pos) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if (((Object)inventoryGrid).name == "QuickSlotGrid") { switch (pos.x) { case 0: UniversalGrasp.SetRightItem(Player.m_localPlayer, item); flag = true; break; case 1: UniversalGrasp.SetLeftItem(Player.m_localPlayer, item); flag = true; break; } } if (!flag && item != null && !((Object)(object)Player.m_localPlayer == (Object)null)) { ((Humanoid)Player.m_localPlayer).UseItem((Inventory)(object)InventoryExtensions.Extended(((Humanoid)Player.m_localPlayer).m_inventory), item, true); } }; return false; } } [HarmonyPatch(typeof(HotkeyBar_UpdateIcons_Patch), "UpdateIconBinding", new Type[] { typeof(HotkeyBar), typeof(int), typeof(ElementData) })] public class CustomHotkeyBar_UpdateIconBinding_patch { private static void Postfix(HotkeyBar instance, int index, ElementData elementData) { if (UniversalGrasp.EnabledConfig.Value && !(((Object)instance).name != "QuickSlotsHotkeyBar")) { TMP_Text component = ((Component)elementData.m_go.transform.Find("binding")).GetComponent<TMP_Text>(); component.alignment = (TextAlignmentOptions)4097; component.fontSize = 12f; } } } [HarmonyPatch(typeof(InventoryGrid), "UpdateGui", new Type[] { typeof(Player), typeof(ItemData) })] public class InventoryGrid_UpdateGui_Patch { private static void Postfix(InventoryGrid __instance) { if (UniversalGrasp.EnabledConfig.Value && !(((Object)__instance).name != "QuickSlotGrid")) { for (int i = 0; i < 2; i++) { TMP_Text component = ((Component)__instance.m_elements[i].m_go.transform.Find("binding")).GetComponent<TMP_Text>(); component.alignment = (TextAlignmentOptions)4097; component.fontSize = 12f; } } } } [HarmonyPatch(typeof(EquipmentAndQuickSlots), "GetBindingLabel", new Type[] { typeof(int) })] public class EquipmentAndQuickSlots_GetBindingLabel_patch { private static void Postfix(int index, ref string __result) { if (UniversalGrasp.EnabledConfig.Value) { index = Mathf.Clamp(index, 0, 2); switch (index) { case 0: __result += " (RH)"; break; case 1: __result += " (LH)"; break; } } } } [HarmonyPatch(typeof(InventoryGrid), "DropItem", new Type[] { typeof(Inventory), typeof(ItemData), typeof(int), typeof(Vector2i) })] public class InventoryGrid_DropItem_patch { } [HarmonyPatch(typeof(EquipmentAndQuickSlots), "CheckQuickUseInput", new Type[] { typeof(Player), typeof(int) })] internal class EquipmentAndQuickSlots_CheckQuickUseInput_patch { private static bool Prefix(Player player, int index, EquipmentAndQuickSlots __instance) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!UniversalGrasp.EnabledConfig.Value) { return true; } if (ZInput.GetKeyDown(EquipmentAndQuickSlots.GetBindingKeycode(index), true)) { ItemData quickSlotItem = PlayerExtensions.GetQuickSlotItem(player, index); if (quickSlotItem != null) { switch (index) { case 0: UniversalGrasp.SetRightItem(player, quickSlotItem); break; case 1: UniversalGrasp.SetLeftItem(player, quickSlotItem); break; default: ((Humanoid)player).UseItem((Inventory)null, quickSlotItem, false); break; } return false; } } return true; } } }