Decompiled source of PoseGhostCombos v1.0.0

Mods/PoseGhostCombos.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppRUMBLE.Interactions.InteractionBase;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Poses;
using Il2CppRUMBLE.Tutorial.MoveLearning;
using Il2CppTMPro;
using MelonLoader;
using PoseGhostCombos;
using RumbleModdingAPI;
using UnityEngine;
using UnityEngine.Events;

[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), "Pose ghsot combos", "1.0.0", "oreotrollturbo", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("PoseGhostCombos")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PoseGhostCombos")]
[assembly: AssemblyTitle("PoseGhostCombos")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PoseGhostCombos;

public static class BuildInfo
{
	public const string ModName = "Pose ghsot combos";

	public const string ModVersion = "1.0.0";

	public const string Description = "yipeeeee!";

	public const string Author = "oreotrollturbo";
}
public class Main : MelonMod
{
	[HarmonyPatch(typeof(PlayerPoseSystem), "OnPoseSetCompleted")]
	public static class Patch_OnPoseCompleted
	{
		private static void Prefix(PlayerPoseSystem __instance, PoseSet set)
		{
			if ((Object)(object)set == (Object)null || Scene.GetSceneName() != "Gym" || (Object)(object)poseGhost == (Object)null)
			{
				return;
			}
			if (!recordingCombo)
			{
				if (CurrentCombo.comboList != null)
				{
					if (((Object)set).name.Equals(((Object)CurrentCombo.comboList[currentPoseIndex]).name))
					{
						poseGhost.OnPoseCompleted();
						SetPoseIndex(currentPoseIndex + 1);
					}
					else if (!CurrentCombo.hasStructure && CurrentCombo.IsSummon(((Object)set).name))
					{
						SetPoseIndex(0);
					}
				}
			}
			else
			{
				CurrentCombo.AddPose(set);
				MelonCoroutines.Start(ShowPlayerFaceText(((Object)set).name));
				MelonLogger.Msg("Pose added to combo");
			}
		}
	}

	public static PoseGhost poseGhost;

	public static bool recordingCombo;

	private static GameObject playerFaceText;

	public static int currentPoseIndex;

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

	private void SceneLoaded()
	{
		currentPoseIndex = 0;
		recordingCombo = false;
		CurrentCombo.comboList = null;
		CurrentCombo.hasStructure = false;
		if (Scene.GetSceneName() == "Gym")
		{
			poseGhost = ((Component)GameObject.Find("--------------LOGIC--------------").transform.GetChild(3).GetChild(6).GetChild(0)).gameObject.GetComponent<PoseGhost>();
			CreatePlayerFaceText();
			CreateRecordButton();
			SetPoseIndex(0);
		}
	}

	public void CreatePlayerFaceText()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		playerFaceText = Create.NewText("PlaceHolder", 3f, Color.white, Vector3.zero, Quaternion.identity);
		playerFaceText.transform.parent = ((Component)Players.GetLocalPlayer().Controller).transform.GetChild(2).GetChild(0).GetChild(0);
		playerFaceText.transform.localPosition = new Vector3(0f, 0f, 1f);
		playerFaceText.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
		playerFaceText.SetActive(false);
		TextMeshPro component = playerFaceText.GetComponent<TextMeshPro>();
		((TMP_Text)component).enableWordWrapping = false;
		((TMP_Text)component).overflowMode = (TextOverflowModes)0;
	}

	public void CreateRecordButton()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		Vector3 localPosition = default(Vector3);
		((Vector3)(ref localPosition))..ctor(-12.0484f, 1.1399f, 3.6717f);
		ButtonWithLabel recordButton = new ButtonWithLabel(localPosition, "Record", "PoseGhostCombo", (Transform)null);
		recordButton.button.transform.rotation = Quaternion.Euler(90f, 153.9229f, 0f);
		((Component)recordButton.button.transform.GetChild(0)).GetComponent<InteractionButton>().onPressed.AddListener(UnityAction.op_Implicit((Action)delegate
		{
			if (recordingCombo)
			{
				recordingCombo = false;
				if (CurrentCombo.comboList.Count != 0)
				{
					SetPoseIndex(0);
				}
				recordButton.ChangeLabelText("Record");
			}
			else
			{
				recordingCombo = true;
				CurrentCombo.comboList = new List<PoseSet>();
				CurrentCombo.hasStructure = false;
				recordButton.ChangeLabelText("Stop recording");
			}
		}));
	}

	public static void SetPoseIndex(int index)
	{
		if (CurrentCombo.comboList != null)
		{
			if (index > CurrentCombo.comboList.Count - 1)
			{
				currentPoseIndex = 0;
			}
			else
			{
				currentPoseIndex = index;
			}
			if ((Object)(object)poseGhost != (Object)null)
			{
				poseGhost.SetPoseSet(CurrentCombo.comboList[currentPoseIndex]);
			}
		}
	}

	public static IEnumerator ShowPlayerFaceText(string text)
	{
		if (text.Contains("PoseSet"))
		{
			text = text.Replace("PoseSet", "");
		}
		if (CurrentCombo.IsSummon(text))
		{
			text = ConvertPoseSetNameToStructure(text);
		}
		((TMP_Text)playerFaceText.GetComponent<TextMeshPro>()).text = text;
		playerFaceText.SetActive(true);
		yield return (object)new WaitForSeconds(1f);
		playerFaceText.SetActive(false);
	}

	public static string ConvertPoseSetNameToStructure(string poseSetName)
	{
		poseSetName = poseSetName.ToLower();
		if (poseSetName.Contains("wall"))
		{
			return "Wall";
		}
		if (poseSetName.Contains("cube"))
		{
			return "Cube";
		}
		if (poseSetName.Contains("ball"))
		{
			return "Ball";
		}
		if (poseSetName.Contains("pillar"))
		{
			return "Pillar";
		}
		if (poseSetName.Contains("disc"))
		{
			return "Disc";
		}
		return null;
	}
}
public class ButtonWithLabel
{
	public GameObject button;

	public GameObject label;

	public ButtonWithLabel(Vector3 localPosition, string labelText, string objectName, Transform parent)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		button = Create.NewButton(Vector3.zero, Quaternion.identity);
		((Object)button).name = objectName;
		if ((Object)(object)parent != (Object)null)
		{
			button.transform.SetParent(parent, false);
		}
		button.transform.localPosition = localPosition;
		button.transform.localRotation = Quaternion.Euler(90f, 180f, 0f);
		label = Create.NewText(labelText, 0.5f, Color.white, Vector3.zero, Quaternion.identity);
		((Object)label).name = objectName + " label";
		label.transform.SetParent(button.transform, false);
		label.transform.localPosition = new Vector3(0f, 0.12f, 0f);
		label.transform.localRotation = Quaternion.Euler(90f, 180f, 0f);
		TextMeshPro component = label.GetComponent<TextMeshPro>();
		((TMP_Text)component).text = labelText;
		((TMP_Text)component).enableWordWrapping = false;
		((TMP_Text)component).overflowMode = (TextOverflowModes)0;
	}

	public ButtonWithLabel(Vector3 localPosition, string labelText, string objectName, GameObject parent)
		: this(localPosition, labelText, objectName, parent.transform)
	{
	}//IL_0001: Unknown result type (might be due to invalid IL or missing references)


	public void ChangeLabelText(string text)
	{
		TextMeshPro component = label.GetComponent<TextMeshPro>();
		((TMP_Text)component).text = text;
	}

	public void Destroy()
	{
		Object.Destroy((Object)(object)button);
		Object.Destroy((Object)(object)label);
	}
}
public static class CurrentCombo
{
	public static List<PoseSet> comboList;

	public static bool hasStructure;

	public static void AddPose(PoseSet set)
	{
		if (IsSummon(((Object)set).name))
		{
			hasStructure = true;
		}
		comboList.Add(set);
	}

	public static bool IsSummon(string setName)
	{
		string text = setName.ToLower();
		return text.Contains("wall") || text.Contains("cube") || text.Contains("disc") || text.Contains("ball") || text.Contains("pillar");
	}
}