using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Lightbug.CharacterControllerPro.Implementation; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HandsReequip")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0ed5a62a044756c91e4267a9f5cc0f6ffb654d07")] [assembly: AssemblyProduct("HandsReequip")] [assembly: AssemblyTitle("HandsReequip")] [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 HandsReequip { [BepInPlugin("com.ttr.handsreequip", "HandsReequip", "1.0.0")] public class HandsReequipPlugin : BaseUnityPlugin { public const string PluginGuid = "com.ttr.handsreequip"; public const string PluginName = "HandsReequip"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.CreateAndPatchAll(typeof(Patches), "com.ttr.handsreequip"); Log.LogInfo((object)"HandsReequip v1.0.0 loaded."); } } internal static class Patches { private static int _savedSlot = -1; private static bool _wasPushing; [HarmonyPatch(typeof(NormalMovement), "HandleEquipping")] [HarmonyPrefix] internal static void HandleEquippingPrefix(NormalMovement __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) try { bool value = ((CharacterState)__instance).CharacterActions.push.value; if (value && !_wasPushing) { object? obj = AccessTools.Field(typeof(NormalMovement), "equipmentController")?.GetValue(__instance); EquipmentController val = (EquipmentController)((obj is EquipmentController) ? obj : null); object? obj2 = AccessTools.Field(typeof(NormalMovement), "player")?.GetValue(__instance); PlayerNetworking val2 = (PlayerNetworking)((obj2 is PlayerNetworking) ? obj2 : null); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { _savedSlot = val.ActiveSelectedItemSlot; HandsReequipPlugin.Log.LogDebug((object)$"Push started: saved slot {_savedSlot}"); } } else if (!value && _wasPushing && _savedSlot != -1) { object? obj3 = AccessTools.Field(typeof(NormalMovement), "equipmentController")?.GetValue(__instance); EquipmentController val3 = (EquipmentController)((obj3 is EquipmentController) ? obj3 : null); object? obj4 = AccessTools.Field(typeof(NormalMovement), "player")?.GetValue(__instance); PlayerNetworking val4 = (PlayerNetworking)((obj4 is PlayerNetworking) ? obj4 : null); if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { InventoryItem itemInSlot = ((InventoryBase)val4.Inventory).GetItemInSlot(_savedSlot + 2); if (((InventoryItem)(ref itemInSlot)).IsValidItem) { val3.SetActiveHandSlot(_savedSlot); HandsReequipPlugin.Log.LogDebug((object)$"Push released: restored slot {_savedSlot}"); } else { HandsReequipPlugin.Log.LogDebug((object)$"Push released: slot {_savedSlot} no longer has an item"); } } _savedSlot = -1; } _wasPushing = value; } catch (Exception arg) { HandsReequipPlugin.Log.LogWarning((object)$"HandleEquipping prefix error: {arg}"); } } } }