Decompiled source of InLevelCarryOnBack v1.0.2

Hikaria.InLevelCarryOnBack.dll

Decompiled 8 months ago
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 Player;
using SNetwork;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Hikaria.InLevelCarryOnBack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Hikaria.InLevelCarryOnBack")]
[assembly: AssemblyTitle("Hikaria.InLevelCarryOnBack")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Hikaria.InLevelCarryOnBack
{
	[BepInPlugin("Hikaria.InLevelCarryOnBack", "InLevelCarryOnBack", "1.0.2")]
	internal class EntryPoint : BasePlugin
	{
		public static EntryPoint Instance;

		private Harmony m_Harmony;

		public override void Load()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Instance = this;
			m_Harmony = new Harmony("Hikaria.InLevelCarryOnBack");
			m_Harmony.PatchAll();
			Logs.LogMessage("OK");
		}
	}
	internal static class Logs
	{
		public static void LogDebug(object data)
		{
			((BasePlugin)EntryPoint.Instance).Log.LogDebug(data);
		}

		public static void LogError(object data)
		{
			((BasePlugin)EntryPoint.Instance).Log.LogError(data);
		}

		public static void LogFatal(object data)
		{
			((BasePlugin)EntryPoint.Instance).Log.LogFatal(data);
		}

		public static void LogInfo(object data)
		{
			((BasePlugin)EntryPoint.Instance).Log.LogInfo(data);
		}

		public static void LogMessage(object data)
		{
			((BasePlugin)EntryPoint.Instance).Log.LogMessage(data);
		}

		public static void LogWarning(object data)
		{
			((BasePlugin)EntryPoint.Instance).Log.LogWarning(data);
		}
	}
	public static class PluginInfo
	{
		public const string GUID = "Hikaria.InLevelCarryOnBack";

		public const string NAME = "InLevelCarryOnBack";

		public const string VERSION = "1.0.2";
	}
}
namespace Hikaria.InLevelCarryOnBack.Patches
{
	[HarmonyPatch]
	internal class Patch_FirstPersonItemHolder
	{
		[HarmonyPatch(typeof(FirstPersonItemHolder), "ItemCanMoveQuick")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		private static bool FirstPersonItemHolder__ItemCanMoveQuick__Prefix(ref bool __result)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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]
	internal class Patch_PlayerBackpackManager
	{
		[HarmonyPatch(typeof(PlayerBackpackManager), "HasItem_Local")]
		[HarmonyPrefix]
		[HarmonyPriority(0)]
		private static bool PlayerBackpackManager__HasItem_Local__Prefix(InventorySlot slot, ref bool __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			if ((int)slot != 8)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch]
	internal class Patch_PlayerInventoryLocal
	{
		[HarmonyPatch(typeof(PlayerInventoryLocal), "CheckInput")]
		[HarmonyPostfix]
		private static void PlayerInventoryLocal__CheckInput__Postfix(PlayerInventoryLocal __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_004c: 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)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			if (((PlayerInventoryBase)__instance).Owner.FPItemHolder.ItemHiddenTrigger || (int)((PlayerInventoryBase)__instance).WieldedSlot != 8 || (int)FocusStateManager.CurrentState == 6 || __instance.CheckWieldingKeys() || !((Object)(object)((PlayerInventoryBase)__instance).m_wieldedItem != (Object)null))
			{
				return;
			}
			float axisKeyMouseGamepad = InputMapper.GetAxisKeyMouseGamepad((InputAction)30, ((PlayerInventoryBase)__instance).Owner.InputFilter);
			if ((Mathf.Abs(axisKeyMouseGamepad) > 0f && Clock.Time > __instance.m_itemScrollTimer) || InputMapper.GetButtonDownKeyMouseGamepad((InputAction)31, ((PlayerInventoryBase)__instance).Owner.InputFilter))
			{
				int num = ((!(axisKeyMouseGamepad > 0f)) ? __instance.GetNextSlot(((PlayerInventoryBase)__instance).WieldedSlot, 1) : __instance.GetNextSlot(((PlayerInventoryBase)__instance).WieldedSlot, -1));
				if (num > -1)
				{
					((PlayerInventoryBase)__instance).Owner.Sync.WantsToWieldSlot((InventorySlot)(byte)num, false);
					pInventoryStatus syncedInventoryStatus = ((PlayerInventoryBase)__instance).Owner.Sync.m_syncedInventoryStatus;
					syncedInventoryStatus.wieldedSlot = (InventorySlot)(byte)num;
					((PlayerInventoryBase)__instance).Owner.Sync.m_syncedInventoryStatus = syncedInventoryStatus;
					((PlayerInventoryBase)__instance).Owner.Sync.LastWantedSlot = syncedInventoryStatus.wieldedSlot;
					((PlayerInventoryBase)__instance).Owner.Sync.m_inventoryStatusPacket.Send(syncedInventoryStatus, (SNet_ChannelType)4);
					((PlayerInventoryBase)__instance).Owner.Sync.DoInventoryWield(syncedInventoryStatus);
					__instance.m_itemScrollTimer = Clock.Time + 0.1f;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerInventoryLocal), "Awake")]
		[HarmonyPostfix]
		private static void PlayerInventoryLocal__Awake__Postfix(PlayerInventoryLocal __instance)
		{
			if (!__instance.m_allowedScrollSlots.Contains((InventorySlot)8))
			{
				__instance.m_allowedScrollSlots.Add((InventorySlot)8);
			}
		}

		[HarmonyPatch(typeof(PlayerInventoryLocal), "CheckAndWield")]
		[HarmonyPostfix]
		private static void PlayerInventoryLocal__CheckAndWield__Postfix(PlayerInventoryLocal __instance, InputAction action, InventorySlot slot, ref bool __result)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0017: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			if (!PlayerBackpackManager.LocalBackpack.HasBackpackItem((InventorySlot)8) || (int)((PlayerInventoryBase)__instance).WieldedSlot != 8)
			{
				return;
			}
			BackpackItem val = default(BackpackItem);
			if (InputMapper.GetButtonDownKeyMouseGamepad(action, ((PlayerInventoryBase)__instance).Owner.InputFilter) && ((PlayerInventoryBase)__instance).WieldedSlot != slot && PlayerBackpackManager.LocalBackpack.HasBackpackItem(slot) && PlayerBackpackManager.TryGetItem(SNet.LocalPlayer, slot, ref val) && (int)val.Status == 0)
			{
				ItemEquippable val2 = ((Il2CppObjectBase)val.Instance).TryCast<ItemEquippable>();
				if ((Object)(object)val2 != (Object)null && val2.CanWield)
				{
					pInventoryStatus syncedInventoryStatus = ((PlayerInventoryBase)__instance).Owner.Sync.m_syncedInventoryStatus;
					syncedInventoryStatus.wieldedSlot = slot;
					((PlayerInventoryBase)__instance).Owner.Sync.m_syncedInventoryStatus = syncedInventoryStatus;
					((PlayerInventoryBase)__instance).Owner.Sync.LastWantedSlot = syncedInventoryStatus.wieldedSlot;
					((PlayerInventoryBase)__instance).Owner.Sync.m_inventoryStatusPacket.Send(syncedInventoryStatus, (SNet_ChannelType)4);
					((PlayerInventoryBase)__instance).Owner.Sync.DoInventoryWield(syncedInventoryStatus);
				}
				__result = true;
			}
			else
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch]
	internal class Patch_PLOC_State
	{
		[HarmonyPatch(typeof(PLOC_Base), "GetHorizontalVelocityFromInput")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void PLOC_Base__GetHorizontalVelocityFromInput__Postfix(PLOC_Base __instance, ref Vector3 __result)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.m_owner.Owner.IsLocal && PlayerBackpackManager.LocalBackpack.HasBackpackItem((InventorySlot)8) && (int)__instance.m_owner.Inventory.WieldedSlot != 8)
			{
				__result *= 0.85f;
			}
		}
	}
}