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.ModPanel;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("NGA")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Persistent player progression! Raid, stash loot, and deploy with seemless scene/loadout saving.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("NGA.TriggerGrab")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.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 NGA
{
[BepInPlugin("NGA.TriggerGrab", "TriggerGrab", "0.0.1")]
[BepInDependency("nrgill28.Sodalite", "1.4.1")]
[BepInProcess("h3vr.exe")]
public class TriggerGrab : BaseUnityPlugin
{
[HarmonyPatch(typeof(FVRViveHand))]
[HarmonyPatch("Update")]
public class FVRPlayerHitboxDamage : MonoBehaviour
{
private static bool trigheldPurposely;
private static FVRInteractiveObject interObj;
private static FVRViveHand currHand;
private static void Postfix(FVRViveHand __instance)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: 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)
if (!AllOnOff.Value)
{
return;
}
if ((Object)(object)__instance == (Object)(object)currHand && trigheldPurposely && __instance.Input.TriggerUp)
{
trigheldPurposely = false;
interObj.EndInteraction(__instance);
__instance.CurrentInteractable = null;
currHand = null;
}
if (!__instance.Input.TriggerDown || (int)__instance.m_state != 0 || !((Object)(object)__instance.OtherHand.CurrentInteractable != (Object)null) || !(__instance.OtherHand.CurrentInteractable is FVRFireArm))
{
return;
}
FVRFireArm val = (FVRFireArm)__instance.OtherHand.CurrentInteractable;
for (int i = 0; i < ((Component)val).transform.childCount; i++)
{
Transform child = ((Component)val).transform.GetChild(i);
if ((Object)(object)((Component)child).GetComponent<ClosedBoltHandle>() != (Object)null || (Object)(object)((Component)child).GetComponent<OpenBoltReceiverBolt>() != (Object)null || (Object)(object)((Component)child).GetComponent<OpenBoltChargingHandle>() != (Object)null || (Object)(object)((Component)child).GetComponent<TubeFedShotgunBolt>() != (Object)null || (Object)(object)((Component)child).GetComponent<HandgunSlide>() != (Object)null || (Object)(object)((Component)child).GetComponent<FVRFireArmTopCover>() != (Object)null || (Object)(object)((Component)child).GetComponent<ClosedBolt>() != (Object)null)
{
if (Vector3.Distance(((Component)__instance).gameObject.transform.position, child.position) < DistToGrab.Value)
{
interObj = ((Component)child).GetComponent<FVRInteractiveObject>();
__instance.Buzz(__instance.Buzzer.Buzz_BeginInteraction);
interObj.BeginInteraction(__instance);
__instance.ForceSetInteractable(interObj);
trigheldPurposely = true;
currHand = __instance;
}
continue;
}
Transform val2 = FindNestedChildComponent(child);
if (!((Object)(object)val2 != (Object)null))
{
continue;
}
FVRInteractiveObject component = ((Component)val2).GetComponent<FVRInteractiveObject>();
if (Vector3.Distance(((Component)__instance).gameObject.transform.position, ((Component)component).transform.position) < DistToGrab.Value)
{
interObj = component;
if ((Object)(object)((Component)val2).GetComponent<BoltActionRifle_Handle>() != (Object)null)
{
}
__instance.Buzz(__instance.Buzzer.Buzz_BeginInteraction);
interObj.BeginInteraction(__instance);
__instance.ForceSetInteractable(interObj);
trigheldPurposely = true;
currHand = __instance;
}
}
}
private static Transform FindNestedChildComponent(Transform parentTransform)
{
for (int i = 0; i < parentTransform.childCount; i++)
{
Transform child = parentTransform.GetChild(i);
BoltActionRifle_Handle component = ((Component)child).GetComponent<BoltActionRifle_Handle>();
if ((Object)(object)component != (Object)null)
{
return child;
}
Transform val = FindNestedChildComponent(child);
if ((Object)(object)val != (Object)null)
{
return val;
}
}
return null;
}
}
private static ConfigEntry<bool> AllOnOff;
private static ConfigEntry<float> DistToGrab;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("NGA.TriggerGrab");
Logger.LogMessage((object)"New harmony");
SetUpConfigFields();
Logger.LogMessage((object)"Setted the fields");
val.PatchAll();
Logger.LogMessage((object)"Hello, world! Sent from NGA.TriggerGrab 0.0.1");
}
private void SetUpConfigFields()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
AllOnOff = ((BaseUnityPlugin)this).Config.Bind<bool>("ON/OFF", "Enable Mod", true, "Enable/disable entire mod.");
DistToGrab = ((BaseUnityPlugin)this).Config.Bind<float>("Bolt Grab", "Distance (spherical)", 0.1f, new ConfigDescription("How far for it to trigger in cm", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 1f, 0.01f), new object[0]));
}
}
}