Decompiled source of GunVarConfigs v0.0.3

NGA.GunVarConfigs.dll

Decompiled 2 weeks 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())
				{
					__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 LpreviousVelocity;

			private static Vector3 RpreviousAngularVelocity;

			private static Vector3 RpreviousVelocity;

			private static void Postfix(FVRPhysicalObject __instance)
			{
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_014f: 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_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: 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)
				//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bb: 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)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: 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)
				{
					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> 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_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
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			GameEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Overall", "ON/OFF", true, "Completely enable/disable mod");
			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.1", 0.1f, new ConfigDescription("How long before next sound", (AcceptableValueBase)new AcceptableValueFloatRangeStep(-20f, 20f, 0.1f), new object[0]));
		}

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