using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using LevelGeneration; using Microsoft.CodeAnalysis; using Player; using SNetwork; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("BigPickupCarryOnBack")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BigPickupCarryOnBack")] [assembly: AssemblyTitle("BigPickupCarryOnBack")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace BigPickupCarryOnBack_Patches { internal static class BigPickupUtil { internal static readonly HashSet TargetIds = new HashSet { 1001u, 1002u, 1004u }; internal static bool IsTargetCarried(out BackpackItem carryItem) { carryItem = null; return PlayerBackpackManager.TryGetItem(SNet.LocalPlayer, (InventorySlot)8, ref carryItem) && carryItem != null && TargetIds.Contains(carryItem.ItemID); } internal static bool IsTargetCarried() { BackpackItem carryItem; return IsTargetCarried(out carryItem); } } [HarmonyPatch(typeof(LG_PickupItem))] internal class SetupBigPickupItemWithItemId { [HarmonyPatch("SetupBigPickupItemWithItemId")] [HarmonyPostfix] private static void LG_PickupItem__SetupBigPickupItemWithItemId__Postfix(LG_PickupItem __instance, uint itemId) { if (itemId == 1002) { CarryItemPickup_Core componentInChildren = ((Component)__instance.m_root).GetComponentInChildren(); Interact_Pickup_PickupItem val = ((Il2CppObjectBase)componentInChildren.m_interact).Cast(); ((Interact_Timed)val).InteractDuration = 1.5f; } } } [HarmonyPatch(typeof(FirstPersonItemHolder))] internal class Patch_FirstPersonItemHolder { [HarmonyPatch("ItemCanMoveQuick")] [HarmonyPrefix] private static bool FirstPersonItemHolder__ItemCanMoveQuick__Prefix(ref bool __result) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if (PlayerBackpackManager.LocalBackpack.HasBackpackItem((InventorySlot)8) && (int)PlayerManager.GetLocalPlayerAgent().Inventory.WieldedSlot != 8) { __result = false; return false; } return true; } } [HarmonyPatch(typeof(PlayerBackpackManager))] internal class Patch_PlayerBackpackManager { [HarmonyPatch("HasItem_Local")] [HarmonyPrefix] private static bool PlayerBackpackManager__HasItem_Local__Prefix(InventorySlot slot, ref bool __result) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 if ((int)slot != 8) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(PlayerInventoryLocal))] internal class Patch_PlayerInventoryLocal { private static void ForceWieldSlot(PlayerInventoryLocal inv, InventorySlot slot) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) ((PlayerInventoryBase)inv).Owner.Sync.WantsToWieldSlot(slot, false); pInventoryStatus syncedInventoryStatus = ((PlayerInventoryBase)inv).Owner.Sync.m_syncedInventoryStatus; syncedInventoryStatus.wieldedSlot = slot; ((PlayerInventoryBase)inv).Owner.Sync.m_syncedInventoryStatus = syncedInventoryStatus; ((PlayerInventoryBase)inv).Owner.Sync.LastWantedSlot = syncedInventoryStatus.wieldedSlot; ((PlayerInventoryBase)inv).Owner.Sync.m_inventoryStatusPacket.Send(syncedInventoryStatus, (SNet_ChannelType)4); ((PlayerInventoryBase)inv).Owner.Sync.DoInventoryWield(syncedInventoryStatus); } [HarmonyPatch("Awake")] [HarmonyPostfix] private static void PlayerInventoryLocal__Awake__Postfix(PlayerInventoryLocal __instance) { if (!__instance.m_allowedScrollSlots.Contains((InventorySlot)8)) { __instance.m_allowedScrollSlots.Add((InventorySlot)8); } } [HarmonyPatch("CheckInput")] [HarmonyPrefix] private static bool PlayerInventoryLocal__CheckInput__Prefix(PlayerInventoryLocal __instance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Invalid comparison between Unknown and I4 //IL_0155: 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_017f: Invalid comparison between Unknown and I4 //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) if ((int)((PlayerInventoryBase)__instance).WieldedSlot != 8) { return true; } if (!BigPickupUtil.IsTargetCarried()) { return true; } if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)32, (eFocusState)0)) { ((PlayerInventoryBase)__instance).Owner.Sync.WantsToSetFlashlightEnabled(!((PlayerInventoryBase)__instance).WantsFlashlightEnabled, false); } if (((PlayerInventoryBase)__instance).Owner.FPItemHolder.ItemHiddenTrigger) { return false; } InventorySlot? val = null; if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)23, (eFocusState)0)) { val = (InventorySlot)1; } else if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)24, (eFocusState)0)) { val = (InventorySlot)2; } else if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)25, (eFocusState)0)) { val = (InventorySlot)3; } else if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)27, (eFocusState)0)) { val = (InventorySlot)4; } else if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)28, (eFocusState)0)) { val = (InventorySlot)5; } else if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)26, (eFocusState)0)) { val = (InventorySlot)10; } else if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)29, (eFocusState)0)) { val = (InventorySlot)11; } if (val.HasValue && val.Value != ((PlayerInventoryBase)__instance).WieldedSlot) { BackpackItem val2 = default(BackpackItem); if (!PlayerBackpackManager.TryGetItem(SNet.LocalPlayer, val.Value, ref val2) || val2 == null) { return false; } bool flag = (int)((PlayerInventoryBase)__instance).WieldedSlot == 8 && BigPickupUtil.IsTargetCarried(); _ = val2.Status; if (!flag) { return false; } ItemEquippable val3 = ((Il2CppObjectBase)val2.Instance).TryCast(); if ((Object)(object)val3 != (Object)null && val3.CanWield) { ForceWieldSlot(__instance, val.Value); __instance.m_itemScrollTimer = Clock.Time + 0.1f; } } if ((int)FocusStateManager.CurrentState != 6 && !__instance.CheckWieldingKeys() && (Object)(object)((PlayerInventoryBase)__instance).m_wieldedItem != (Object)null) { float axisKeyMouse = InputMapper.GetAxisKeyMouse((InputAction)30, (eFocusState)0); bool buttonDownKeyMouseGamepad = InputMapper.GetButtonDownKeyMouseGamepad((InputAction)31, (eFocusState)0); if ((((PlayerInventoryBase)__instance).AllowScrollInput && ((PlayerInventoryBase)__instance).m_wieldedItem.WeaponSwitchAllowed && Mathf.Abs(axisKeyMouse) > 0f && Clock.Time > __instance.m_itemScrollTimer) || buttonDownKeyMouseGamepad) { int num = ((axisKeyMouse > 0f) ? __instance.GetNextSlot(((PlayerInventoryBase)__instance).WieldedSlot, -1) : __instance.GetNextSlot(((PlayerInventoryBase)__instance).WieldedSlot, 1)); if (num > -1) { ForceWieldSlot(__instance, (InventorySlot)(byte)num); __instance.m_itemScrollTimer = Clock.Time + 0.1f; } } } if (__instance.m_FPItemHolder.ItemIsBusy) { return false; } if (InputMapper.GetButtonDownKeyMouseGamepad((InputAction)11, (eFocusState)0) && ((PlayerInventoryBase)__instance).CanReloadCurrent()) { ((PlayerInventoryBase)__instance).TriggerReload(); } return false; } [HarmonyPatch("CheckInput")] [HarmonyPostfix] private static void CheckInput_Postfix(PlayerInventoryLocal __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if (!((PlayerInventoryBase)__instance).Owner.FPItemHolder.ItemHiddenTrigger && (int)FocusStateManager.CurrentState != 6 && (int)((PlayerInventoryBase)__instance).WieldedSlot != 8 && BigPickupUtil.IsTargetCarried() && (Input.GetKeyDown((KeyCode)56) || Input.GetKeyDown((KeyCode)264)) && Clock.Time > __instance.m_itemScrollTimer) { ForceWieldSlot(__instance, (InventorySlot)8); __instance.m_itemScrollTimer = Clock.Time + 0.1f; } } } [HarmonyPatch(typeof(PLOC_Base))] internal class Patch_PLOC_State { [HarmonyPatch("GetHorizontalVelocityFromInput")] [HarmonyPostfix] [HarmonyPriority(0)] private static void PLOC_Base__GetHorizontalVelocityFromInput__Postfix(PLOC_Base __instance, ref Vector3 __result) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (__instance.m_owner.Owner.IsLocal && BigPickupUtil.IsTargetCarried() && (int)__instance.m_owner.Inventory.WieldedSlot != 8) { __result *= 0.7f; } } } } namespace BigPickupCarryOnBack { [BepInPlugin("BigPickupCarryOnBack", "BigPickupCarryOnBack", "1.0.0")] internal class EntryPoint : BasePlugin { public static EntryPoint Instance; private Harmony m_Harmony; public override void Load() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Instance = this; m_Harmony = new Harmony("BigPickupCarryOnBack"); m_Harmony.PatchAll(); } } }