using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FistVR; using HarmonyLib; using Microsoft.CodeAnalysis; using Sodalite.Api; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("Niko666")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Allows player to recycle (sell) attachments and magazines in Take and Hold.")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("Niko666.TNHRecycleAttachmentsAndMagazines")] [assembly: AssemblyTitle("TNHRecycleAttachmentsAndMagazines")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [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 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 Niko666 { [BepInProcess("h3vr.exe")] [BepInPlugin("Niko666.TNHRecycleAttachmentsAndMagazines", "TNHRecycleAttachmentsAndMagazines", "1.0.1")] public class TNHRecycleAttachmentsAndMagazines : BaseUnityPlugin { public enum RecyclingMagMode { Disabled, Enabled, EnabledWhenNoSpawnlocking } public ConfigEntry configAllowRecyclingAttachments; public ConfigEntry configAllowRecyclingMagazines; public const string Id = "Niko666.TNHRecycleAttachmentsAndMagazines"; public static TNHRecycleAttachmentsAndMagazines Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } public static string Name => "TNHRecycleAttachmentsAndMagazines"; public static string Version => "1.0.1"; public void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; configAllowRecyclingAttachments = ((BaseUnityPlugin)this).Config.Bind("General", "AllowRecyclingAttachments", true, "Allows players to recycle attachments."); configAllowRecyclingMagazines = ((BaseUnityPlugin)this).Config.Bind("General", "AllowRecyclingMagazines", RecyclingMagMode.EnabledWhenNoSpawnlocking, "Allows players to recycle magazines."); LeaderboardAPI.LeaderboardDisabled.TakeLock(); Harmony.CreateAndPatchAll(typeof(TNHRecycleAttachmentsAndMagazinesPatch), (string)null); Logger.LogMessage((object)("H3VR2 Release when? Sent from Niko666.TNHRecycleAttachmentsAndMagazines " + Version)); } } public static class TNHRecycleAttachmentsAndMagazinesPatch { [HarmonyPatch(typeof(SteamVR_LoadLevel), "Begin")] [HarmonyPrefix] public static bool BeginPatch() { ((BaseUnityPlugin)TNHRecycleAttachmentsAndMagazines.Instance).Config.Reload(); return true; } [HarmonyPatch(typeof(TNH_GunRecycler), "Scan")] [HarmonyPostfix] public static void RecycleAttachmentsAndMagazinesPatch(TNH_GunRecycler __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance.m_selectedObject == (Object)null)) { return; } int num = Physics.OverlapBoxNonAlloc(__instance.ScanningVolume.position, __instance.ScanningVolume.localScale * 0.5f, __instance.colbuffer, __instance.ScanningVolume.rotation, LayerMask.op_Implicit(__instance.ScanningLM), (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { if (!((Object)(object)__instance.colbuffer[i].attachedRigidbody != (Object)null)) { continue; } if (TNHRecycleAttachmentsAndMagazines.Instance.configAllowRecyclingAttachments.Value) { FVRFireArmAttachment component = ((Component)__instance.colbuffer[i].attachedRigidbody).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && !((FVRPhysicalObject)component).SpawnLockable && !((FVRInteractiveObject)component).IsHeld && (Object)(object)((FVRPhysicalObject)component).QuickbeltSlot == (Object)null) { __instance.m_selectedObject = (FVRPhysicalObject)(object)component; break; } } if ((TNHRecycleAttachmentsAndMagazines.Instance.configAllowRecyclingMagazines.Value == TNHRecycleAttachmentsAndMagazines.RecyclingMagMode.EnabledWhenNoSpawnlocking && !GM.CurrentSceneSettings.IsSpawnLockingEnabled) || TNHRecycleAttachmentsAndMagazines.Instance.configAllowRecyclingMagazines.Value == TNHRecycleAttachmentsAndMagazines.RecyclingMagMode.Enabled) { FVRFireArmMagazine component2 = ((Component)__instance.colbuffer[i].attachedRigidbody).gameObject.GetComponent(); if ((Object)(object)component2 != (Object)null && !component2.IsIntegrated && !((FVRInteractiveObject)component2).IsHeld && (Object)(object)((FVRPhysicalObject)component2).QuickbeltSlot == (Object)null) { __instance.m_selectedObject = (FVRPhysicalObject)(object)component2; break; } } } } } }