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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: 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) : Mathf.MoveTowards(__instance.m_curArmSwingerImpetus, 0f, AccelMult.Value * Time.deltaTime));
if (sprintingEngaged && __instance.m_isGrounded)
{
float curArmSwingerImpetus = __instance.m_curArmSwingerImpetus;
float value = JogSpeedCap.Value;
float value2 = JogMinHand.Value;
float value3 = SprintMinHand.Value;
float value4 = SprintSpeedCap.Value;
float value5 = SuperSprintMinHand.Value;
Vector3 normalized = ((Vector3)(ref __instance.worldTPAxis)).normalized;
float num3 = Mathf.Clamp(value * (curArmSwingerImpetus / value2), 0f, value);
if (curArmSwingerImpetus > value3 && value2 < value3)
{
float num4 = curArmSwingerImpetus / value3;
num3 = Mathf.Clamp(value4 * num4, 0f, value4);
}
if (curArmSwingerImpetus > value5 && value5 > value3)
{
float num5 = curArmSwingerImpetus / value3;
num3 = value4 * num5;
}
__instance.worldTPAxis.x += normalized.x * num3;
__instance.worldTPAxis.z += normalized.z * num3;
}
float value6 = 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 > value6 && __instance.Hands[1].Input.VelLinearWorld.y > value6)
{
__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> SuperSprintMinHand;
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");
}
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_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Expected O, but got Unknown
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Expected O, but got Unknown
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Expected O, but got Unknown
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: 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 Added speed v2", 2f, new ConfigDescription("Sprint speed soft-cap on armswing. Bigger than jog.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 20f, 0.05f), new object[0]));
JogSpeedCap = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Jog Added Speed v2", 0.75f, new ConfigDescription("Jog speed soft-cap on armswing.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 20f, 0.05f), new object[0]));
SuperSprintMinHand = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Needed Arm-movement (Super Sprint) v2", 8f, new ConfigDescription("How much arm movement to start sprinting. Bigger than jog.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.25f, 20f, 0.25f), new object[0]));
SprintMinHand = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Needed Arm-movement (Sprint) v2", 4f, new ConfigDescription("How much arm movement to start sprinting. Bigger than jog.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.1f, 20f, 0.1f), new object[0]));
JogMinHand = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Needed Arm-movement (Jog) v2", 1.8f, new ConfigDescription("How much arm movement to start jogging.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0.1f, 20f, 0.1f), new object[0]));
AccelMult = ((BaseUnityPlugin)this).Config.Bind<float>("TwinStickArmSwing", "Acceleration multiplier v2", 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 v2", 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 v2", 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) v2", 3f, 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;
}
}
}