Decompiled source of PoseLogger v2.0.0

Mods/PoseLogger.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.MoveSystem;
using Il2CppRUMBLE.Utilities;
using Il2CppTMPro;
using MelonLoader;
using PoseLogger;
using RumbleModUI;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(PoseLoggerClass), "PoseLogger", "2.0.0", "Baumritter", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: MelonColor(200, 0, 200, 0)]
[assembly: MelonAuthorColor(200, 0, 200, 0)]
[assembly: AssemblyTitle("PoseLogger")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PoseLogger")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7563b7ca-ebe1-428e-8669-99f62cbf56ab")]
[assembly: AssemblyFileVersion("2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace PoseLogger;

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

	public const string ModVersion = "2.0.0";

	public const string Description = "Logs Poses";

	public const string Author = "Baumritter";

	public const string Company = "";
}
public static class Globals
{
	internal enum StackType
	{
		Structure,
		Modifier,
		Movement
	}

	internal static Dictionary<string, string> stackDict = new Dictionary<string, string>
	{
		{ "Explode", "Explode" },
		{ "Flick", "Flick" },
		{ "HoldRight", "Hold" },
		{ "Parry", "Parry" },
		{ "HoldLeft", "Hold" },
		{ "RockSlide", "Dash" },
		{ "SpawnCube", "Cube" },
		{ "Uppercut", "Uppercut" },
		{ "SpawnWall", "Wall" },
		{ "Jump", "Jump" },
		{ "Kick", "Kick" },
		{ "SpawnBall", "Ball" },
		{ "Stomp", "Stomp" },
		{ "Disc", "Disc" },
		{ "SpawnPillar", "Pillar" },
		{ "Straight", "Straight" }
	};

	internal static Dictionary<string, StackType> typeDict = new Dictionary<string, StackType>
	{
		{
			"Straight",
			StackType.Modifier
		},
		{
			"Explode",
			StackType.Modifier
		},
		{
			"Flick",
			StackType.Modifier
		},
		{
			"Hold",
			StackType.Modifier
		},
		{
			"Parry",
			StackType.Modifier
		},
		{
			"Uppercut",
			StackType.Modifier
		},
		{
			"Kick",
			StackType.Modifier
		},
		{
			"Stomp",
			StackType.Modifier
		},
		{
			"Disc",
			StackType.Structure
		},
		{
			"Ball",
			StackType.Structure
		},
		{
			"Cube",
			StackType.Structure
		},
		{
			"Wall",
			StackType.Structure
		},
		{
			"Pillar",
			StackType.Structure
		},
		{
			"Jump",
			StackType.Movement
		},
		{
			"Dash",
			StackType.Movement
		}
	};

	internal static Dictionary<string, string> structDict = new Dictionary<string, string>
	{
		{ "Disc", "Disc" },
		{ "SmallRock", "Rock" },
		{ "Ball", "Ball" },
		{ "Pillar", "Pillar" },
		{ "RockCube", "Cube" },
		{ "Wall", "Wall" },
		{ "LargeRock", "Boulder" },
		{ "BoulderBall", "BallToy" }
	};
}
public class StackData
{
	public string StackName;

	public DateTime TimeStamp;

	public int ProcessorID;

	public bool HitSomething;

	public string TargetIdentifier;

	public string LeftString;

	public string RightString;

	public void TargetIdentification(ProcessableComponent Target)
	{
		if ((Object)(object)Target == (Object)null)
		{
			TargetIdentifier = "";
		}
		string name = ((Object)Target).name;
		if (!((Object)((Component)Target).gameObject.transform.parent).name.Contains("Pool"))
		{
			if (Globals.structDict.ContainsKey(((Object)Target).name))
			{
				TargetIdentifier = Globals.structDict[((Object)Target).name];
			}
			else
			{
				TargetIdentifier = ((Object)Target).name;
			}
		}
		else
		{
			TargetIdentifier = Globals.structDict[((Object)Target).name] + "#" + ((Component)Target).gameObject.transform.GetSiblingIndex();
		}
	}

	public override string ToString()
	{
		return $"ProcessorID: {ProcessorID} StackName: {StackName} TimeStamp: {TimeStamp} HitSomething: {HitSomething} Target: {TargetIdentifier}";
	}
}
public class PoseLoggerClass : MelonMod
{
	[HarmonyPatch(typeof(PlayerStackProcessor), "Execute", new Type[]
	{
		typeof(Stack),
		typeof(StackConfiguration)
	})]
	public static class ExecutePatch
	{
		private static void Prefix(Stack stack, StackConfiguration overrideConfig)
		{
			if (AllowTracking)
			{
				temp = new StackData
				{
					StackName = Globals.stackDict[stack.cachedName],
					HitSomething = false,
					TimeStamp = DateTime.Now
				};
			}
		}
	}

	[HarmonyPatch(typeof(PlayerStackProcessor), "OnStackExecutionStarted", new Type[] { typeof(StackConfiguration) })]
	public static class OnStackExecutePatch
	{
		private static void Postfix(StackConfiguration config)
		{
			try
			{
				if (AllowTracking && ((bool)((ModSetting)LogAllPlayers).SavedValue || config.CastingPlayerActorNo == Singleton<PlayerManager>.instance.localPlayer.Data.GeneralData.ActorNo))
				{
					if ((double)((ModSetting)AutoClear).SavedValue != 0.0 && lastMoveTime.AddSeconds((double)((ModSetting)AutoClear).SavedValue) < DateTime.Now)
					{
						WriteToFile(ForceWrite: true);
						File.AppendAllText(FolderString, Environment.NewLine);
						moveList.Clear();
						delayList.Clear();
						dataList.Clear();
						moveList.Fill(20);
						delayList.Fill(20);
						dataList.Add(new StackData
						{
							ProcessorID = 99,
							StackName = "Filler",
							TimeStamp = DateTime.Now
						});
						ComboActive = false;
					}
					dataList.Insert(0, new StackData
					{
						StackName = temp.StackName,
						ProcessorID = config.CastingPlayerActorNo,
						TimeStamp = temp.TimeStamp,
						HitSomething = true,
						TargetIdentifier = ""
					});
					if (Globals.typeDict[dataList[0].StackName] == Globals.StackType.Modifier)
					{
						dataList[0].TargetIdentification(((Il2CppObjectBase)config.TargetProcessable).TryCast<ProcessableComponent>());
					}
					ComboTracker();
					if (dataList.Count > dataListLength)
					{
						dataList.RemoveAt(dataList.Count - 1);
					}
					string text = "";
					if ((bool)((ModSetting)LogAllPlayers).SavedValue && config.CastingPlayerActorNo != -1)
					{
						text = text + "P" + config.CastingPlayerActorNo + ": ";
					}
					TimeSpan input;
					switch (ComboLength)
					{
					case 2:
						text = text + dataList[1].StackName + ">" + dataList[0].StackName;
						input = ((dataList.Count != 2) ? (dataList[0].TimeStamp - dataList[2].TimeStamp) : TimeSpan.Zero);
						break;
					case 3:
						text = text + dataList[2].StackName + ">" + dataList[1].StackName + ">" + dataList[0].StackName;
						input = ((dataList.Count != 3) ? (dataList[0].TimeStamp - dataList[3].TimeStamp) : TimeSpan.Zero);
						break;
					case 4:
						text = text + dataList[3].StackName + ">" + dataList[2].StackName + ">" + dataList[1].StackName + ">" + dataList[0].StackName;
						input = ((dataList.Count != 4) ? (dataList[0].TimeStamp - dataList[4].TimeStamp) : TimeSpan.Zero);
						break;
					case 5:
						text = text + dataList[4].StackName + ">" + dataList[3].StackName + ">" + dataList[2].StackName + ">" + dataList[1].StackName + ">" + dataList[0].StackName;
						input = ((dataList.Count != 5) ? (dataList[0].TimeStamp - dataList[5].TimeStamp) : TimeSpan.Zero);
						break;
					default:
						text += dataList[0].StackName;
						input = ((dataList.Count != 1) ? (dataList[0].TimeStamp - dataList[1].TimeStamp) : TimeSpan.Zero);
						break;
					}
					if (dataList[0].TargetIdentifier != "")
					{
						text = text + " on " + dataList[0].TargetIdentifier;
					}
					WriteToFile(ForceWrite: false);
					if (input.TotalMilliseconds > 9999.0)
					{
						input = new TimeSpan(99990000L);
					}
					if (ComboActive)
					{
						moveList[0] = text;
						delayList[0] = MsFormatting(input);
					}
					else
					{
						moveList.AddAtStart(text, 20);
						delayList.AddAtStart(MsFormatting(input), 20);
					}
					ApplyToBoardandOnScreen();
					lastMoveTime = DateTime.Now;
				}
			}
			catch (Exception ex)
			{
				File.AppendAllText(folderHandler.GetFolderString("", false) + "\\Error.txt", ex.Message + Environment.NewLine);
			}
		}
	}

	private Vector3 Howard_BoardMainPosition = new Vector3(-2.615f, -3.52f, -19.05f);

	private Vector3 Howard_BoardMainRotation = new Vector3(0f, 250f, 0f);

	private Vector3 Training_BoardMainPosition = new Vector3(-42.0299f, 3.194f, -1.0598f);

	private Vector3 Training_BoardMainRotation = new Vector3(0f, 250f, 0f);

	private Vector3 Park_BoardMainPosition = new Vector3(-5.9f, -5.9f, -10f);

	private Vector3 Park_BoardMainRotation = new Vector3(0f, 196f, 0f);

	private static List<StackData> dataList = new List<StackData>();

	private static StackData temp = new StackData();

	private static List<string> moveList = new List<string>();

	private static List<string> delayList = new List<string>();

	private static bool AllowTracking = false;

	private static int dataListLength = 6;

	private static DateTime lastMoveTime = DateTime.Now;

	private static bool ComboActive;

	private static int ComboLength;

	private static DateTime ComboStartTime;

	private static DateTime ComboMoveTime;

	private static string ComboDelayString;

	private static GameObject OnScreenTracker;

	private static List<DisplayBoard> boards = new List<DisplayBoard>();

	private static string FolderString;

	private Mod Mod = new Mod();

	private static ModSetting<bool> OnScreenLog;

	private static ModSetting<bool> BoardLog;

	private static ModSetting<bool> LogToFile;

	private static ModSetting<bool> LogAllPlayers;

	private static ModSetting<double> AutoClear;

	private static ModSetting<double> ComboTimer;

	private static ModSetting<int> LogFileAmount;

	private Delay LoadDelay = new Delay();

	private static Folders folderHandler = new Folders();

	private string currentScene;

	private void CreateOnScreenLogger()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		//IL_042d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		GameObject[] array = (GameObject[])(object)new GameObject[20];
		GameObject[] array2 = (GameObject[])(object)new GameObject[20];
		GameObject val = GameObject.Find("Game Instance/UI/LegacyRecordingCameraUI/Panel");
		GameObject val2 = new GameObject();
		float num = 16f;
		OnScreenTracker = Object.Instantiate<GameObject>(val);
		OnScreenTracker.SetActive(false);
		((Object)OnScreenTracker).name = "OnScreenLogger";
		OnScreenTracker.transform.SetParent(GameObject.Find("Game Instance/UI").transform);
		OnScreenTracker.transform.position = new Vector3(220f, 790f, 0f);
		OnScreenTracker.transform.localScale = new Vector3(1.041625f, 1.25f, 0f);
		((Graphic)OnScreenTracker.GetComponent<Image>()).color = new Color(0.2f, 0.2f, 0.2f, 0.8f);
		for (int i = 0; i < OnScreenTracker.transform.childCount; i++)
		{
			Object.Destroy((Object)(object)((Component)OnScreenTracker.transform.GetChild(i)).gameObject);
		}
		for (int j = 0; j < array.Length; j++)
		{
			array[j] = Object.Instantiate<GameObject>(val2);
			array[j].gameObject.AddComponent<TextMeshProUGUI>();
			array[j].transform.SetParent(OnScreenTracker.transform);
			if (j == 0)
			{
				((Object)array[j]).name = "Line_Head";
				array[j].transform.localPosition = new Vector3(-35f, 160f, 0f);
				((Component)array[j].transform).GetComponent<RectTransform>().sizeDelta = new Vector2(520f, 28f);
				((TMP_Text)((Component)array[j].transform).GetComponent<TextMeshProUGUI>()).text = "Move Tracker";
				((TMP_Text)((Component)array[j].transform).GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)514;
			}
			else
			{
				((Object)array[j]).name = "Line" + j;
				array[j].transform.localPosition = new Vector3(-35f, 150f + num - num * (float)(j + 1), 0f);
				((Component)array[j].transform).GetComponent<RectTransform>().sizeDelta = new Vector2(520f, 28f);
				((TMP_Text)((Component)array[j].transform).GetComponent<TextMeshProUGUI>()).text = "";
				((TMP_Text)((Component)array[j].transform).GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)513;
			}
			array[j].transform.localScale = new Vector3(0.6f, 0.5f, 1f);
			((TMP_Text)((Component)array[j].transform).GetComponent<TextMeshProUGUI>()).fontSize = 24f;
			((TMP_Text)((Component)array[j].transform).GetComponent<TextMeshProUGUI>()).autoSizeTextContainer = false;
		}
		for (int k = 0; k < array2.Length; k++)
		{
			array2[k] = Object.Instantiate<GameObject>(val2);
			array2[k].gameObject.AddComponent<TextMeshProUGUI>();
			array2[k].transform.SetParent(OnScreenTracker.transform);
			if (k == 0)
			{
				((Object)array2[k]).name = "Delay_Head";
				array2[k].transform.localPosition = new Vector3(135f, 160f, 0f);
				((TMP_Text)((Component)array2[k].transform).GetComponent<TextMeshProUGUI>()).text = "Time since last";
			}
			else
			{
				((Object)array2[k]).name = "Delay" + k;
				array2[k].transform.localPosition = new Vector3(135f, 150f + num - num * (float)(k + 1), 0f);
				((TMP_Text)((Component)array2[k].transform).GetComponent<TextMeshProUGUI>()).text = "";
			}
			((TMP_Text)((Component)array2[k].transform).GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)516;
			((Component)array2[k].transform).GetComponent<RectTransform>().sizeDelta = new Vector2(170f, 28f);
			array2[k].transform.localScale = new Vector3(0.6f, 0.5f, 1f);
			((TMP_Text)((Component)array2[k].transform).GetComponent<TextMeshProUGUI>()).fontSize = 24f;
			((TMP_Text)((Component)array2[k].transform).GetComponent<TextMeshProUGUI>()).autoSizeTextContainer = false;
		}
		Object.Destroy((Object)(object)val2);
	}

	private static void ComboTracker()
	{
		if (dataList.Count <= 1)
		{
			return;
		}
		TimeSpan timeSpan = dataList[0].TimeStamp - ComboStartTime;
		if (dataList[0].TargetIdentifier == dataList[1].TargetIdentifier && timeSpan.TotalMilliseconds <= (double)((ModSetting)ComboTimer).SavedValue * 1000.0)
		{
			if (ComboMoveTime == ComboStartTime)
			{
				TimeSpan input = dataList[0].TimeStamp - ComboStartTime;
				ComboDelayString = MsFormatting(input);
			}
			else
			{
				TimeSpan input = dataList[0].TimeStamp - ComboMoveTime;
				ComboDelayString = ComboDelayString + " > " + MsFormatting(input);
			}
			ComboMoveTime = dataList[0].TimeStamp;
			string stackName = dataList[1].StackName;
			string text = stackName;
			if (!(text == "Straight"))
			{
				if (text == "Struppercut")
				{
					if (dataList[0].StackName == "Kick")
					{
						dataList[1].StackName = "Strupperkick";
						dataList.RemoveAt(0);
					}
				}
				else
				{
					ComboLength++;
				}
			}
			else
			{
				if (dataList[0].StackName == "Uppercut")
				{
					dataList[1].StackName = "Struppercut";
					dataList.RemoveAt(0);
				}
				if (dataList[0].StackName == "Kick")
				{
					dataList[1].StackName = "Hop";
					dataList.RemoveAt(0);
				}
			}
			ComboActive = true;
			if (ComboLength >= 5)
			{
				ComboLength = 5;
			}
		}
		else
		{
			ComboActive = false;
			ComboLength = 1;
			ComboStartTime = dataList[0].TimeStamp;
			ComboMoveTime = dataList[0].TimeStamp;
		}
	}

	private static void ApplyToBoardandOnScreen()
	{
		if ((bool)((ModSetting)OnScreenLog).SavedValue)
		{
			for (int i = 0; i < moveList.Count - 1; i++)
			{
				((TMP_Text)((Component)OnScreenTracker.transform.GetChild(i + 1)).GetComponent<TextMeshProUGUI>()).text = moveList[i];
				((TMP_Text)((Component)OnScreenTracker.transform.GetChild(i + 21)).GetComponent<TextMeshProUGUI>()).text = delayList[i];
			}
		}
		if (!(bool)((ModSetting)BoardLog).SavedValue)
		{
			return;
		}
		foreach (DisplayBoard board in boards)
		{
			board.SetAllTextOnBoard(moveList, delayList);
		}
	}

	private static void WriteToFile(bool ForceWrite)
	{
		if ((bool)((ModSetting)LogToFile).SavedValue && (!ComboActive || ForceWrite) && moveList[0] != "" && delayList[0] != "")
		{
			File.AppendAllText(FolderString, delayList[0].Pad(StringExtension.PaddingMode.Left, 15) + "   " + moveList[0].Pad(StringExtension.PaddingMode.Right, 60) + "   " + ComboDelayString + Environment.NewLine);
			ComboDelayString = "";
		}
	}

	private void CreateFileName()
	{
		FolderString = folderHandler.GetFolderString("Logs", false) + "\\MoveLog_" + DateTime.Now.ToString("yy-MM-dd_hh-mm") + ".txt";
		File.AppendAllText(FolderString, "Time since last".Pad(StringExtension.PaddingMode.Left, 15) + "   " + "Move Info".Pad(StringExtension.PaddingMode.Right, 60) + "   Time between Combo Moves" + Environment.NewLine);
	}

	private static string MsFormatting(TimeSpan input)
	{
		string text = input.TotalMilliseconds.ToString("####") + "ms";
		if (text == "ms")
		{
			return "0ms";
		}
		return text;
	}

	public override void OnLateInitializeMelon()
	{
		((MelonBase)this).OnLateInitializeMelon();
		UI.instance.UI_Initialized += OnUIInit;
		LoadHandler.PlayerLoaded += WaitAfterInit;
		folderHandler.SetModFolderCustom("PoseLogger");
		folderHandler.AddSubFolder("Logs");
		folderHandler.CheckAllFoldersExist();
		CreateFileName();
		dataList.Add(new StackData
		{
			ProcessorID = 99,
			StackName = "Filler",
			TimeStamp = DateTime.Now
		});
		moveList.Fill(20);
		delayList.Fill(20);
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		((MelonMod)this).OnSceneWasLoaded(buildIndex, sceneName);
		currentScene = sceneName;
		AllowTracking = false;
	}

	public override void OnFixedUpdate()
	{
		((MelonBase)this).OnFixedUpdate();
		if (currentScene == "Gym" && (Object)(object)BoardRef.Reference == (Object)null)
		{
			BoardRef.InitBoardRef();
		}
	}

	public override void OnApplicationQuit()
	{
		((MelonBase)this).OnApplicationQuit();
		if ((double)((ModSetting)AutoClear).SavedValue != 0.0 && lastMoveTime.AddSeconds((double)((ModSetting)AutoClear).SavedValue) < DateTime.Now)
		{
			WriteToFile(ForceWrite: true);
			File.AppendAllText(FolderString, Environment.NewLine + "--- End of Log ---" + Environment.NewLine);
		}
	}

	private void OnUIInit()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Expected O, but got Unknown
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Expected O, but got Unknown
		Mod.ModName = "PoseLogger";
		Mod.ModVersion = "2.0.0";
		Mod.SetFolder("PoseLogger");
		Mod.SetSubFolder("Settings");
		Mod.AddDescription("Description", "", "Logs Poses", new Tags
		{
			IsSummary = true
		});
		LogAllPlayers = Mod.AddToList("Log all Players", false, 0, "Logs moves from all players.", new Tags());
		ComboTimer = Mod.AddToList("Combo Timer", 1.0, "Timeframe in which moves are considered a combo in seconds" + Environment.NewLine + "Limit: 0.1 - 1.0", new Tags());
		AutoClear = Mod.AddToList("Auto Reset Buffer", 5.0, "Time after which the move buffer is automatically cleared." + Environment.NewLine + "Will trigger after the time has elapsed upon next move execution." + Environment.NewLine + "0 = Disabled", new Tags());
		OnScreenLog = Mod.AddToList("Toggle OnScreen Log", true, 0, "Shows the log window in the top left corner.", new Tags());
		BoardLog = Mod.AddToList("Toggle Board Log", true, 0, "Enables the physical boards in the Gym/Park.", new Tags());
		LogToFile = Mod.AddToList("Log to File", true, 0, "Enables the Output to a log file.", new Tags());
		LogFileAmount = Mod.AddToList("Log File Maximum", 20, "Sets a limit to the amount of log files created.", new Tags());
		Mod.GetFromFile();
		if ((double)((ModSetting)ComboTimer).SavedValue > 1.0)
		{
			((ModSetting)ComboTimer).SavedValue = 1.0;
		}
		if ((double)((ModSetting)ComboTimer).SavedValue < 0.1)
		{
			((ModSetting)ComboTimer).SavedValue = 0.1;
		}
		Mod.ModSaved += OnSaveOrInit;
		UI.instance.AddMod(Mod);
		if ((int)((ModSetting)LogFileAmount).SavedValue <= 0)
		{
			((ModSetting)LogFileAmount).SavedValue = 20;
			MelonLogger.Error("Set the Log File Maximum to a positive integer");
		}
		string[] files = Directory.GetFiles(folderHandler.GetFolderString("Logs", false));
		if (files.Length > (int)((ModSetting)LogFileAmount).SavedValue)
		{
			int num = files.Length - (int)((ModSetting)LogFileAmount).SavedValue;
			for (int i = 0; i < num; i++)
			{
				File.Delete(files[i]);
			}
		}
		MelonLoggerExtension.Log("Added Mod.");
	}

	private void WaitAfterInit()
	{
		LoadDelay.Start(2.0, false, (Action)delegate
		{
			OnSaveOrInit();
		});
	}

	private void OnSaveOrInit()
	{
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		if ((double)((ModSetting)ComboTimer).SavedValue > 1.0)
		{
			((ModSetting)ComboTimer).SavedValue = 1.0;
		}
		if ((double)((ModSetting)ComboTimer).SavedValue < 0.1)
		{
			((ModSetting)ComboTimer).SavedValue = 0.1;
		}
		if ((Object)(object)OnScreenTracker == (Object)null)
		{
			CreateOnScreenLogger();
		}
		if (currentScene == "Gym" || currentScene == "Park")
		{
			OnScreenTracker.SetActive((bool)((ModSetting)OnScreenLog).SavedValue);
			if (boards.Count > 0)
			{
				foreach (DisplayBoard board in boards)
				{
					Object.Destroy((Object)(object)board.Board);
				}
			}
			if ((bool)((ModSetting)BoardLog).SavedValue)
			{
				string text = currentScene;
				string text2 = text;
				if (!(text2 == "Gym"))
				{
					if (text2 == "Park")
					{
						boards.Clear();
						boards.Add(new DisplayBoard());
						boards[0].Init("ParkBoard", Park_BoardMainPosition, Park_BoardMainRotation);
					}
				}
				else
				{
					boards.Clear();
					boards.Add(new DisplayBoard());
					boards.Add(new DisplayBoard());
					boards[0].Init("HowardBoard", Howard_BoardMainPosition, Howard_BoardMainRotation);
					boards[1].Init("RingBoard", Training_BoardMainPosition, Training_BoardMainRotation);
				}
			}
			if (!(bool)((ModSetting)BoardLog).SavedValue && !(bool)((ModSetting)OnScreenLog).SavedValue)
			{
				AllowTracking = false;
			}
			else
			{
				AllowTracking = true;
			}
		}
		else
		{
			AllowTracking = false;
			OnScreenTracker.gameObject.SetActive(false);
		}
	}
}
public static class BoardRef
{
	private static bool debug;

	public static GameObject Reference;

	public static GameObject GetBoard()
	{
		if ((Object)(object)Reference != (Object)null)
		{
			return Reference;
		}
		InitBoardRef();
		return Reference;
	}

	public static void InitBoardRef()
	{
		//IL_00e3: 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_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Expected O, but got Unknown
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Reference != (Object)null)
		{
			return;
		}
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(0f, 50f, 0f);
		Vector3 eulerAngles = default(Vector3);
		((Vector3)(ref eulerAngles))..ctor(0f, 0f, 0f);
		Vector3 localPosition = default(Vector3);
		((Vector3)(ref localPosition))..ctor(0f, 1.175f, 0f);
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(0.95f, 0.6f, 0.2f);
		Vector3 localPosition2 = default(Vector3);
		((Vector3)(ref localPosition2))..ctor(0f, 0.1f, -0.25f);
		Vector3 localPosition3 = default(Vector3);
		((Vector3)(ref localPosition3))..ctor(0f, -0.1f, -0.25f);
		GameObject val2 = GameObject.Find("--------------LOGIC--------------/Heinhouser products/Leaderboard/Frame");
		if (debug)
		{
			MelonLogger.Msg("Board Object get");
		}
		GameObject val3 = Object.Instantiate<GameObject>(val2);
		if (debug)
		{
			MelonLogger.Msg("Board Object instantiate");
		}
		val3.transform.position = position;
		val3.transform.eulerAngles = eulerAngles;
		if (debug)
		{
			MelonLogger.Msg("Position changed");
		}
		((Object)val3).name = "Template";
		((Object)val3.transform.GetChild(0)).name = "TopLog";
		((Object)val3.transform.GetChild(2)).name = "FootLeft";
		((Object)val3.transform.GetChild(3)).name = "FootRight";
		((Object)val3.transform.GetChild(4)).name = "LogLeft";
		((Object)val3.transform.GetChild(5)).name = "LogRight";
		((Object)val3.transform.GetChild(6)).name = "InnerWall";
		((Object)val3.transform.GetChild(11)).name = "LogBigTop";
		((Object)val3.transform.GetChild(12)).name = "BackPlane";
		if (debug)
		{
			MelonLogger.Msg("Objects renamed");
		}
		val3.transform.GetChild(6).localPosition = localPosition;
		val3.transform.GetChild(6).localScale = val;
		if (debug)
		{
			MelonLogger.Msg("Frame resized");
		}
		val2 = GameObject.Find("--------------LOGIC--------------/Heinhouser products/Leaderboard/Text Objects/Titleplate/Leaderboard");
		if (debug)
		{
			MelonLogger.Msg("Sample Text Object get");
		}
		for (int i = 0; i < 4; i++)
		{
			GameObject val4 = new GameObject
			{
				name = "Text" + i
			};
			val4.transform.SetParent(val3.transform.GetChild(6));
			if (debug)
			{
				MelonLogger.Msg("Text Object " + i + " created");
			}
			if (i <= 1)
			{
				val4.transform.localPosition = localPosition2;
			}
			else
			{
				val4.transform.localPosition = localPosition3;
			}
			val4.transform.localScale.InvertAndSet(val);
			val4.transform.eulerAngles = eulerAngles;
			val4.AddComponent<TextMeshPro>();
			((Component)val4.transform).GetComponent<RectTransform>().sizeDelta = new Vector2(1f, 1f);
			if (debug)
			{
				MelonLogger.Msg("Text created and transformed");
			}
			((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).fontSize = 0.6f;
			((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).font = ((TMP_Text)val2.GetComponent<TextMeshPro>()).font;
			((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).fontMaterial = ((TMP_Text)val2.GetComponent<TextMeshPro>()).fontMaterial;
			switch (i)
			{
			case 0:
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).alignment = (TextAlignmentOptions)257;
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).text = "Move Tracker";
				break;
			case 1:
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).alignment = (TextAlignmentOptions)260;
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).text = "Time since last";
				break;
			case 2:
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).alignment = (TextAlignmentOptions)1025;
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).text = "This is a text";
				break;
			case 3:
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).alignment = (TextAlignmentOptions)1028;
				((TMP_Text)((Component)val4.transform).GetComponent<TextMeshPro>()).text = "This is a text";
				break;
			}
			if (debug)
			{
				MelonLogger.Msg("Text Object " + i + " set");
			}
		}
		Object.Destroy((Object)(object)((Component)val3.transform.GetChild(1)).gameObject);
		Object.Destroy((Object)(object)((Component)val3.transform.GetChild(7)).gameObject);
		Object.Destroy((Object)(object)((Component)val3.transform.GetChild(8)).gameObject);
		Object.Destroy((Object)(object)((Component)val3.transform.GetChild(9)).gameObject);
		Object.Destroy((Object)(object)((Component)val3.transform.GetChild(10)).gameObject);
		if (debug)
		{
			MelonLogger.Msg("Children destroyed");
		}
		Object.DontDestroyOnLoad((Object)(object)val3.transform);
		Reference = val3;
		Reference.gameObject.SetActive(false);
	}
}
public class DisplayBoard
{
	public enum TextFields
	{
		Head_Left,
		Head_Right,
		Body_Left,
		Body_Right
	}

	private bool debug = false;

	public string LeftHeader = "Pose/Structure Tracker";

	public string RightHeader = "Time since last";

	public GameObject Board;

	public TextMeshPro HeaderLeft;

	public TextMeshPro HeaderRight;

	public TextMeshPro BodyLeft;

	public TextMeshPro BodyRight;

	public void Init(string Name, Vector3 BoardMainPosition, Vector3 BoardMainRotation)
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Board != (Object)null))
		{
			Board = Object.Instantiate<GameObject>(BoardRef.GetBoard());
			((Object)Board).name = Name;
			Board.transform.position = BoardMainPosition;
			Board.transform.eulerAngles = BoardMainRotation;
			HeaderLeft = ((Component)Board.transform.GetChild(5).GetChild(0)).GetComponent<TextMeshPro>();
			HeaderRight = ((Component)Board.transform.GetChild(5).GetChild(1)).GetComponent<TextMeshPro>();
			BodyLeft = ((Component)Board.transform.GetChild(5).GetChild(2)).GetComponent<TextMeshPro>();
			BodyRight = ((Component)Board.transform.GetChild(5).GetChild(3)).GetComponent<TextMeshPro>();
			Board.gameObject.SetActive(true);
			if (debug)
			{
				MelonLogger.Msg("Board initialized.");
			}
		}
	}

	public void SetAllTextOnBoard(List<string> LeftBuffer, List<string> RightBuffer)
	{
		SetTextOnBoard(TextFields.Head_Left, LeftHeader);
		SetTextOnBoard(TextFields.Head_Right, RightHeader);
		string text = "";
		string text2 = "";
		for (int i = 0; i < 17; i++)
		{
			text += LeftBuffer[i];
			text2 += RightBuffer[i];
			if (i != 16)
			{
				text += Environment.NewLine;
				text2 += Environment.NewLine;
			}
		}
		SetTextOnBoard(TextFields.Body_Left, text);
		SetTextOnBoard(TextFields.Body_Right, text2);
		if (debug)
		{
			MelonLogger.Msg("Board refreshed.");
		}
	}

	public void SetTextOnBoard(TextFields Field, string Input)
	{
		switch (Field)
		{
		case TextFields.Head_Left:
			((TMP_Text)HeaderLeft).text = Input;
			break;
		case TextFields.Head_Right:
			((TMP_Text)HeaderRight).text = Input;
			break;
		case TextFields.Body_Left:
			((TMP_Text)BodyLeft).text = Input;
			break;
		case TextFields.Body_Right:
			((TMP_Text)BodyRight).text = Input;
			break;
		}
		if (debug)
		{
			MelonLogger.Msg("Text applied.");
		}
	}
}
public static class Vector3Extension
{
	public static void InvertAndSet(this Vector3 obj, Vector3 Input)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		obj.x = 1f / Input.x;
		obj.y = 1f / Input.y;
		obj.z = 1f / Input.z;
	}
}
public static class StringExtension
{
	public enum PaddingMode
	{
		Left,
		Right
	}

	public static string Pad(this string str, PaddingMode PaddingMode, int StringLength)
	{
		if (str.Length > StringLength)
		{
			throw new ArgumentException("Padding not possible: Input Length > Pad Length");
		}
		string text = "";
		int num = StringLength - str.Length;
		for (int i = 0; i < num; i++)
		{
			text += " ";
		}
		str = ((PaddingMode != 0) ? (str + text) : (text + str));
		return str;
	}
}
public static class ListExtension
{
	public static void AddAtStart(this List<string> strings, string input, int maxLength)
	{
		if (strings.Count == 0)
		{
			strings.Add(input);
		}
		else
		{
			strings.Insert(0, input);
		}
		if (strings.Count > maxLength)
		{
			strings.RemoveAt(strings.Count - 1);
		}
	}

	public static void Fill(this List<string> strings, int maxLength)
	{
		int num = maxLength - strings.Count;
		for (int i = 0; i < maxLength; i++)
		{
			strings.Add("");
		}
	}
}