using System;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("industries._5505.tesinormed.OpenBackpack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+cd370e0f39a704cbaf44df518d86c287ae25b43f")]
[assembly: AssemblyProduct("industries._5505.tesinormed.OpenBackpack")]
[assembly: AssemblyTitle("OpenBackpack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace industries._5505.tesinormed.OpenBackpack
{
[BepInPlugin("industries._5505.tesinormed.OpenBackpack", "OpenBackpack", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private static Harmony _harmony;
internal static bool IsModifiedBackpackWheel;
public const string Id = "industries._5505.tesinormed.OpenBackpack";
public static string Name => "OpenBackpack";
public static string Version => "1.0.2";
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "industries._5505.tesinormed.OpenBackpack");
}
private void OnDestroy()
{
_harmony.UnpatchSelf();
IsModifiedBackpackWheel = false;
}
}
}
namespace industries._5505.tesinormed.OpenBackpack.Patches
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public class BackpackWheelSlice_canInteract_Patch
{
public static void Prefix(BackpackWheelSlice __instance, ref bool __runOriginal, ref bool __result)
{
if (Plugin.IsModifiedBackpackWheel)
{
__runOriginal = false;
__result = __instance.hasItem;
}
}
}
[HarmonyPatch(typeof(BackpackWheel), "Choose")]
public class BackpackWheel_Choose_Patch
{
public static void Prefix(ref bool __runOriginal)
{
if (Plugin.IsModifiedBackpackWheel)
{
__runOriginal = false;
}
}
}
[HarmonyPatch(typeof(BackpackWheel), "InitWheel")]
public class BackpackWheel_InitWheel_Patch
{
public static void Postfix(ref BackpackWheel __instance)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
if (!Plugin.IsModifiedBackpackWheel)
{
return;
}
BackpackWheelSlice[] slices = __instance.slices;
foreach (BackpackWheelSlice backpackWheelSlice in slices)
{
((UnityEvent)((UIWheelSlice)backpackWheelSlice).button.onClick).AddListener((UnityAction)delegate
{
Plugin.Logger.LogInfo((object)"picking up item from backpack");
Item val = default(Item);
if (((BackpackReference)(ref backpackWheelSlice.backpack)).GetVisuals().TryGetSpawnedItem(backpackWheelSlice.backpackSlot, ref val))
{
val.Interact(Character.localCharacter);
}
Plugin.Logger.LogInfo((object)"closing modified backpack wheel");
GUIManager.instance.CloseBackpackWheel();
});
}
((Component)__instance.slices[0]).gameObject.SetActive(false);
((Behaviour)__instance.currentlyHeldItem).enabled = false;
}
}
[HarmonyPatch(typeof(BackpackWheel), "Update")]
public class BackpackWheel_Update_Patch
{
public static void Prefix(ref bool __runOriginal)
{
if (Plugin.IsModifiedBackpackWheel)
{
__runOriginal = false;
}
}
}
[HarmonyPatch(typeof(GUIManager), "CloseBackpackWheel")]
public class GUIManager_CloseBackpackWheel_Patch
{
public static void Postfix(GUIManager __instance)
{
if (Plugin.IsModifiedBackpackWheel)
{
Plugin.IsModifiedBackpackWheel = false;
BackpackWheelSlice[] slices = __instance.backpackWheel.slices;
foreach (BackpackWheelSlice val in slices)
{
((UnityEventBase)((UIWheelSlice)val).button.onClick).RemoveAllListeners();
}
}
}
}
[HarmonyPatch(typeof(GUIManager), "UpdatePaused")]
public class GUIManager_UpdatePaused_Patch
{
public static void Prefix(GUIManager __instance, ref bool __runOriginal)
{
if (Plugin.IsModifiedBackpackWheel && Character.localCharacter.input.pauseWasPressed)
{
Plugin.Logger.LogInfo((object)"closing modified backpack wheel");
__runOriginal = false;
Character.localCharacter.input.pauseWasPressed = false;
__instance.CloseBackpackWheel();
}
}
}
[HarmonyPatch(typeof(Item), "Awake")]
public class Item_Awake_Patch
{
public static void Postfix(ref Item __instance)
{
if (__instance is Backpack)
{
__instance.UIData.mainInteractPrompt = "OPEN";
__instance.UIData.hasMainInteract = true;
Item item = __instance;
Item obj = __instance;
obj.OnPrimaryStarted = (Action)Delegate.Combine(obj.OnPrimaryStarted, (Action)delegate
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
Plugin.Logger.LogInfo((object)"opening modified backpack wheel");
Plugin.IsModifiedBackpackWheel = true;
GUIManager.instance.OpenBackpackWheel(BackpackReference.GetFromBackpackItem(item));
});
}
}
}
[HarmonyPatch(typeof(Item), "CanUsePrimary")]
public class Item_CanUsePrimary_Patch
{
public static void Prefix(Item __instance, ref bool __runOriginal, ref bool __result)
{
if (__instance is Backpack)
{
__runOriginal = false;
__result = true;
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}