using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using LethalHands; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("LethalHandsV81Fix")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LethalHandsV81Fix")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d2a07bd8-3667-4e57-b542-fdda65b0f4aa")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace Taylor.LethalHandsV81Fix; [BepInPlugin("Taylor.LethalHandsV81Fix", "LethalHands V81 Fix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGUID = "Taylor.LethalHandsV81Fix"; public const string PluginName = "LethalHands V81 Fix"; public const string PluginVersion = "1.0.0"; private Harmony _harmony; internal static ManualLogSource Log; private void Awake() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"======================================"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalHands V81 Fix loading..."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"======================================"); try { _harmony = new Harmony("Taylor.LethalHandsV81Fix"); ApplySwitchToItemSlotFix(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"LethalHands V81 Fix loaded successfully."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)"Failed to initialize LethalHands V81 Fix!"); ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private void ApplySwitchToItemSlotFix() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown Type type = AccessTools.TypeByName("LethalHands.Patches.PlayerControllerBPatch"); if (type == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find LethalHands.Patches.PlayerControllerBPatch."); return; } MethodInfo methodInfo = AccessTools.Method(type, "PostSwitchToItemSlot", (Type[])null, (Type[])null); if (methodInfo == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find LethalHands PostSwitchToItemSlot patch."); return; } MethodInfo methodInfo2 = AccessTools.Method(typeof(Plugin), "LethalHandsSwitchSafetyPrefix", (Type[])null, (Type[])null); if (methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find compatibility safety prefix."); return; } _harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully patched LethalHands PostSwitchToItemSlot."); } private static bool LethalHandsSwitchSafetyPrefix() { try { if ((Object)(object)LethalHands.Instance == (Object)null) { return false; } if (LethalHands.Instance.allowItems) { return true; } if ((Object)(object)LethalHands.Instance.playerControllerInstance == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)"Prevented LethalHands SwitchToItemSlot null-reference during inventory transition."); } return false; } return true; } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogWarning((object)"Exception while checking LethalHands state. Skipping PostSwitchToItemSlot."); } ManualLogSource log3 = Log; if (log3 != null) { log3.LogDebug((object)ex); } return false; } } private void OnDestroy() { try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } } }