using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("TwinStickArmSprint")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TwinStickArmSprint")]
[assembly: AssemblyTitle("TwinStickArmSprint")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace H3VRMod
{
public class Patch
{
public class HandState
{
public Quaternion pointerRotation_0;
public Quaternion pointerRotation_1;
public int baseSpeedLeft;
public int baseSpeedRight;
}
public static int MovementHand = 0;
public static readonly Dictionary<float, int[]> SpeedMap = new Dictionary<float, int[]>
{
{
3.6f,
new int[2] { 5, 5 }
},
{
3f,
new int[2] { 5, 4 }
},
{
2.55f,
new int[2] { 5, 3 }
},
{
2.4f,
new int[2] { 4, 4 }
},
{
2.175f,
new int[2] { 5, 2 }
},
{
2.025f,
new int[2] { 5, 1 }
},
{
1.95f,
new int[2] { 4, 3 }
},
{
1.8f,
new int[2] { 5, 0 }
},
{
1.575f,
new int[2] { 4, 2 }
},
{
1.5f,
new int[2] { 3, 3 }
},
{
1.425f,
new int[2] { 4, 1 }
},
{
1.2f,
new int[2] { 4, 0 }
},
{
1.125f,
new int[2] { 3, 2 }
},
{
0.975f,
new int[2] { 3, 1 }
},
{
0.75f,
new int[2] { 2, 2 }
},
{
0.6f,
new int[2] { 2, 1 }
},
{
0.45f,
new int[2] { 1, 1 }
},
{
0.375f,
new int[2] { 2, 0 }
},
{
0.225f,
new int[2] { 1, 0 }
},
{
0f,
new int[2]
}
};
[HarmonyPatch(typeof(FVRMovementManager), "Awake")]
[HarmonyPrefix]
public static void Patch_FindMovementHand(FVRMovementManager __instance)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
int num = ((!__instance.Hands[0].IsThisTheRightHand) ? 1 : 0);
MovementHand = (((int)GM.Options.MovementOptions.TwinStickLeftRightState == 1) ? num : (1 - num));
}
[HarmonyPatch(typeof(FVRMovementManager), "ShouldFlushTouchpad")]
[HarmonyPostfix]
public static void Patch_ShouldFlushTouchpad(FVRMovementManager __instance, FVRViveHand hand, ref bool __result)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Invalid comparison between Unknown and I4
if (!hand.IsInStreamlinedMode && (int)hand.CMode != 3 && (int)hand.CMode != 2 && (int)__instance.Mode == 4)
{
bool flag = hand.IsThisTheRightHand;
if ((int)GM.Options.MovementOptions.TwinStickLeftRightState == 1)
{
flag = !flag;
}
if (__instance.m_isLeftHandActive && !flag)
{
__result = true;
}
if (__instance.m_isRightHandActive && flag)
{
__result = true;
}
}
}
[HarmonyPatch(typeof(FVRMovementManager), "UpdateMovementWithHand")]
[HarmonyPrefix]
public static bool Patch_HandMovementUpdate(FVRMovementManager __instance, FVRViveHand hand)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
if ((int)__instance.Mode == 4)
{
bool secondary2AxisWestDown = __instance.Hands[MovementHand].Input.Secondary2AxisWestDown;
bool secondary2AxisEastDown = __instance.Hands[MovementHand].Input.Secondary2AxisEastDown;
__instance.Hands[MovementHand].Input.Secondary2AxisWestDown = false;
__instance.Hands[MovementHand].Input.Secondary2AxisEastDown = false;
__instance.HandUpdateArmSwinger(hand);
__instance.Hands[MovementHand].Input.Secondary2AxisWestDown = secondary2AxisWestDown;
__instance.Hands[MovementHand].Input.Secondary2AxisEastDown = secondary2AxisEastDown;
TwinStickSnapturnMode twinStickSnapturnState = GM.Options.MovementOptions.TwinStickSnapturnState;
GM.Options.MovementOptions.TwinStickSnapturnState = (TwinStickSnapturnMode)0;
__instance.HandUpdateTwinstick(hand);
GM.Options.MovementOptions.TwinStickSnapturnState = twinStickSnapturnState;
__instance.AXButtonCheck(hand);
return false;
}
return true;
}
[HarmonyPatch(typeof(FVRMovementManager), "UpdateSmoothLocomotion")]
[HarmonyPrefix]
public static void Patch_SmoothLocomotionUpdate(FVRMovementManager __instance, out HandState __state)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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_0084: Invalid comparison between Unknown and I4
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Invalid comparison between Unknown and I4
__state = new HandState();
if ((int)__instance.Mode != 4)
{
return;
}
__instance.Hands[MovementHand].Input.Secondary2AxisWestPressed = false;
__instance.Hands[MovementHand].Input.Secondary2AxisEastPressed = false;
ref bool reference = ref __instance.Hands[0].Input.BYButtonPressed;
ref bool reference2 = ref __instance.Hands[1].Input.BYButtonPressed;
if (__instance.Hands[0].IsInStreamlinedMode)
{
if ((int)__instance.Hands[0].CMode == 3 || (int)__instance.Hands[0].CMode == 2)
{
reference = ref __instance.Hands[0].Input.Secondary2AxisNorthPressed;
reference2 = ref __instance.Hands[1].Input.Secondary2AxisNorthPressed;
}
else
{
reference = ref __instance.Hands[0].Input.TouchpadNorthPressed;
reference2 = ref __instance.Hands[1].Input.TouchpadNorthPressed;
}
}
float magnitude = ((Vector3)(ref __instance.worldTPAxis)).magnitude;
reference = magnitude > 0f;
reference2 = magnitude > 0f;
__state.pointerRotation_0 = __instance.Hands[0].PointingTransform.localRotation;
__state.pointerRotation_1 = __instance.Hands[1].PointingTransform.localRotation;
__state.baseSpeedLeft = GM.Options.MovementOptions.ArmSwingerBaseSpeed_Left;
__state.baseSpeedRight = GM.Options.MovementOptions.ArmSwingerBaseSpeed_Right;
if (!(magnitude > 0f))
{
return;
}
__instance.Hands[0].PointingTransform.forward = ((Vector3)(ref __instance.worldTPAxis)).normalized;
__instance.Hands[1].PointingTransform.forward = ((Vector3)(ref __instance.worldTPAxis)).normalized;
foreach (float key in SpeedMap.Keys)
{
if (magnitude > key)
{
GM.Options.MovementOptions.ArmSwingerBaseSpeed_Left = SpeedMap[key][0];
GM.Options.MovementOptions.ArmSwingerBaseSpeed_Right = SpeedMap[key][1];
break;
}
}
}
[HarmonyPatch(typeof(FVRMovementManager), "UpdateSmoothLocomotion")]
[HarmonyPostfix]
public static void Patch_SmoothLocomotionUpdateEnd(FVRMovementManager __instance, HandState __state)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if ((int)__instance.Mode == 4)
{
__instance.Hands[0].PointingTransform.localRotation = __state.pointerRotation_0;
__instance.Hands[1].PointingTransform.localRotation = __state.pointerRotation_1;
GM.Options.MovementOptions.ArmSwingerBaseSpeed_Left = __state.baseSpeedLeft;
GM.Options.MovementOptions.ArmSwingerBaseSpeed_Right = __state.baseSpeedRight;
}
}
[HarmonyPatch(typeof(FVRPointableButton), "Awake")]
[HarmonyPostfix]
public static void Patch_FixDashName(FVRPointableButton __instance)
{
Text component = ((Component)__instance).GetComponent<Text>();
if ((Object)(object)component != (Object)null && component.text == "Armswinger")
{
component.text = "TS Arm Sprint";
}
}
}
[BepInPlugin("dll.h3vr.odekak.twinstickarmsprint", "TwinStick Arm Sprint", "1.0.1")]
[BepInProcess("h3vr.exe")]
public class Plugin : BaseUnityPlugin
{
public void Start()
{
Harmony.CreateAndPatchAll(typeof(Patch), (string)null);
}
}
internal static class PluginInfo
{
internal const string NAME = "TwinStick Arm Sprint";
internal const string GUID = "dll.h3vr.odekak.twinstickarmsprint";
internal const string VERSION = "1.0.1";
}
}