Decompiled source of Far ForeGrip v0.1.1

NGA.FarForeGrip.dll

Decompiled 5 months ago
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 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.FarForeGrip")]
[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.FarForeGrip", "FarForeGrip", "0.1.0")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInProcess("h3vr.exe")]
	public class FarForeGrip : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FVRViveHand))]
		[HarmonyPatch("Update")]
		private class FVRViveHandUpdateHook
		{
			private static void Postfix(FVRViveHand __instance)
			{
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: 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_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.Input.IsGrabDown || !((Object)(object)__instance.CurrentInteractable == (Object)null) || !((Object)(object)__instance.ClosestPossibleInteractable == (Object)null))
				{
					return;
				}
				GameObject gameObject = ((Component)Object.FindObjectOfType<FVRPlayerBody>()).gameObject;
				if ((Object)(object)gameObject == (Object)null)
				{
					Logger.LogMessage((object)"Player null!!!!!!!!!!!!!!!!!!!!");
					return;
				}
				FVRViveHand component = ((Component)gameObject.transform.Find("Controller (left)")).GetComponent<FVRViveHand>();
				FVRViveHand component2 = ((Component)gameObject.transform.Find("Controller (right)")).GetComponent<FVRViveHand>();
				FVRViveHand val = null;
				if ((Object)(object)component == (Object)(object)__instance)
				{
					val = component2;
				}
				if ((Object)(object)component2 == (Object)(object)__instance)
				{
					val = component;
				}
				if (!((Object)(object)val == (Object)null) && (Object)(object)val.CurrentInteractable != (Object)null && val.CurrentInteractable is FVRFireArm && (Object)(object)((FVRFireArm)val.CurrentInteractable).Foregrip.GetComponent<FVRAlternateGrip>() != (Object)null && (Object)(object)((FVRFireArm)val.CurrentInteractable).Foregrip.GetComponent<Collider>() != (Object)null)
				{
					Transform component3 = ((FVRFireArm)val.CurrentInteractable).Foregrip.GetComponent<Transform>();
					float num = Vector3.Distance(((Component)__instance).transform.position, component3.position);
					if (num < config_grab_distance.Value)
					{
						__instance.CurrentInteractable = (FVRInteractiveObject)(object)((FVRFireArm)val.CurrentInteractable).Foregrip.GetComponent<FVRAlternateGrip>();
						__instance.m_state = (HandState)1;
						__instance.CurrentInteractable.BeginInteraction(__instance);
						__instance.Buzz(__instance.Buzzer.Buzz_BeginInteraction);
					}
					else
					{
						Logger.LogMessage((object)"Too far!!");
					}
				}
			}
		}

		private static ConfigEntry<float> config_grab_distance;

		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.FarForeGrip");
			Logger.LogMessage((object)"New harmony");
			SetUpConfigFields();
			Logger.LogMessage((object)"Setted the fields");
			val.PatchAll();
			Logger.LogMessage((object)"Hello, world! Sent from NGA.FarForeGrip 0.0.1");
		}

		private void SetUpConfigFields()
		{
			config_grab_distance = ((BaseUnityPlugin)this).Config.Bind<float>("Far ForeGrip", "Grab Distance from Foregrip Center", 0.15f, "0.15 = 15cm. How far from center of foregrip will far-grip trigger.");
		}
	}
}