Decompiled source of GunVarConfigs v0.0.5

NGA.GunVarConfigs.dll

Decompiled 6 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 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.GunVarConfigs")]
[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.GunVarConfigs", "GunVarConfigs", "0.0.1")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInProcess("h3vr.exe")]
	public class GunVarConfigs : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FVRPhysicalObject))]
		[HarmonyPatch("Awake")]
		public class FVRPhysicalObjectAwake : MonoBehaviour
		{
			private static void Postfix(FVRPhysicalObject __instance)
			{
				if (!CheckSkip() && IntensityEnabled.Value)
				{
					__instance.MoveIntensity = MoveInt.Value;
					__instance.RotIntensity = RotInt.Value;
				}
			}
		}

		[HarmonyPatch(typeof(FVRPhysicalObject))]
		[HarmonyPatch("FVRFixedUpdate")]
		public class FVRPhysicalObjectFVRFixedUpdate : MonoBehaviour
		{
			private static float Lsince_last_shake;

			private static float Rsince_last_shake;

			private static Vector3 LpreviousAngularVelocity;

			private static Vector3 RpreviousAngularVelocity;

			private static Vector3 LpreviousVelocity;

			private static Vector3 RpreviousVelocity;

			private static void Postfix(FVRPhysicalObject __instance)
			{
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0170: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_020d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0212: Unknown result type (might be due to invalid IL or missing references)
				//IL_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_0115: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				if (CheckSkip() || !SoundEnabled.Value || !((FVRInteractiveObject)__instance).IsHeld)
				{
					return;
				}
				Rigidbody component = ((Component)__instance).GetComponent<Rigidbody>();
				if ((Object)(object)component == (Object)null || (Object)(object)((FVRInteractiveObject)__instance).m_hand == (Object)null || ((Object)(object)((Component)__instance).GetComponent<FVRFireArm>() == (Object)null && (Object)(object)((Component)__instance).GetComponent<FVRFireArmMagazine>() == (Object)null))
				{
					return;
				}
				if (((FVRInteractiveObject)__instance).m_hand.IsThisTheRightHand)
				{
					Vector3 val = component.angularVelocity - RpreviousAngularVelocity;
					Vector3 val2 = component.velocity - RpreviousVelocity;
					if ((((Vector3)(ref val)).magnitude > SoundAngTrig.Value || ((Vector3)(ref val2)).magnitude > SoundVelTrig.Value) && Rsince_last_shake > SoundSinceLast.Value)
					{
						bool flag = (Object)(object)((Component)__instance).GetComponent<FVRFireArm>() == (Object)null;
						SM.PlayHandlingGrabSound(((FVRInteractiveObject)__instance).HandlingGrabSound, ((Component)__instance).transform.position, flag);
						Rsince_last_shake = 0f;
					}
					Rsince_last_shake += Time.deltaTime;
					RpreviousAngularVelocity = component.angularVelocity;
					RpreviousVelocity = component.velocity;
				}
				else
				{
					Vector3 val3 = component.angularVelocity - LpreviousAngularVelocity;
					Vector3 val4 = component.velocity - LpreviousVelocity;
					if ((((Vector3)(ref val3)).magnitude > SoundAngTrig.Value || ((Vector3)(ref val4)).magnitude > SoundVelTrig.Value) && Lsince_last_shake > SoundSinceLast.Value)
					{
						bool flag2 = (Object)(object)((Component)__instance).GetComponent<FVRFireArm>() == (Object)null;
						SM.PlayHandlingGrabSound(((FVRInteractiveObject)__instance).HandlingGrabSound, ((Component)__instance).transform.position, flag2);
						Lsince_last_shake = 0f;
					}
					Lsince_last_shake += Time.deltaTime;
					LpreviousAngularVelocity = component.angularVelocity;
					LpreviousVelocity = component.velocity;
				}
			}
		}

		private static ConfigEntry<bool> GameEnabled;

		private static ConfigEntry<bool> IntensityEnabled;

		private static ConfigEntry<bool> SoundEnabled;

		private static ConfigEntry<float> MoveInt;

		private static ConfigEntry<float> RotInt;

		private static ConfigEntry<float> SoundAngTrig;

		private static ConfigEntry<float> SoundVelTrig;

		private static ConfigEntry<float> SoundSinceLast;

		public static Camera eyeCam;

		public static Camera foundCamera;

		public static GameObject ThirdPersonRoot;

		public static GameObject ThirdPersonOffset;

		public static GameObject foundCameraObj;

		public static float rightLeft = 1f;

		public static bool isThirdPersonRn = false;

		public static bool addedNewCam = false;

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

		private void SetUpConfigFields()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			GameEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Overall", "ON/OFF", true, "Completely enable/disable mod");
			IntensityEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Floaty-ness", "ON/OFF", true, "Enable/disable floatiness changes");
			MoveInt = ((BaseUnityPlugin)this).Config.Bind<float>("Floaty-ness", "Move Intesity", 1.35f, new ConfigDescription("Floatiness of objects in translation", (AcceptableValueBase)new AcceptableValueFloatRangeStep(-20f, 20f, 0.05f), new object[0]));
			RotInt = ((BaseUnityPlugin)this).Config.Bind<float>("Floaty-ness", "Rotation Intensity", 1.55f, new ConfigDescription("Floatiness of objects in rotation", (AcceptableValueBase)new AcceptableValueFloatRangeStep(-20f, 20f, 0.05f), new object[0]));
			SoundEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "ON/OFF", true, "enable/disable sound section");
			SoundAngTrig = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "Angular Magnitude of force stop 0.0.1", 8.5f, new ConfigDescription("How hard for sound to trigger from angular movement", (AcceptableValueBase)new AcceptableValueFloatRangeStep(-20f, 20f, 0.1f), new object[0]));
			SoundVelTrig = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "Magnitude of force stop 0.0.1", 1.5f, new ConfigDescription("How hard for sound to trigger from velocity", (AcceptableValueBase)new AcceptableValueFloatRangeStep(-20f, 20f, 0.1f), new object[0]));
			SoundSinceLast = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "Time since last sound 0.0.2", 0.5f, new ConfigDescription("How long before next sound", (AcceptableValueBase)new AcceptableValueFloatRangeStep(-20f, 20f, 0.1f), new object[0]));
		}

		private static bool CheckSkip()
		{
			return !GameEnabled.Value;
		}
	}
}