Decompiled source of HandDistanceRecorder v2.0.1

Mods/HandDistanceRecorder.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HandDistanceRecorder;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using RumbleModdingAPI;
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.0.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, 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
{
	private bool init = false;

	private GameObject lastHandPositionL;

	private GameObject lastHandPositionR;

	private Transform handLTransform;

	private Transform handRTransform;

	private float distanceL = 0f;

	private float distanceR = 0f;

	private DateTime waitTill;

	private int sceneCount = 0;

	private TextMeshPro textL;

	private TextMeshPro textR;

	private string currentScene = "Loader";

	public override void OnLateInitializeMelon()
	{
		Calls.onMapInitialized += SceneLoaded;
	}

	private void SceneLoaded()
	{
		if (currentScene != "Loader")
		{
			MelonCoroutines.Start(WaitBeforeRunningInit(sceneCount));
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		sceneCount++;
		init = false;
		waitTill = DateTime.Now.AddSeconds(2.0);
	}

	public override void OnUpdate()
	{
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: 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_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: 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)
			{
				GameObject gameObject = ((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(1)).gameObject;
				handLTransform = gameObject.transform.GetChild(1);
				handRTransform = gameObject.transform.GetChild(2);
				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;
			}
		}
	}

	public IEnumerator WaitBeforeRunningInit(int sceneChanges)
	{
		yield return (object)new WaitForSeconds(1f);
		if (sceneChanges == sceneCount)
		{
			MelonCoroutines.Start(SetInitialHandPositions(sceneChanges));
		}
	}

	public IEnumerator SetInitialHandPositions(int sceneChanges)
	{
		yield return (object)new WaitForFixedUpdate();
		bool gotHands = false;
		while (!gotHands)
		{
			while ((Object)(object)Singleton<PlayerManager>.instance.localPlayer.Controller == (Object)null)
			{
				yield return (object)new WaitForFixedUpdate();
			}
			if (sceneCount != sceneChanges)
			{
				yield break;
			}
			GameObject VR = ((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(1)).gameObject;
			lastHandPositionL = new GameObject();
			lastHandPositionR = new GameObject();
			lastHandPositionL.transform.parent = VR.transform;
			lastHandPositionR.transform.parent = VR.transform;
			handLTransform = VR.transform.GetChild(1);
			handRTransform = VR.transform.GetChild(2);
			GameObject textLeft = Create.NewText();
			((Object)textLeft).name = "TextLeft";
			textLeft.transform.parent = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(5).GetChild(7).GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(1)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0);
			textLeft.transform.localPosition = new Vector3(0.0272f, 0.115f, 0f);
			textLeft.transform.localRotation = Quaternion.Euler(7.2175f, 269.9012f, 358.3884f);
			textL = textLeft.GetComponent<TextMeshPro>();
			((TMP_Text)textL).autoSizeTextContainer = true;
			((TMP_Text)textL).enableWordWrapping = false;
			((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;
			GameObject textRight = Create.NewText();
			((Object)textRight).name = "TextRight";
			textRight.transform.parent = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(5).GetChild(7).GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(2)
				.GetChild(0)
				.GetChild(0)
				.GetChild(0);
			textRight.transform.localPosition = new Vector3(-0.0272f, 0.1148f, 0f);
			textRight.transform.localRotation = Quaternion.Euler(7.1158f, 93.6177f, 0.9292f);
			textR = textRight.GetComponent<TextMeshPro>();
			((TMP_Text)textR).autoSizeTextContainer = true;
			((TMP_Text)textR).enableWordWrapping = false;
			((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;
			_ = handLTransform.position;
			_ = handRTransform.position;
			if (true)
			{
				gotHands = true;
			}
			if (!gotHands)
			{
				yield return (object)new WaitForFixedUpdate();
			}
		}
		init = true;
	}
}