Decompiled source of HeadArmSwing v1.1.2

NGA.HeadArmSwing.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 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.HeadArmSwing")]
[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.HeadArmSwing", "HeadArmSwing", "0.0.1")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInProcess("h3vr.exe")]
	public class HeadArmSwing : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(FVRMovementManager))]
		[HarmonyPatch("HandUpdateTwinstick")]
		public class FVRMovementManagerHandUpdateTwoAxis : MonoBehaviour
		{
			private static int keptLoco;

			private static void Prefix(FVRMovementManager __instance)
			{
				keptLoco = GM.Options.MovementOptions.TPLocoSpeedIndex;
				if (!CheckSkip() && TwinArmSwingEnabled.Value && OnlyArmSprint.Value)
				{
					GM.Options.MovementOptions.TPLocoSpeedIndex = 5;
					int num = GM.Options.MovementOptions.TPLocoSpeeds.Length;
					for (int i = 0; i < num; i++)
					{
						GM.Options.MovementOptions.TPLocoSpeeds[i] = 1f;
					}
				}
			}

			private static void Postfix(FVRMovementManager __instance)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Invalid comparison between Unknown and I4
				//IL_0202: 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_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_023b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				GM.Options.MovementOptions.TPLocoSpeedIndex = keptLoco;
				if (CheckSkip() || !TwinArmSwingEnabled.Value || (int)__instance.Mode != 6)
				{
					return;
				}
				float num = 0f;
				bool sprintingEngaged = __instance.m_sprintingEngaged;
				for (int i = 0; i < __instance.Hands.Length; i++)
				{
					float num2 = Mathf.Max(((Vector3)(ref __instance.Hands[i].Input.VelAngularWorld)).magnitude * AngVelMult.Value, ((Vector3)(ref __instance.Hands[i].Input.VelLinearWorld)).magnitude * LinVelMult.Value);
					num += num2;
				}
				__instance.m_tarArmSwingerImpetus = num;
				__instance.m_curArmSwingerImpetus = (sprintingEngaged ? Mathf.MoveTowards(__instance.m_curArmSwingerImpetus, __instance.m_tarArmSwingerImpetus, AccelMult.Value * Time.deltaTime) : 0f);
				if (sprintingEngaged && __instance.m_isGrounded)
				{
					float curArmSwingerImpetus = __instance.m_curArmSwingerImpetus;
					float value = JogSpeedCap.Value;
					float value2 = JogMinHand.Value;
					if (curArmSwingerImpetus > value2)
					{
						float num3 = curArmSwingerImpetus / value2;
						float num4 = value * num3;
						float value3 = SprintMinHand.Value;
						float value4 = SprintSpeedCap.Value;
						if (curArmSwingerImpetus > value3 && value2 < value3)
						{
							float num5 = curArmSwingerImpetus / value3;
							num4 = value4 * num5;
						}
						Vector3 normalized = ((Vector3)(ref __instance.worldTPAxis)).normalized;
						__instance.worldTPAxis.x += normalized.x * num4;
						__instance.worldTPAxis.z += normalized.z * num4;
					}
				}
				float value5 = JumpThres.Value;
				if (AllowJump.Value && ((Component)__instance.Hands[0]).transform.position.y > __instance.Head.position.y && ((Component)__instance.Hands[1]).transform.position.y > __instance.Head.position.y && __instance.Hands[0].Input.VelLinearWorld.y > value5 && __instance.Hands[1].Input.VelLinearWorld.y > value5)
				{
					__instance.Jump();
				}
			}
		}

		private static ConfigEntry<bool> GameEnabled;

		private static ConfigEntry<bool> TwinArmSwingEnabled;

		private static ConfigEntry<float> SprintSpeedCap;

		private static ConfigEntry<float> JogSpeedCap;

		private static ConfigEntry<float> JogMinHand;

		private static ConfigEntry<float> SprintMinHand;

		private static ConfigEntry<float> AccelMult;

		private static ConfigEntry<float> LinVelMult;

		private static ConfigEntry<float> AngVelMult;

		private static ConfigEntry<bool> OnlyArmSprint;

		private static ConfigEntry<bool> AllowJump;

		private static ConfigEntry<float> JumpThres;

		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.HeadArmSwing");
			Logger.LogMessage((object)"New harmony");
			SetUpConfigFields();
			Logger.LogMessage((object)"Setted the fields");
			val.PatchAll();
			Logger.LogMessage((object)"Hello, world! Sent from NGA.HeadArmSwing 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_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
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Expected O, but got Unknown
			GameEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Overall", "ON/OFF", true, "Completely enable/disable mod");
			TwinArmSwingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("TwinStickArmSwing", "ON/OFF", true, "Enable armswinger with twinstick");
			SprintSpeedCap = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Sprint speed.", 2.75f, new ConfigDescription("Sprint speed soft-cap on armswing. Bigger than jog.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 20f, 0.25f), new object[0]));
			JogSpeedCap = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Jog Speed.", 1.25f, new ConfigDescription("Jog speed soft-cap on armswing.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 20f, 0.25f), new object[0]));
			SprintMinHand = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Needed Arm-movement (Sprint).", 4f, new ConfigDescription("How much arm movement to start sprinting. Bigger than jog.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.25f, 20f, 0.25f), new object[0]));
			JogMinHand = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Needed Arm-movement (Jog).", 1.75f, new ConfigDescription("How much arm movement to start jogging.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.25f, 20f, 0.25f), new object[0]));
			AccelMult = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Acceleration multiplier.", 10f, new ConfigDescription("How fast you speed up and slow down when swinging faster or slower.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.25f, 20f, 0.25f), new object[0]));
			LinVelMult = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Linear Hand Vel Mult.", 3f, new ConfigDescription("How much linear hand velocity contributes to sprint speed.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.25f, 20f, 0.25f), new object[0]));
			AngVelMult = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Angular Hand Vel Mult.", 1f, new ConfigDescription("How much angular hand velocity contributes to sprint speed.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.25f, 20f, 0.25f), new object[0]));
			OnlyArmSprint = ((BaseUnityPlugin)this).Config.Bind<bool>("TwinStickArmSwing", "Only Sprint w Arms.", true, "Pressing sprint does nothing unless you swing your arms (recommended).");
			AllowJump = ((BaseUnityPlugin)this).Config.Bind<bool>("TwinStickArmJump", "Allow Armswing Jump.", true, "Thrust hands above head.");
			JumpThres = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmJump", "Needed arm movement (Jump up).", 2f, new ConfigDescription("How fast both hands need to be flung above head.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.25f, 20f, 0.25f), new object[0]));
		}

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