Decompiled source of HandDistanceRecorder v2.3.1

Mods/HandDistanceRecorder.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HandDistanceRecorder;
using HarmonyLib;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Players;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using RumbleModdingAPI.RMAPI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "HandDistanceRecorder", "2.3.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 7, 0, true)]
[assembly: AssemblyTitle("HandDistanceRecorder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HandDistanceRecorder")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b14d69ae-fbeb-434d-bea3-7c74f1b85b50")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HandDistanceRecorder;

public class main : MelonMod
{
	[HarmonyPatch(typeof(PlayerController), "Initialize", new Type[] { typeof(Player) })]
	public static class PlayerSpawn
	{
		private static void Postfix(ref PlayerController __instance, ref Player player)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if ((int)__instance.controllerType == 1)
			{
				init = false;
				waitTill = DateTime.Now.AddSeconds(2.0);
				MelonCoroutines.Start(SetInitialHandPositions());
			}
		}
	}

	[CompilerGenerated]
	private sealed class <SetInitialHandPositions>d__11 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private GameObject <textLeft>5__1;

		private GameObject <textRight>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <SetInitialHandPositions>d__11(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<textLeft>5__1 = null;
			<textRight>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForFixedUpdate();
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				lastHandPositionL = new GameObject();
				((Object)lastHandPositionL).name = "HandDistanceTrackerL";
				lastHandPositionL.transform.parent = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerVR).transform;
				handLTransform = Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerVR.leftController.Transform;
				lastHandPositionR = new GameObject();
				((Object)lastHandPositionR).name = "HandDistanceTrackerR";
				lastHandPositionR.transform.parent = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerVR).transform;
				handRTransform = Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerVR.rightController.Transform;
				<textLeft>5__1 = Create.NewText();
				((Object)<textLeft>5__1).name = "TextLeft";
				<textLeft>5__1.transform.parent = Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerScaling.RigDefinition.leftHandDefinition.Transform;
				<textLeft>5__1.transform.localPosition = new Vector3(0.0372f, 0.115f, 0f);
				<textLeft>5__1.transform.localRotation = Quaternion.Euler(7.2175f, 269.9012f, 358.3884f);
				textL = <textLeft>5__1.GetComponent<TextMeshPro>();
				((TMP_Text)textL).autoSizeTextContainer = true;
				((TMP_Text)textL).enableWordWrapping = false;
				((TMP_Text)textL).alignment = (TextAlignmentOptions)514;
				((TMP_Text)textL).text = "0";
				((TMP_Text)textL).fontSize = 0.25f;
				((TMP_Text)textL).color = Color.white;
				((TMP_Text)textL).outlineColor = Color32.op_Implicit(Color.black);
				((TMP_Text)textL).outlineWidth = 0.25f;
				<textRight>5__2 = Create.NewText();
				((Object)<textRight>5__2).name = "TextRight";
				<textRight>5__2.transform.parent = Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerScaling.RigDefinition.rightHandDefinition.Transform;
				<textRight>5__2.transform.localPosition = new Vector3(-0.0372f, 0.1148f, 0f);
				<textRight>5__2.transform.localRotation = Quaternion.Euler(7.1158f, 93.6177f, 0.9292f);
				textR = <textRight>5__2.GetComponent<TextMeshPro>();
				((TMP_Text)textR).autoSizeTextContainer = true;
				((TMP_Text)textR).enableWordWrapping = false;
				((TMP_Text)textR).alignment = (TextAlignmentOptions)514;
				((TMP_Text)textR).text = "0";
				((TMP_Text)textR).fontSize = 0.25f;
				((TMP_Text)textR).color = Color.white;
				((TMP_Text)textR).outlineColor = Color32.op_Implicit(Color.black);
				((TMP_Text)textR).outlineWidth = 0.25f;
				lastHandPositionL.transform.position = handLTransform.localPosition;
				lastHandPositionR.transform.position = handRTransform.localPosition;
				init = true;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static bool init;

	private static GameObject lastHandPositionL;

	private static GameObject lastHandPositionR;

	private static Transform handLTransform;

	private static Transform handRTransform;

	private float distanceL = 0f;

	private float distanceR = 0f;

	private static DateTime waitTill;

	private static TextMeshPro textL;

	private static TextMeshPro textR;

	[IteratorStateMachine(typeof(<SetInitialHandPositions>d__11))]
	public static IEnumerator SetInitialHandPositions()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <SetInitialHandPositions>d__11(0);
	}

	public override void OnUpdate()
	{
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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)
		if (init && !((Object)(object)lastHandPositionL == (Object)null) && !((Object)(object)lastHandPositionR == (Object)null))
		{
			if (DateTime.Now < waitTill)
			{
				handLTransform = Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerVR.leftController.Transform;
				handRTransform = Singleton<PlayerManager>.instance.localPlayer.Controller.PlayerVR.rightController.Transform;
				lastHandPositionL.transform.position = handLTransform.position;
				lastHandPositionR.transform.position = handRTransform.position;
			}
			else
			{
				distanceL += Vector3.Distance(lastHandPositionL.transform.position, handLTransform.position);
				distanceR += Vector3.Distance(lastHandPositionR.transform.position, handRTransform.position);
				((TMP_Text)textL).text = distanceL.ToString("0.#");
				((TMP_Text)textR).text = distanceR.ToString("0.#");
				lastHandPositionL.transform.position = handLTransform.position;
				lastHandPositionR.transform.position = handRTransform.position;
			}
		}
	}
}