Decompiled source of PoseHitboxes v1.3.0

Mods/PoseHitboxes.dll

Decompiled 3 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppRUMBLE.Poses;
using Il2CppRUMBLE.Tutorial.MoveLearning;
using MelonLoader;
using PoseHitboxes;
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(ClassPH), "PoseHitboxes", "1.3.0", "Marcopolo1613", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: AssemblyTitle("PoseHitboxes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PoseHitboxes")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("138ef4a5-245f-4c7b-a130-69645d5b6e5b")]
[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 PoseHitboxes;

public class ClassPH : MelonMod
{
	private string currentScene = "Loader";

	private bool sceneChanged = false;

	private bool loaded = false;

	private PoseGhost poseGhost;

	private Material ghosty;

	private Material redy;

	private Material glassy;

	private string currentPoseName = "";

	private int delayCycle = 0;

	private GameObject LHitbox;

	private GameObject RHitbox;

	private GameObject LRotate;

	private GameObject RRotate;

	private GameObject LRotateLimit;

	private GameObject RRotateLimit;

	private GameObject LHandRef;

	private GameObject RHandRef;

	private float deg2rad = 0.01745328f;

	private float LThresh = 0f;

	private float RThresh = 0f;

	private Color red8 = new Color(1f, 0f, 0f, 0.8f);

	private Color green8 = new Color(0f, 1f, 0f, 0.8f);

	private Color blue8 = new Color(0f, 0f, 1f, 0.8f);

	private Color black8 = new Color(0f, 0f, 0f, 0.8f);

	private Color red1 = new Color(1f, 0f, 0f, 0.1f);

	private Color green1 = new Color(0f, 1f, 0f, 0.1f);

	private Color blue1 = new Color(0f, 0f, 1f, 0.1f);

	private void BuildWireframeBox(GameObject WFParent, Material WFMat, Color WFColor)
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		GameObject[,] array = new GameObject[3, 4];
		int[,] array2 = new int[4, 2]
		{
			{ 1, 1 },
			{ 1, -1 },
			{ -1, 1 },
			{ -1, -1 }
		};
		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 4; j++)
			{
				array[i, j] = GameObject.CreatePrimitive((PrimitiveType)3);
				array[i, j].transform.parent = WFParent.transform;
				array[i, j].GetComponent<Renderer>().material = WFMat;
				array[i, j].GetComponent<Renderer>().material.color = WFColor;
				switch (i)
				{
				case 0:
					array[i, j].transform.localScale = new Vector3(1f, 0.003f, 0.003f);
					array[i, j].transform.localPosition = new Vector3(0f, 0.5f * (float)array2[j, 0], 0.5f * (float)array2[j, 1]);
					break;
				case 1:
					array[i, j].transform.localScale = new Vector3(0.003f, 1f, 0.003f);
					array[i, j].transform.localPosition = new Vector3(0.5f * (float)array2[j, 0], 0f, 0.5f * (float)array2[j, 1]);
					break;
				case 2:
					array[i, j].transform.localScale = new Vector3(0.003f, 0.003f, 1f);
					array[i, j].transform.localPosition = new Vector3(0.5f * (float)array2[j, 0], 0.5f * (float)array2[j, 1], 0f);
					break;
				}
			}
		}
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		sceneChanged = true;
		delayCycle = 5;
		loaded = false;
	}

	public override void OnUpdate()
	{
		//IL_0e47: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e68: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_051a: Unknown result type (might be due to invalid IL or missing references)
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05db: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_060b: Unknown result type (might be due to invalid IL or missing references)
		//IL_062c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0640: Unknown result type (might be due to invalid IL or missing references)
		//IL_0645: Unknown result type (might be due to invalid IL or missing references)
		//IL_0666: Unknown result type (might be due to invalid IL or missing references)
		//IL_067a: Unknown result type (might be due to invalid IL or missing references)
		//IL_067f: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_081a: Unknown result type (might be due to invalid IL or missing references)
		//IL_083b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0850: Unknown result type (might be due to invalid IL or missing references)
		//IL_0865: Unknown result type (might be due to invalid IL or missing references)
		//IL_086f: Unknown result type (might be due to invalid IL or missing references)
		//IL_088c: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0720: Unknown result type (might be due to invalid IL or missing references)
		//IL_073b: Unknown result type (might be due to invalid IL or missing references)
		//IL_075c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0771: Unknown result type (might be due to invalid IL or missing references)
		//IL_0786: Unknown result type (might be due to invalid IL or missing references)
		//IL_0790: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_09db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a56: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aa7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b2e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bb7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bcf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0be7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c20: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c34: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c39: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c5a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c6e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c73: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c94: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ca8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ce2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ce7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cfd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d06: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d1b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d20: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d2e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0da5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0daa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0daf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dcc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dd1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dd6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d53: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d58: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d5d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d7a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d7f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d84: Unknown result type (might be due to invalid IL or missing references)
		//IL_0df4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e11: Unknown result type (might be due to invalid IL or missing references)
		if (currentScene != "Gym")
		{
			return;
		}
		if (sceneChanged)
		{
			if (delayCycle > 1)
			{
				delayCycle--;
			}
			else
			{
				if (!loaded)
				{
					try
					{
						poseGhost = MoveLearning.GetGameObject().GetComponentInChildren<PoseGhost>();
						ghosty = ((Component)((Component)poseGhost).transform.GetChild(0).GetChild(1)).GetComponent<Renderer>().material;
						redy = ((Component)GymArena.GetGameObject().transform.GetChild(0)).GetComponent<Renderer>().material;
						LHandRef = GameObject.Find("Player Controller(Clone)/Visuals/RIG/Bone_Pelvis/Bone_Spine/Bone_Chest/Bone_Shoulderblade_L/Bone_Shoulder_L/Bone_Lowerarm_L/Bone_Hand_L");
						RHandRef = GameObject.Find("Player Controller(Clone)/Visuals/RIG/Bone_Pelvis/Bone_Spine/Bone_Chest/Bone_Shoulderblade_R/Bone_Shoulder_R/Bone_Lowerarm_R/Bone_Hand_R");
						loaded = true;
						currentPoseName = "";
					}
					catch
					{
						return;
					}
				}
				sceneChanged = false;
			}
		}
		if (loaded && currentPoseName != ((Object)poseGhost.showCurrentPoseData).name)
		{
			if (((Component)poseGhost).transform.GetChild(0).GetChild(0).childCount > 0)
			{
				while (((Component)poseGhost).transform.GetChild(0).GetChild(0).childCount > 0 || ((Component)poseGhost).transform.GetChild(0).GetChild(1).childCount > 0)
				{
					Object.DestroyImmediate((Object)(object)((Component)((Component)poseGhost).transform.GetChild(0).GetChild(0).GetChild(0)).gameObject);
					Object.DestroyImmediate((Object)(object)((Component)((Component)poseGhost).transform.GetChild(0).GetChild(1).GetChild(0)).gameObject);
					Object.DestroyImmediate((Object)(object)LRotate.gameObject);
					Object.DestroyImmediate((Object)(object)RRotate.gameObject);
				}
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
			val.transform.parent = ((Component)poseGhost).transform.GetChild(0).GetChild(0);
			val2.transform.parent = ((Component)poseGhost).transform.GetChild(0).GetChild(1);
			val.transform.position = poseGhost.leftHand.position;
			val2.transform.position = poseGhost.rightHand.position;
			BuildWireframeBox(val.gameObject, redy, black8);
			BuildWireframeBox(val2.gameObject, redy, black8);
			val.GetComponent<Renderer>().enabled = false;
			val2.GetComponent<Renderer>().enabled = false;
			((Component)((Component)poseGhost).transform.GetChild(0).GetChild(0)).GetComponent<Renderer>().material = redy;
			((Component)((Component)poseGhost).transform.GetChild(0).GetChild(1)).GetComponent<Renderer>().material = redy;
			currentPoseName = ((Object)poseGhost.showCurrentPoseData).name;
			LRotate = GameObject.CreatePrimitive((PrimitiveType)3);
			RRotate = GameObject.CreatePrimitive((PrimitiveType)3);
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
			GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3);
			GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)3);
			GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)3);
			LRotate.transform.parent = ((Component)poseGhost).transform.GetChild(0).GetChild(0);
			RRotate.transform.parent = ((Component)poseGhost).transform.GetChild(0).GetChild(1);
			LRotate.GetComponent<Renderer>().material = redy;
			RRotate.GetComponent<Renderer>().material = redy;
			LRotate.transform.localScale = new Vector3(0.003f, 0.003f, 0.003f);
			RRotate.transform.localScale = new Vector3(0.003f, 0.003f, 0.003f);
			val3.transform.parent = LRotate.transform;
			val4.transform.parent = LRotate.transform;
			val5.transform.parent = RRotate.transform;
			val6.transform.parent = RRotate.transform;
			val3.transform.localScale = new Vector3(1f, 25f, 1f);
			val4.transform.localScale = new Vector3(1f, 1f, 25f);
			val5.transform.localScale = new Vector3(1f, 25f, 1f);
			val6.transform.localScale = new Vector3(1f, 1f, 25f);
			val3.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val4.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val5.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val6.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val3.GetComponent<Renderer>().material.color = green8;
			val4.GetComponent<Renderer>().material.color = blue8;
			val5.GetComponent<Renderer>().material.color = green8;
			val6.GetComponent<Renderer>().material.color = blue8;
			LRotate.transform.position = poseGhost.leftHand.position + new Vector3(-1f, 0f, -1f);
			RRotate.transform.position = poseGhost.rightHand.position + new Vector3(-1f, 0f, -1f);
			LRotateLimit = GameObject.CreatePrimitive((PrimitiveType)0);
			RRotateLimit = GameObject.CreatePrimitive((PrimitiveType)0);
			GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)2);
			GameObject val8 = GameObject.CreatePrimitive((PrimitiveType)2);
			GameObject val9 = GameObject.CreatePrimitive((PrimitiveType)2);
			GameObject val10 = GameObject.CreatePrimitive((PrimitiveType)2);
			Quaternion rotation = poseGhost.leftHand.rotation;
			float x = ((Quaternion)(ref rotation)).eulerAngles.x;
			Condition leftControllerCondition = poseGhost.showCurrentPoseData.leftControllerCondition;
			if (x == ((Quaternion)(ref leftControllerCondition.DesiredPose.rotation)).eulerAngles.x)
			{
				LThresh = poseGhost.showCurrentPoseData.LeftControllerCondition.RotationTreshold;
				RThresh = poseGhost.showCurrentPoseData.RightControllerCondition.RotationTreshold;
				val.transform.localScale = new Vector3(poseGhost.showCurrentPoseData.leftControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.leftControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.leftControllerCondition.PositionTreshold);
				val2.transform.localScale = new Vector3(poseGhost.showCurrentPoseData.RightControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.RightControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.RightControllerCondition.PositionTreshold);
			}
			else
			{
				RThresh = poseGhost.showCurrentPoseData.LeftControllerCondition.RotationTreshold;
				LThresh = poseGhost.showCurrentPoseData.RightControllerCondition.RotationTreshold;
				val2.transform.localScale = new Vector3(poseGhost.showCurrentPoseData.leftControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.leftControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.leftControllerCondition.PositionTreshold);
				val.transform.localScale = new Vector3(poseGhost.showCurrentPoseData.RightControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.RightControllerCondition.PositionTreshold, poseGhost.showCurrentPoseData.RightControllerCondition.PositionTreshold);
			}
			float num = (1f - LThresh) * 3.14159f;
			float num2 = (1f - RThresh) * 3.14159f;
			LRotateLimit.transform.parent = ((Component)poseGhost).transform.GetChild(0).GetChild(0);
			RRotateLimit.transform.parent = ((Component)poseGhost).transform.GetChild(0).GetChild(1);
			LRotateLimit.GetComponent<Renderer>().material = redy;
			RRotateLimit.GetComponent<Renderer>().material = redy;
			LRotateLimit.transform.localScale = new Vector3(0.03f * LThresh, 0.03f * LThresh, 0.03f * LThresh);
			RRotateLimit.transform.localScale = new Vector3(0.03f * RThresh, 0.03f * RThresh, 0.03f * RThresh);
			val7.transform.parent = LRotateLimit.transform;
			val8.transform.parent = LRotateLimit.transform;
			val9.transform.parent = RRotateLimit.transform;
			val10.transform.parent = RRotateLimit.transform;
			val7.transform.localScale = new Vector3(num, 0.5f, num);
			val8.transform.localScale = new Vector3(num, 0.5f, num);
			val9.transform.localScale = new Vector3(num2, 0.5f, num2);
			val10.transform.localScale = new Vector3(num2, 0.5f, num2);
			val7.transform.Rotate(new Vector3(0f, 90f, 0f), (Space)1);
			val8.transform.Rotate(new Vector3(90f, 0f, 0f), (Space)1);
			val9.transform.Rotate(new Vector3(0f, 90f, 0f), (Space)1);
			val10.transform.Rotate(new Vector3(90f, 0f, 0f), (Space)1);
			val7.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val8.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val9.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val10.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
			val7.GetComponent<Renderer>().material.color = green1;
			val8.GetComponent<Renderer>().material.color = blue1;
			val9.GetComponent<Renderer>().material.color = green1;
			val10.GetComponent<Renderer>().material.color = blue1;
			LRotateLimit.transform.position = poseGhost.leftHand.position + new Vector3(-0.3f, 0.15f, -0.3f);
			RRotateLimit.transform.position = poseGhost.rightHand.position + new Vector3(-0.3f, 0.15f, -0.3f);
			LRotate.transform.position = poseGhost.leftHand.position + new Vector3(-0.3f, 0.15f, -0.3f);
			RRotate.transform.position = poseGhost.rightHand.position + new Vector3(-0.3f, 0.15f, -0.3f);
			rotation = poseGhost.leftHand.rotation;
			float x2 = ((Quaternion)(ref rotation)).eulerAngles.x;
			leftControllerCondition = poseGhost.showCurrentPoseData.leftControllerCondition;
			if (x2 == ((Quaternion)(ref leftControllerCondition.DesiredPose.rotation)).eulerAngles.x)
			{
				val.transform.localRotation = poseGhost.showCurrentPoseData.leftControllerCondition.DesiredPose.rotation;
				val2.transform.localRotation = poseGhost.showCurrentPoseData.rightControllerCondition.DesiredPose.rotation;
			}
			else
			{
				val2.transform.localRotation = poseGhost.showCurrentPoseData.leftControllerCondition.DesiredPose.rotation;
				val.transform.localRotation = poseGhost.showCurrentPoseData.rightControllerCondition.DesiredPose.rotation;
			}
			LRotateLimit.transform.rotation = val.transform.rotation;
			RRotateLimit.transform.rotation = val2.transform.rotation;
		}
		if ((Object)(object)LRotate != (Object)null)
		{
			LRotate.transform.rotation = LHandRef.GetComponent<Transform>().rotation;
			RRotate.transform.rotation = RHandRef.GetComponent<Transform>().rotation;
		}
	}
}