Decompiled source of notationClipper v1.1.0

Mods/notationClipper.dll

Decompiled 3 months ago
using System;
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.1.0", "klibe", null)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 240, 205, 53)]
[assembly: MelonAuthorColor(255, 240, 205, 53)]
[assembly: AssemblyTitle("notationClipper")]
[assembly: AssemblyDescription("Adds your combos to your clipboard after recording them!")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[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.1.0";

	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 notationText;

	private static TextMeshPro notationTextRef;

	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 = new Color(1f, 0.8f, 0.8f);

	private static Color comboingColor = Color.white;

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

	public void OnUIInit()
	{
		Calls.onMapInitialized += setupText;
		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.1.0";
		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());
		updateModUIVariables();
		NotationClipper.ModSaved += updateModUIVariables;
		NotationClipper.GetFromFile();
		UI.instance.UI_Initialized += OnUIInit;
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		init = false;
	}

	private void setupText()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		notationText = Create.NewText("", 1f, comboingColor, new Vector3(0f, 1f, 0f), Quaternion.identity);
		((Object)notationText).name = "Combo Display";
		notationText.transform.parent = ((Component)Managers.GetPlayerManager().localPlayer.Controller).transform.GetChild(1).GetChild(0).GetChild(0);
		notationText.transform.localPosition = new Vector3(0f, 0.1f, 0.2f);
		notationText.transform.forward = ((Component)Managers.GetPlayerManager().localPlayer.Controller).transform.GetChild(1).GetChild(0).GetChild(0)
			.forward;
		notationTextRef = notationText.GetComponent<TextMeshPro>();
		((TMP_Text)notationTextRef).enableWordWrapping = false;
		((TMP_Text)notationTextRef).outlineColor = Color32.op_Implicit(Color.black);
		((TMP_Text)notationTextRef).outlineWidth = 0.1f;
		((TMP_Text)notationTextRef).fontSize = 0.3f;
		((TMP_Text)notationTextRef).alignment = (TextAlignmentOptions)514;
		init = true;
	}

	public override void OnFixedUpdate()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		if (!init)
		{
			return;
		}
		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)
			{
				notationText.transform.forward = ((Component)Managers.GetPlayerManager().localPlayer.Controller).transform.GetChild(1).GetChild(0).GetChild(0)
					.forward;
				((TMP_Text)notationTextRef).text = "";
				comboString = "";
				((TMP_Text)notationTextRef).color = recordingColor;
			}
			return;
		}
		if (!stillDisplayingText && comboString != "")
		{
			moveTimer++;
		}
		if (moveTimer >= maxMoveTime)
		{
			comboString = "";
			((TMP_Text)notationTextRef).text = "";
		}
		if (!flag)
		{
			return;
		}
		if (comboString != "")
		{
			string expectedText = getExpectedText(comboString, clipShiftstones);
			MelonLogger.Msg(expectedText + " copied to clipboard!");
			try
			{
				Clipboard.SetText(expectedText);
				((TMP_Text)notationTextRef).text = expectedText + Environment.NewLine + "copied to clipboard!";
			}
			catch
			{
				MelonLogger.Msg("Problem with copying to clipboard!");
			}
			comboString = "";
			postRecordTimer = 0;
			moveTimer = 0;
			stillDisplayingText = true;
		}
		else
		{
			((TMP_Text)notationTextRef).color = comboingColor;
		}
		if (!stillDisplayingText)
		{
			return;
		}
		postRecordTimer++;
		if (postRecordTimer > postRecordMaxTime && interruptedCombo)
		{
			stillDisplayingText = false;
			interruptedCombo = false;
			((TMP_Text)notationTextRef).color = comboingColor;
			if (!interruptedCombo)
			{
				((TMP_Text)notationTextRef).text = "";
			}
		}
	}

	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 != "" && (alwaysDisplayText || recording))
		{
			((TMP_Text)notationTextRef).text = getExpectedText(comboString, displayShiftstonesOnText);
		}
	}
}