using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("BellaModsGames")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BackpackMod")]
[assembly: AssemblyTitle("BackpackMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 BackpackModNamespace
{
[BepInPlugin("com.BellaModsGames.backpack", "Backpack", "1.0.4")]
public class BackpackMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(PlayerController))]
internal static class PlayerControllerPatches
{
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static void Update_Prefix(PlayerController __instance)
{
//IL_003b: 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)
if (storeKey != null && dropKey != null && maxItems != null && !((Object)(object)__instance == (Object)null) && Object.op_Implicit((Object)(object)__instance.playerAvatarScript))
{
if (Input.GetKeyDown(storeKey.Value) && (Object)(object)__instance.playerAvatarScript != (Object)null && (Object)(object)__instance.playerAvatarScript.physGrabber != (Object)null && (Object)(object)__instance.playerAvatarScript.physGrabber.grabbedPhysGrabObject != (Object)null)
{
StoreCurrentItem(__instance);
}
if (Input.GetKeyDown(dropKey.Value))
{
DropLastItem(__instance);
}
}
}
private static void StoreCurrentItem(PlayerController playerController)
{
if ((Object)(object)playerController?.playerAvatarScript?.physGrabber?.grabbedPhysGrabObject == (Object)null)
{
return;
}
PhysGrabObject grabbedPhysGrabObject = playerController.playerAvatarScript.physGrabber.grabbedPhysGrabObject;
if (storedItems.Count >= maxItems.Value)
{
ManualLogSource? staticLogger = StaticLogger;
if (staticLogger != null)
{
staticLogger.LogInfo((object)$"Backpack is full! Cannot store {((Object)grabbedPhysGrabObject).name}. ({storedItems.Count}/{maxItems.Value} items)");
}
return;
}
storedItems.Insert(0, grabbedPhysGrabObject);
((Component)grabbedPhysGrabObject).gameObject.SetActive(false);
playerController.playerAvatarScript.physGrabber.ReleaseObject(0.1f);
ManualLogSource? staticLogger2 = StaticLogger;
if (staticLogger2 != null)
{
staticLogger2.LogInfo((object)$"Stored item: {((Object)grabbedPhysGrabObject).name}. ({storedItems.Count}/{maxItems.Value} items in backpack)");
}
}
private static void DropLastItem(PlayerController playerController)
{
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
if (storedItems.Count == 0)
{
ManualLogSource? staticLogger = StaticLogger;
if (staticLogger != null)
{
staticLogger.LogInfo((object)"Drop key pressed, but the backpack is empty!");
}
return;
}
PhysGrabObject val = storedItems[0];
if ((Object)(object)val == (Object)null)
{
ManualLogSource? staticLogger2 = StaticLogger;
if (staticLogger2 != null)
{
staticLogger2.LogWarning((object)"Attempted to drop an item that no longer exists (was null). Removing from backpack.");
}
storedItems.RemoveAt(0);
return;
}
PlayerAvatar playerAvatarScript = playerController.playerAvatarScript;
object obj;
if (playerAvatarScript == null)
{
obj = null;
}
else
{
Transform localCameraTransform = playerAvatarScript.localCameraTransform;
obj = ((localCameraTransform != null) ? ((Component)localCameraTransform).GetComponent<Camera>() : null);
}
if (obj == null)
{
obj = Camera.main;
}
Camera val2 = (Camera)obj;
if ((Object)(object)val2 == (Object)null)
{
ManualLogSource? staticLogger3 = StaticLogger;
if (staticLogger3 != null)
{
staticLogger3.LogError((object)"Cannot drop item: Main camera not found!");
}
return;
}
Transform transform = ((Component)playerController).transform;
Vector3 val3 = transform.position + transform.forward * 1.2f + Vector3.up * 0.75f;
Vector3 val4 = val3;
float num = 5f;
LayerMask val5 = LayerMask.op_Implicit(~LayerMask.GetMask(new string[3] { "Player", "Ignore Raycast", "Trigger" }));
Vector3 val6 = val3 + Vector3.up * 0.2f;
ManualLogSource? staticLogger4 = StaticLogger;
if (staticLogger4 != null)
{
staticLogger4.LogInfo((object)$"Attempting raycast from: {val6}");
}
RaycastHit val7 = default(RaycastHit);
if (Physics.Raycast(val6, Vector3.down, ref val7, num, LayerMask.op_Implicit(val5), (QueryTriggerInteraction)1))
{
val4 = ((RaycastHit)(ref val7)).point + Vector3.up * 0.15f;
ManualLogSource? staticLogger5 = StaticLogger;
if (staticLogger5 != null)
{
staticLogger5.LogInfo((object)$"Surface detected at {((RaycastHit)(ref val7)).point}. Dropping item at calculated position: {val4} (Collider hit: {((Object)((RaycastHit)(ref val7)).collider).name})");
}
}
else
{
val4 = val3;
ManualLogSource? staticLogger6 = StaticLogger;
if (staticLogger6 != null)
{
staticLogger6.LogInfo((object)$"No surface detected below drop point. Dropping at default position: {val4}");
}
}
storedItems.RemoveAt(0);
((Component)val).transform.position = val4;
((Component)val).transform.rotation = Quaternion.LookRotation(transform.forward, Vector3.up);
((Component)val).gameObject.SetActive(true);
Rigidbody val8 = default(Rigidbody);
if (((Component)val).TryGetComponent<Rigidbody>(ref val8))
{
val8.velocity = Vector3.zero;
val8.angularVelocity = Vector3.zero;
}
ManualLogSource? staticLogger7 = StaticLogger;
if (staticLogger7 != null)
{
staticLogger7.LogInfo((object)$"Dropped item: {((Object)val).name}. ({storedItems.Count}/{maxItems.Value} items remaining)");
}
}
}
public static ConfigEntry<KeyCode>? storeKey;
public static ConfigEntry<KeyCode>? dropKey;
public static ConfigEntry<int>? maxItems;
private ManualLogSource? modLogger;
private static List<PhysGrabObject> storedItems = new List<PhysGrabObject>();
public static ManualLogSource? StaticLogger { get; private set; }
public static BackpackMod? Instance { get; private set; }
private void Awake()
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
Instance = this;
modLogger = Logger.CreateLogSource("Backpack");
StaticLogger = modLogger;
storeKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Store Key", (KeyCode)102, "Keybind used to store the currently grabbed item into the backpack.");
dropKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Drop Key", (KeyCode)122, "Keybind used to drop the most recently stored item from the backpack.");
maxItems = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Max Items", 30, "Maximum number of items that can be stored in the backpack.");
try
{
Harmony val = new Harmony("com.BellaModsGames.backpack");
val.PatchAll();
modLogger.LogInfo((object)"Backpack patches applied successfully!");
}
catch (Exception arg)
{
modLogger.LogError((object)$"Failed to apply Backpack patches: {arg}");
}
modLogger.LogInfo((object)"Backpack mod initialized!");
modLogger.LogWarning((object)"Note: Backpack storage is CLIENT-SIDE only and items will be invisible to others when stored.");
}
}
}