Decompiled source of notationClipper v1.0.4

Mods/notationClipper.dll

Decompiled 9 hours 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 System.Windows.Forms;
using HarmonyLib;
using Il2Cpp;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.Combat.ShiftStones;
using Il2CppRUMBLE.Players.Subsystems;
using Il2CppRUMBLE.Poses;
using Il2CppTMPro;
using MelonLoader;
using RumbleModUI;
using RumbleModdingAPI;
using UnityEngine;
using notationClipper;

[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), "notationClipper", "1.0.4", "klibe", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: AssemblyTitle("notationClipper")]
[assembly: AssemblyDescription("Adds your combos to your clipboard after recording them!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("notationClipper")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0c4fb5e0-dd9a-40e6-be7c-c121f3555e3b")]
[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 notationClipper;

public static class BuildInfo
{
	public const string ModName = "notationClipper";

	public const string ModVersion = "1.0.4";

	public const string Description = "Adds your combos to your clipboard after recording them!";

	public const string Author = "klibe";

	public const string Company = "";
}
public class Validation : ValidationParameters
{
	private int Length;

	public Validation(int i)
	{
		Length = i;
	}

	public override bool DoValidation(string Input)
	{
		if (Input.Length == Length)
		{
			return true;
		}
		return false;
	}
}
public class main : MelonMod
{
	[HarmonyPatch(typeof(PlayerPoseSystem), "OnPoseSetCompleted", new Type[] { typeof(PoseSet) })]
	private static class PosePatch
	{
		private static void Postfix(PoseSet set)
		{
			string moveName = turnToNotation(((Object)set).name);
			moveDetected(moveName);
		}
	}

	private Mod NotationClipper = new Mod();

	private static string comboString = "";

	private bool isLockingOn = false;

	private bool isUTurning = false;

	private static bool recording = false;

	private static bool interruptedCombo = false;

	private static bool stillDisplayingText = false;

	private static int moveTimer = 0;

	private static int maxMoveTime = 25;

	private static int postRecordTimer = 0;

	private static int postRecordMaxTime = 25;

	private string currentScene = "";

	private static bool init = false;

	private GameObject text1;

	private static TextMeshPro text1Text;

	private static bool displayShiftstonesOnText = true;

	private static bool clipShiftstones = true;

	private static bool detectJoystick = false;

	private static bool alwaysDisplayText = false;

	private static int postStructureTime;

	private static int postModifierTime;

	private static int postMovementTime;

	private static Color recordingColor = Color.red;

	private static Color comboingColor = Color.white;

	private void updateModUIVariables()
	{
		displayShiftstonesOnText = "true" == NotationClipper.Settings[1].GetValueAsString();
		clipShiftstones = "true" == NotationClipper.Settings[2].GetValueAsString();
		detectJoystick = "true" == NotationClipper.Settings[3].GetValueAsString();
		alwaysDisplayText = "true" == NotationClipper.Settings[4].GetValueAsString();
		postStructureTime = (int)NotationClipper.Settings[5].Value;
		postModifierTime = (int)NotationClipper.Settings[6].Value;
		postMovementTime = (int)NotationClipper.Settings[7].Value;
	}

	public void OnUIInit()
	{
		UI.instance.AddMod(NotationClipper);
		MelonLogger.Msg("Added Mod");
	}

	public override void OnLateInitializeMelon()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Expected O, but got Unknown
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Expected O, but got Unknown
		((MelonBase)this).OnLateInitializeMelon();
		NotationClipper.ModName = "notationClipper";
		NotationClipper.ModVersion = "1.0.4";
		NotationClipper.SetFolder("notationClipper");
		NotationClipper.AddDescription("Description", "Description", "Adds your combos to your clipboard after recording them!", new Tags
		{
			IsSummary = true
		});
		NotationClipper.AddToList("Display Shiftstones", true, 0, "Toggles if shiftstones display on the text", new Tags());
		NotationClipper.AddToList("Clip Shiftstones", true, 0, "Toggles if shiftstones are clipped and noted on recording", new Tags());
		NotationClipper.AddToList("Clip Joystick", true, 0, "Toggles if joystick flicks display on the text", new Tags());
		NotationClipper.AddToList("Always display text", false, 0, "If on, will always display current combo even if not recording", new Tags());
		NotationClipper.AddToList("Post Structure Time", 50, "The time after a structure pose the combo will wait for another move (in 50th of a second)", new Tags());
		NotationClipper.AddToList("Post Modifier Time", 25, "The time after a modifier pose the combo will wait for another move (in 50th of a second)", new Tags());
		NotationClipper.AddToList("Post Movement Time", 40, "The time after a movement pose the combo will wait for another move (in 50th of a second)", new Tags());
		NotationClipper.ModSaved += updateModUIVariables;
		NotationClipper.GetFromFile();
		updateModUIVariables();
		UI.instance.UI_Initialized += OnUIInit;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
		init = false;
		if (currentScene != "Loader")
		{
			MelonCoroutines.Start(InitializeWithPause());
		}
	}

	private IEnumerator InitializeWithPause()
	{
		yield return (object)new WaitForSeconds(3f);
		text1 = Create.NewText("", 1f, comboingColor, new Vector3(0f, 1f, 0f), Quaternion.identity);
		((Object)text1).name = "Combo Display";
		text1Text = text1.GetComponent<TextMeshPro>();
		((TMP_Text)text1Text).enableWordWrapping = false;
		((TMP_Text)text1Text).outlineColor = Color32.op_Implicit(Color.black);
		((TMP_Text)text1Text).outlineWidth = 0.1f;
		((TMP_Text)text1Text).fontSize = 0.3f;
		((TMP_Text)text1Text).alignment = (TextAlignmentOptions)514;
		text1.transform.parent = ((Component)Managers.GetPlayerManager().localPlayer.Controller).transform.GetChild(1).GetChild(0).GetChild(0);
		text1.transform.localPosition = new Vector3(0f, 0.1f, 0.2f);
		text1.transform.forward = ((Component)Managers.GetPlayerManager().localPlayer.Controller).transform.GetChild(1).GetChild(0).GetChild(0)
			.forward;
		init = true;
	}

	private IEnumerator delayClearText()
	{
		stillDisplayingText = true;
		if (interruptedCombo)
		{
			interruptedCombo = false;
			postRecordTimer = 0;
			stillDisplayingText = false;
			((TMP_Text)text1Text).color = comboingColor;
		}
		if (postRecordTimer >= postRecordMaxTime)
		{
			if (init)
			{
				((TMP_Text)text1Text).text = "";
			}
			postRecordTimer = 0;
			stillDisplayingText = false;
			((TMP_Text)text1Text).color = comboingColor;
		}
		else
		{
			yield return (object)new WaitForFixedUpdate();
			MelonCoroutines.Start(delayClearText());
		}
	}

	public override void OnFixedUpdate()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		bool flag = recording;
		recording = LeftController.GetTrigger() > 0.8f && LeftController.GetGrip() > 0.8f && init;
		if (detectJoystick)
		{
			Vector2 joystick = LeftController.GetJoystick();
			if (joystick.y > 0.9f && !isLockingOn)
			{
				isLockingOn = true;
				moveDetected("^");
			}
			if (joystick.y < 0.5f)
			{
				isLockingOn = false;
			}
			if (joystick.y < -0.9f && isUTurning)
			{
				isUTurning = true;
				moveDetected("u");
			}
			if (joystick.y > -0.5f)
			{
				isUTurning = false;
			}
		}
		if (recording)
		{
			if (!flag && init)
			{
				text1.transform.forward = ((Component)Managers.GetPlayerManager().localPlayer.Controller).transform.GetChild(1).GetChild(0).GetChild(0)
					.forward;
				((TMP_Text)text1Text).text = "";
				comboString = "";
				if (init)
				{
					((TMP_Text)text1Text).color = recordingColor;
				}
			}
			return;
		}
		if (!stillDisplayingText && comboString != "")
		{
			moveTimer++;
		}
		else
		{
			postRecordTimer++;
		}
		if (moveTimer >= maxMoveTime)
		{
			comboString = "";
			if (init)
			{
				((TMP_Text)text1Text).text = "";
			}
		}
		if (!flag || !init)
		{
			return;
		}
		if (comboString != "")
		{
			string expectedText = getExpectedText(comboString, clipShiftstones);
			MelonLogger.Msg(expectedText + " copied to clipboard!");
			try
			{
				Clipboard.SetText(expectedText);
				((TMP_Text)text1Text).text = expectedText + Environment.NewLine + "copied to clipboard!";
			}
			catch
			{
			}
			comboString = "";
			postRecordTimer = 0;
			moveTimer = 0;
			MelonCoroutines.Start(delayClearText());
		}
		else
		{
			((TMP_Text)text1Text).color = comboingColor;
		}
	}

	private static string turnToNotation(string original)
	{
		maxMoveTime = postModifierTime;
		string text = "";
		switch (original)
		{
		case "SprintPoseSet":
			text = "R";
			maxMoveTime = postMovementTime;
			break;
		case "PoseSetStraight":
			text = "S";
			break;
		case "PoseSetUppercut":
			text = "U";
			break;
		case "PoseSetKick":
			text = "K";
			break;
		case "PoseSetStomp":
			text = "G";
			break;
		case "PoseSetParry":
			text = "P";
			break;
		case "PoseSetDash":
			text = "D";
			maxMoveTime = postMovementTime;
			break;
		case "PoseSetRockjump":
			text = "J";
			maxMoveTime = postMovementTime;
			break;
		case "PoseSetHoldRight":
			text = "H";
			break;
		case "PoseSetHoldLeft":
			text = "H";
			break;
		case "PoseSetFlick":
			text = "F";
			maxMoveTime = postStructureTime;
			break;
		case "PoseSetExplode":
			text = "E";
			break;
		case "PoseSetDisc":
			text = "d";
			break;
		case "PoseSetSpawnPillar":
			text = "p";
			maxMoveTime = postStructureTime;
			break;
		case "PoseSetBall":
			text = "b";
			maxMoveTime = postStructureTime;
			break;
		case "PoseSetWall_Grounded":
			text = "w";
			maxMoveTime = postStructureTime;
			break;
		case "PoseSetSpawnCube":
			text = "c";
			maxMoveTime = postStructureTime;
			break;
		default:
			text = "R";
			maxMoveTime = postMovementTime;
			break;
		}
		return text;
	}

	private static string getShiftStones()
	{
		PlayerShiftStoneSystem component = ((Component)((Component)Managers.GetPlayerManager().localPlayer.Controller).transform.GetChild(10)).GetComponent<PlayerShiftStoneSystem>();
		string stoneName = ((Il2CppArrayBase<ShiftstoneSocket>)(object)component.shiftStoneSockets)[0].assignedShiftstone.StoneName;
		string stoneName2 = ((Il2CppArrayBase<ShiftstoneSocket>)(object)component.shiftStoneSockets)[1].assignedShiftstone.StoneName;
		bool flag = stoneName == "Flow Stone" || stoneName2 == "Flow Stone";
		bool flag2 = stoneName == "Charge Stone" || stoneName2 == "Charge Stone";
		bool flag3 = stoneName == "Stubborn Stone" || stoneName2 == "Stubborn Stone";
		bool flag4 = stoneName == "Volatile Stone" || stoneName2 == "Volatile Stone";
		string text = "";
		if (comboString.Contains("JD") || (comboString.Contains("JJ") && flag))
		{
			text += "F";
		}
		if (comboString.Contains("H") && flag2)
		{
			text += "C";
		}
		if ((comboString.Contains("D") || comboString.Contains("J")) && flag3)
		{
			text += "S";
		}
		if (comboString.Contains("E") && flag4)
		{
			text += "V";
		}
		return text;
	}

	private static string getExpectedText(string inputCombo, bool useShiftstones)
	{
		string text = "";
		text += inputCombo;
		if (useShiftstones)
		{
			string shiftStones = getShiftStones();
			string text2 = ((shiftStones == "") ? "" : "/ ");
			text = shiftStones + text2 + inputCombo;
		}
		return text;
	}

	private static void moveDetected(string moveName)
	{
		moveTimer = 0;
		if (stillDisplayingText && !recording)
		{
			interruptedCombo = true;
		}
		comboString += moveName;
		if (init && comboString != "" && ((!recording && alwaysDisplayText) || recording))
		{
			((TMP_Text)text1Text).text = getExpectedText(comboString, displayShiftstonesOnText);
		}
	}
}