Decompiled source of MatchInfo v2.6.1

Mods/MatchInfo.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using Il2CppPhoton.Pun;
using Il2CppPhoton.Realtime;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Utilities;
using Il2CppSystem;
using Il2CppTMPro;
using MatchInfo;
using MelonLoader;
using MelonLoader.Preferences;
using RumbleModdingAPI.RMAPI;
using UIFramework;
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(Main), "MatchInfo", "2.6.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 7, 2, true)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MatchInfo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+3f2ce6e6aab7efff5d761b1d33b082ac28d928aa")]
[assembly: AssemblyProduct("MatchInfo")]
[assembly: AssemblyTitle("MatchInfo")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MatchInfo;

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

	public const string ModVersion = "2.6.1";

	public const string Author = "UlvakSkillz";
}
public class Main : MelonMod
{
	[CompilerGenerated]
	private sealed class <MatchStarted>d__61 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Main <>4__this;

		private bool <won>5__1;

		private string <winOrLose>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MatchStarted>d__61(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<winOrLose>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			case 2:
				<>1__state = -1;
				break;
			}
			if (<>4__this.matchActive)
			{
				if (!<>4__this.ranWinLoss && Singleton<PlayerManager>.instance.AllPlayers.Count == 2 && <>4__this.MatchSlabOne.activeSelf)
				{
					<won>5__1 = false;
					<winOrLose>5__2 = "Unlocalized Entry!";
					if (Players.IsHost())
					{
						Log("Host");
						<winOrLose>5__2 = ((TMP_Text)<>4__this.Slab1Text).text;
					}
					else
					{
						Log("Client");
						<winOrLose>5__2 = ((TMP_Text)<>4__this.Slab2Text).text;
					}
					if (<winOrLose>5__2 == "Unlocalized Entry!")
					{
						<>2__current = (object)new WaitForFixedUpdate();
						<>1__state = 1;
						return true;
					}
					if (<winOrLose>5__2 == "Victory!")
					{
						Log("Win");
						<won>5__1 = true;
					}
					else
					{
						Log("Lose");
						<won>5__1 = false;
					}
					if (<won>5__1)
					{
						<>4__this.fileText[<>4__this.playerFileSpot + 1] = (int.Parse(<>4__this.fileText[<>4__this.playerFileSpot + 1]) + 1).ToString();
						((TMP_Text)player2MatchWinsComponent).text = <>4__this.fileText[<>4__this.playerFileSpot + 1] + " Wins";
					}
					else
					{
						<>4__this.fileText[<>4__this.playerFileSpot + 2] = (int.Parse(<>4__this.fileText[<>4__this.playerFileSpot + 2]) + 1).ToString();
						((TMP_Text)player1MatchWinsComponent).text = <>4__this.fileText[<>4__this.playerFileSpot + 2] + " Wins";
					}
					((TMP_Text)player2BPComponent).text = Singleton<PlayerManager>.instance.AllPlayers[0].Data.GeneralData.BattlePoints + " BP";
					((TMP_Text)player1BPComponent).text = Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.BattlePoints + " BP";
					<>4__this.ranWinLoss = true;
					File.WriteAllLines(<>4__this.FILEPATH + "\\" + <>4__this.FILENAME, <>4__this.fileText);
					<winOrLose>5__2 = null;
				}
				<>2__current = (object)new WaitForFixedUpdate();
				<>1__state = 2;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <MoveSign>d__64 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Main <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MoveSign>d__64(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(7f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (<>4__this.currentScene == "Map0")
				{
					matchInfoGameObject.transform.position = new Vector3(2.9761f, 1.2f, -19.3972f);
					matchInfoGameObject.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
				}
				else if (<>4__this.currentScene == "Map1")
				{
					matchInfoGameObject.transform.position = new Vector3(-8.9054f, 7.9409f, -9.2236f);
					matchInfoGameObject.transform.rotation = Quaternion.Euler(0f, 211.8524f, 0f);
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <OnePlayerFound>d__65 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Main <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <OnePlayerFound>d__65(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(4f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				matchInfoGameObject.SetActive(false);
				<>4__this.stopWatchingPings = true;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <StartUpdatingPings>d__62 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Main <>4__this;

		private PhotonView <pvLocal>5__1;

		private PhotonView <pvRemote>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <StartUpdatingPings>d__62(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<pvLocal>5__1 = null;
			<pvRemote>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<pvLocal>5__1 = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.GetComponent<PhotonView>();
				<pvRemote>5__2 = ((Singleton<PlayerManager>.instance.AllPlayers.Count > 1) ? ((Component)Singleton<PlayerManager>.instance.AllPlayers[1].Controller).gameObject.GetComponent<PhotonView>() : null);
				<>4__this.stopWatchingPings = false;
				<>4__this.lastLocalPingDifference = 0;
				<>4__this.lastRemotePingDifference = 0;
				<>4__this.lastLocalPing = 0;
				<>4__this.lastRemotePing = 0;
				<>4__this.localPing = 0;
				<>4__this.remotePing = 0;
				<>4__this.lastLocalPingDifferenceTime = DateTime.Now;
				<>4__this.lastRemotePingDifferenceTime = DateTime.Now;
				break;
			case 1:
				<>1__state = -1;
				break;
			case 2:
				<>1__state = -1;
				break;
			}
			if (!<>4__this.stopWatchingPings)
			{
				if ((Object)(object)<pvLocal>5__1 == (Object)null)
				{
					<pvLocal>5__1 = ((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.GetComponent<PhotonView>();
					if ((Object)(object)<pvLocal>5__1 == (Object)null)
					{
						<>2__current = (object)new WaitForFixedUpdate();
						<>1__state = 1;
						return true;
					}
				}
				if (DateTime.Now >= <>4__this.lastLocalPingDifferenceTime.AddSeconds(1.0))
				{
					<>4__this.lastLocalPingDifference = 0;
					<>4__this.lastLocalPingDifferenceTime = DateTime.Now;
				}
				if (DateTime.Now >= <>4__this.lastRemotePingDifferenceTime.AddSeconds(1.0))
				{
					<>4__this.lastRemotePingDifference = 0;
					<>4__this.lastRemotePingDifferenceTime = DateTime.Now;
				}
				if (<>4__this.lastLocalPing != <>4__this.localPing)
				{
					<>4__this.lastLocalPingDifference = <>4__this.lastLocalPing - <>4__this.localPing;
					<>4__this.lastLocalPingDifferenceTime = DateTime.Now;
				}
				if (<>4__this.lastRemotePing != <>4__this.remotePing)
				{
					<>4__this.lastRemotePingDifference = <>4__this.lastRemotePing - <>4__this.remotePing;
					<>4__this.lastRemotePingDifferenceTime = DateTime.Now;
				}
				<>4__this.lastLocalPing = <>4__this.localPing;
				<>4__this.lastRemotePing = <>4__this.remotePing;
				Main main = <>4__this;
				int localPing;
				if (<pvLocal>5__1.Controller != null)
				{
					Main main2 = <>4__this;
					PhotonView obj = <pvLocal>5__1;
					object str;
					if (obj == null)
					{
						str = null;
					}
					else
					{
						Player controller = obj.Controller;
						str = ((controller != null) ? ((Object)controller.CustomProperties).ToString() : null);
					}
					localPing = main2.GetPingFromString((string)str);
				}
				else
				{
					localPing = 0;
				}
				main.localPing = localPing;
				if (Preferences.PrefShowMatchIndividualPingVisual.Value == PingVisualType.Ping)
				{
					((TMP_Text)player2PingComponent).text = <>4__this.localPing + " ms";
				}
				else if (Preferences.PrefShowMatchIndividualPingVisual.Value == PingVisualType.PingTickDifference)
				{
					((TMP_Text)player2PingComponent).text = <>4__this.lastLocalPingDifference + " ms";
				}
				if ((Object)(object)<pvRemote>5__2 == (Object)null && Singleton<PlayerManager>.instance.AllPlayers.Count > 1)
				{
					<pvRemote>5__2 = ((Component)Singleton<PlayerManager>.instance.AllPlayers[1].Controller).gameObject.GetComponent<PhotonView>();
				}
				Main main3 = <>4__this;
				int remotePing;
				if (Singleton<PlayerManager>.instance.AllPlayers.Count <= 1)
				{
					remotePing = 0;
				}
				else if (!((Object)(object)<pvRemote>5__2 == (Object)null))
				{
					Main main4 = <>4__this;
					PhotonView obj2 = <pvRemote>5__2;
					object str2;
					if (obj2 == null)
					{
						str2 = null;
					}
					else
					{
						Player controller2 = obj2.Controller;
						str2 = ((controller2 != null) ? ((Object)controller2.CustomProperties).ToString() : null);
					}
					remotePing = main4.GetPingFromString((string)str2);
				}
				else
				{
					remotePing = 0;
				}
				main3.remotePing = remotePing;
				if (Preferences.PrefShowMatchIndividualPingVisual.Value == PingVisualType.Ping)
				{
					((TMP_Text)player1PingComponent).text = <>4__this.remotePing + " ms";
				}
				else if (Preferences.PrefShowMatchIndividualPingVisual.Value == PingVisualType.PingTickDifference)
				{
					((TMP_Text)player1PingComponent).text = <>4__this.lastRemotePingDifference + " ms";
				}
				if (Preferences.PrefShowMatchCombinedPingVisual.Value == PingVisualType.Ping)
				{
					((TMP_Text)combinedPingComponent).text = <>4__this.localPing + <>4__this.remotePing + " ms";
				}
				else if (Preferences.PrefShowMatchCombinedPingVisual.Value == PingVisualType.PingTickDifference)
				{
					((TMP_Text)combinedPingComponent).text = <>4__this.lastLocalPingDifference + <>4__this.lastRemotePingDifference + " ms";
				}
				<>2__current = (object)new WaitForFixedUpdate();
				<>1__state = 2;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private string currentScene = "Loader";

	public bool enabled = true;

	private bool init = false;

	private string FILEPATH = "UserData\\MatchInfo";

	private string FILENAME = "MatchInfo.txt";

	private string BACKUPFILENAME = "MatchInfo_Backup";

	private List<string> fileText = new List<string>();

	public static GameObject matchInfoGameObject;

	public static GameObject player1GameObject;

	public static GameObject player2GameObject;

	public static GameObject vsGameObject;

	public static GameObject player1BPGameObject;

	public static GameObject player2BPGameObject;

	public static GameObject player1MatchWinsGameObject;

	public static GameObject player2MatchWinsGameObject;

	public static GameObject player1PingGameObject;

	public static GameObject player2PingGameObject;

	public static GameObject combinedPingGameObject;

	public static TextMeshPro player1Component;

	public static TextMeshPro player2Component;

	public static TextMeshPro vsComponent;

	public static TextMeshPro player1BPComponent;

	public static TextMeshPro player2BPComponent;

	public static TextMeshPro player1MatchWinsComponent;

	public static TextMeshPro player2MatchWinsComponent;

	public static TextMeshPro player1PingComponent;

	public static TextMeshPro player2PingComponent;

	public static TextMeshPro combinedPingComponent;

	public static GameObject gymMatchInfoGameObject;

	public static GameObject gymMatchInfoTotalGameObject;

	public static GameObject gymMatchInfoWinsGameObject;

	public static GameObject gymMatchInfoLossesGameObject;

	public static GameObject gymMatchInfoWinPercentGameObject;

	public static TextMeshPro gymMatchInfoTitleComponent;

	public static TextMeshPro gymMatchInfoTotalComponent;

	public static TextMeshPro gymMatchInfoWinsComponent;

	public static TextMeshPro gymMatchInfoLossesComponent;

	public static TextMeshPro gymMatchInfoWinPercentComponent;

	private bool matchActive = false;

	private GameObject MatchSlabOne;

	private TextMeshPro Slab1Text;

	private TextMeshPro Slab2Text;

	private int playerFileSpot = 0;

	private bool ranWinLoss = true;

	private bool stopWatchingPings = false;

	private int localPing = 0;

	private int remotePing = 0;

	private int lastLocalPing = 0;

	private int lastRemotePing = 0;

	private int lastLocalPingDifference = 0;

	private int lastRemotePingDifference = 0;

	private DateTime lastLocalPingDifferenceTime = DateTime.Now;

	private DateTime lastRemotePingDifferenceTime = DateTime.Now;

	public static void Log(string msg)
	{
		Melon<Main>.Logger.Msg(msg);
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		currentScene = sceneName;
		stopWatchingPings = true;
	}

	public override void OnLateInitializeMelon()
	{
		CheckFiles();
		Preferences.InitPrefs();
		Preferences.StoreLastSavedPrefs();
		((ModelModItem)UI.Register((MelonBase)(object)this, (MelonPreferences_Category[])(object)new MelonPreferences_Category[1] { Preferences.MatchInfoCategory })).OnModSaved += Save;
		Actions.onMapInitialized += mapLoaded;
	}

	private void CheckFiles()
	{
		if (!Directory.Exists(FILEPATH))
		{
			Log("Folder Not Found, Creating Folder: " + FILEPATH);
			Directory.CreateDirectory(FILEPATH);
		}
		if (!File.Exists(FILEPATH + "\\" + FILENAME))
		{
			Log("Creating File " + FILENAME);
			saveFile("", FILEPATH + "\\" + FILENAME);
		}
		if (!Directory.Exists(FILEPATH + "\\Backups"))
		{
			Log("Folder Not Found, Creating Folder: " + FILEPATH + "\\Backups");
			Directory.CreateDirectory(FILEPATH + "\\Backups");
		}
		if (!File.Exists(FILEPATH + "\\Backups\\" + BACKUPFILENAME + "1.txt"))
		{
			Log("Creating File " + BACKUPFILENAME + "1.txt");
			saveFile("", FILEPATH + "\\Backups\\" + BACKUPFILENAME + "1.txt");
		}
		if (!File.Exists(FILEPATH + "\\Backups\\" + BACKUPFILENAME + "2.txt"))
		{
			Log("Creating File " + BACKUPFILENAME + "2.txt");
			saveFile("", FILEPATH + "\\Backups\\" + BACKUPFILENAME + "2.txt");
		}
		if (!File.Exists(FILEPATH + "\\Backups\\" + BACKUPFILENAME + "3.txt"))
		{
			Log("Creating File " + BACKUPFILENAME + "3.txt");
			saveFile("", FILEPATH + "\\Backups\\" + BACKUPFILENAME + "3.txt");
		}
		string[] array = ReadFileText(FILEPATH, FILENAME);
		string[] array2 = array;
		foreach (string item in array2)
		{
			fileText.Add(item);
		}
	}

	public static string[] ReadFileText(string filePath, string fileName)
	{
		try
		{
			return File.ReadAllLines(filePath + "\\" + fileName);
		}
		catch (Exception ex)
		{
			MelonLogger.Error((object)ex);
		}
		return null;
	}

	private void saveFile(string textToSave, string file)
	{
		FileStream fileStream = File.Create(file);
		byte[] bytes = Encoding.UTF8.GetBytes(textToSave);
		fileStream.Write(bytes);
		fileStream.Close();
		fileStream.Dispose();
	}

	public void Save()
	{
		if (currentScene == "Gym")
		{
			gymMatchInfoGameObject.SetActive(Preferences.PrefShowGymInfo.Value);
		}
		else if (currentScene == "Map0" || currentScene == "Map1")
		{
			player1MatchWinsGameObject.SetActive(Preferences.PrefShowMatchWinLoss.Value);
			player2MatchWinsGameObject.SetActive(Preferences.PrefShowMatchWinLoss.Value);
			player1PingGameObject.SetActive(Preferences.PrefShowMatchIndividualPingVisual.Value != PingVisualType.Off);
			player2PingGameObject.SetActive(Preferences.PrefShowMatchIndividualPingVisual.Value != PingVisualType.Off);
			combinedPingGameObject.SetActive(Preferences.PrefShowMatchCombinedPingVisual.Value != PingVisualType.Off);
		}
	}

	public void mapLoaded(string map)
	{
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		if (map == "Loader")
		{
			return;
		}
		if (init)
		{
			gymMatchInfoGameObject.SetActive(false);
		}
		if (map == "Gym")
		{
			if (!init)
			{
				RunInit();
			}
			matchInfoGameObject.SetActive(false);
			gymMatchInfoGameObject.SetActive(true);
			CountWinLoss();
			if (!Preferences.PrefShowGymInfo.Value)
			{
				gymMatchInfoGameObject.SetActive(false);
			}
			matchActive = false;
		}
		else
		{
			if (!(map == "Map0") && !(map == "Map1"))
			{
				return;
			}
			matchInfoGameObject.SetActive(true);
			MelonCoroutines.Start(StartUpdatingPings());
			try
			{
				if (map == "Map0")
				{
					MatchSlabOne = MatchFormCanvas.GetGameObject();
					Slab1Text = MatchText.GetGameObject().GetComponent<TextMeshPro>();
					Slab2Text = MatchText.GetGameObject().GetComponent<TextMeshPro>();
				}
				else if (map == "Map1")
				{
					MatchSlabOne = MatchFormCanvas.GetGameObject();
					Slab1Text = MatchText.GetGameObject().GetComponent<TextMeshPro>();
					Slab2Text = MatchText.GetGameObject().GetComponent<TextMeshPro>();
				}
			}
			catch
			{
				return;
			}
			if (Players.IsHost())
			{
				matchInfoGameObject.transform.position = new Vector3(-3f, 3f, 0f);
				matchInfoGameObject.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
			}
			else
			{
				matchInfoGameObject.transform.position = new Vector3(3f, 3f, 0f);
				matchInfoGameObject.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
			}
			((TMP_Text)player2Component).text = Singleton<PlayerManager>.instance.AllPlayers[0].Data.GeneralData.PublicUsername;
			if (Singleton<PlayerManager>.instance.AllPlayers[0].Data.GeneralData.PlayFabMasterId == "5832566FD2375E31")
			{
				((TMP_Text)player2Component).text = "<#990099>U<#ff00ff>l<#ff66ff>v<#cc66ff>a<#9966ff>k<#6666ff>S<#3366ff>k<#6699ff>i<#809fff>l<#b3c6ff>l<#e6ecff>z";
			}
			((TMP_Text)player2BPComponent).text = Singleton<PlayerManager>.instance.AllPlayers[0].Data.GeneralData.BattlePoints + " BP";
			if (Singleton<PlayerManager>.instance.AllPlayers.Count > 1)
			{
				((TMP_Text)player1Component).text = Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PublicUsername;
				if (Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PlayFabMasterId == "5832566FD2375E31")
				{
					((TMP_Text)player1Component).text = "<#990099>U<#ff00ff>l<#ff66ff>v<#cc66ff>a<#9966ff>k<#6666ff>S<#3366ff>k<#6699ff>i<#809fff>l<#b3c6ff>l<#e6ecff>z";
				}
				((TMP_Text)player1BPComponent).text = Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.BattlePoints + " BP";
				bool flag = false;
				for (int i = 0; i < fileText.Count; i += 3)
				{
					if (fileText[i].Contains(Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PlayFabMasterId))
					{
						if (fileText[i] == Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PlayFabMasterId)
						{
							List<string> list = fileText;
							int index = i;
							list[index] = list[index] + " - " + Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PublicUsername;
						}
						else if (!fileText[i].Contains(Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PublicUsername))
						{
							fileText[i] = Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PlayFabMasterId + " - " + Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PublicUsername;
						}
						playerFileSpot = i;
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					fileText.Add(Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PlayFabMasterId + " - " + Singleton<PlayerManager>.instance.AllPlayers[1].Data.GeneralData.PublicUsername);
					fileText.Add("0");
					fileText.Add("0");
					playerFileSpot = fileText.Count - 3;
				}
				player1MatchWinsGameObject.SetActive(true);
				player2MatchWinsGameObject.SetActive(true);
				((TMP_Text)player1MatchWinsComponent).text = fileText[playerFileSpot + 2] + " Wins";
				((TMP_Text)player2MatchWinsComponent).text = fileText[playerFileSpot + 1] + " Wins";
				if (!Preferences.PrefShowMatchWinLoss.Value)
				{
					player1MatchWinsGameObject.SetActive(false);
					player2MatchWinsGameObject.SetActive(false);
				}
				matchActive = true;
				ranWinLoss = false;
				MelonCoroutines.Start(MoveSign());
				MelonCoroutines.Start(MatchStarted());
			}
			else
			{
				MelonCoroutines.Start(OnePlayerFound());
			}
		}
	}

	[IteratorStateMachine(typeof(<MatchStarted>d__61))]
	private IEnumerator MatchStarted()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MatchStarted>d__61(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<StartUpdatingPings>d__62))]
	private IEnumerator StartUpdatingPings()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <StartUpdatingPings>d__62(0)
		{
			<>4__this = this
		};
	}

	private int GetPingFromString(string str)
	{
		int result = -1;
		string[] array = str.Split(',');
		string[] array2 = array;
		foreach (string text in array2)
		{
			if (text.Contains("(System.String)ping="))
			{
				string text2 = text.Split(')')[^1];
				text2.Replace(" ", string.Empty);
				int.TryParse(text2, out result);
				if (!int.TryParse(text2, out var _))
				{
					result = -1;
				}
				break;
			}
		}
		return result;
	}

	[IteratorStateMachine(typeof(<MoveSign>d__64))]
	private IEnumerator MoveSign()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MoveSign>d__64(0)
		{
			<>4__this = this
		};
	}

	[IteratorStateMachine(typeof(<OnePlayerFound>d__65))]
	public IEnumerator OnePlayerFound()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <OnePlayerFound>d__65(0)
		{
			<>4__this = this
		};
	}

	public void CountWinLoss()
	{
		int num = 0;
		int num2 = 0;
		for (int i = 0; i < fileText.Count; i += 3)
		{
			num += int.Parse(fileText[i + 1]);
			num2 += int.Parse(fileText[i + 2]);
		}
		((TMP_Text)gymMatchInfoTotalComponent).text = "Total: " + (num + num2);
		((TMP_Text)gymMatchInfoWinsComponent).text = "Wins: " + num;
		((TMP_Text)gymMatchInfoLossesComponent).text = "Losses: " + num2;
		((TMP_Text)gymMatchInfoWinPercentComponent).text = "Win Rate: " + (float)(int)((float)num / (float)(num + num2) * 10000f) / 100f + "%";
		if (num + num2 == 0)
		{
			((TMP_Text)gymMatchInfoWinPercentComponent).text = "Win Rate: N/A";
		}
	}

	private void RunInit()
	{
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0445: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_081b: Unknown result type (might be due to invalid IL or missing references)
		//IL_083f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0863: Unknown result type (might be due to invalid IL or missing references)
		//IL_0887: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_08cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0917: Unknown result type (might be due to invalid IL or missing references)
		//IL_093b: Unknown result type (might be due to invalid IL or missing references)
		//IL_095f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0983: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			File.Copy(FILEPATH + "\\Backups\\" + BACKUPFILENAME + "2.txt", FILEPATH + "\\Backups\\" + BACKUPFILENAME + "3.txt", overwrite: true);
			File.Copy(FILEPATH + "\\Backups\\" + BACKUPFILENAME + "1.txt", FILEPATH + "\\Backups\\" + BACKUPFILENAME + "2.txt", overwrite: true);
			File.Copy(FILEPATH + "\\" + FILENAME, FILEPATH + "\\Backups\\" + BACKUPFILENAME + "1.txt", overwrite: true);
		}
		catch (Exception ex)
		{
			Log("Failed to Backup Logs: " + ex);
		}
		matchInfoGameObject = new GameObject();
		((Object)matchInfoGameObject).name = "MatchInfoMod";
		matchInfoGameObject.SetActive(false);
		player1GameObject = Object.Instantiate<GameObject>(Nr.GetGameObject());
		player1GameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player1GameObject).name = "Player1Name";
		player1Component = player1GameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player1Component).text = "name";
		((TMP_Text)player1Component).fontSize = 5f;
		((TMP_Text)player1Component).color = new Color(1f, 1f, 1f, 1f);
		((TMP_Text)player1Component).outlineColor = Color32.op_Implicit(new Color(0f, 0f, 0f, 0.5f));
		((TMP_Text)player1Component).alignment = (TextAlignmentOptions)516;
		((TMP_Text)player1Component).enableWordWrapping = false;
		((TMP_Text)player1Component).outlineWidth = 0.1f;
		player2GameObject = Object.Instantiate<GameObject>(player1GameObject);
		player2GameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player2GameObject).name = "Player2Name";
		player2Component = player2GameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player2Component).alignment = (TextAlignmentOptions)513;
		vsGameObject = Object.Instantiate<GameObject>(player2GameObject);
		vsGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)vsGameObject).name = "VSText";
		vsComponent = vsGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)vsComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)vsComponent).color = new Color(0f, 0f, 0f, 1f);
		((TMP_Text)vsComponent).text = "vs";
		((TMP_Text)vsComponent).fontSize = 3.5f;
		player1BPGameObject = Object.Instantiate<GameObject>(player2GameObject);
		player1BPGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player1BPGameObject).name = "Player1BP";
		player1BPComponent = player1BPGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player1BPComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)player1BPComponent).text = "P1BP";
		((TMP_Text)player1BPComponent).fontSize = 4f;
		player2BPGameObject = Object.Instantiate<GameObject>(player2GameObject);
		player2BPGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player2BPGameObject).name = "Player2BP";
		player2BPComponent = player2BPGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player2BPComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)player2BPComponent).text = "P2BP";
		((TMP_Text)player2BPComponent).fontSize = 4f;
		player1MatchWinsGameObject = Object.Instantiate<GameObject>(player1BPGameObject);
		player1MatchWinsGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player1MatchWinsGameObject).name = "P1Wins";
		player1MatchWinsComponent = player1MatchWinsGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player1MatchWinsComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)player1MatchWinsComponent).text = "0 Wins";
		((TMP_Text)player1MatchWinsComponent).color = new Color(1f, 1f, 1f, 1f);
		player2MatchWinsGameObject = Object.Instantiate<GameObject>(player1MatchWinsGameObject);
		player2MatchWinsGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player2MatchWinsGameObject).name = "P2Wins";
		player2MatchWinsComponent = player2MatchWinsGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player2MatchWinsComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)player2MatchWinsComponent).text = "0 Wins";
		player1PingGameObject = Object.Instantiate<GameObject>(player2MatchWinsGameObject);
		player1PingGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player1PingGameObject).name = "Player1Ping";
		player1PingComponent = player1PingGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player1PingComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)player1PingComponent).text = "P1Ping";
		((TMP_Text)player1PingComponent).fontSize = 4f;
		player2PingGameObject = Object.Instantiate<GameObject>(player1PingGameObject);
		player2PingGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)player2PingGameObject).name = "Player2Ping";
		player2PingComponent = player2PingGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)player2PingComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)player2PingComponent).text = "P2Ping";
		((TMP_Text)player2PingComponent).fontSize = 4f;
		combinedPingGameObject = Object.Instantiate<GameObject>(player2PingGameObject);
		combinedPingGameObject.transform.parent = matchInfoGameObject.transform;
		((Object)combinedPingGameObject).name = "CombinedPing";
		combinedPingComponent = combinedPingGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)combinedPingComponent).alignment = (TextAlignmentOptions)514;
		((TMP_Text)combinedPingComponent).text = "CombinedPing";
		((TMP_Text)combinedPingComponent).fontSize = 4f;
		gymMatchInfoGameObject = Object.Instantiate<GameObject>(player1GameObject);
		((Object)gymMatchInfoGameObject).name = "GymMatchInfo";
		gymMatchInfoTitleComponent = gymMatchInfoGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)gymMatchInfoTitleComponent).alignment = (TextAlignmentOptions)513;
		((TMP_Text)gymMatchInfoTitleComponent).text = "Match History";
		((TMP_Text)gymMatchInfoTitleComponent).fontSize = 3.5f;
		gymMatchInfoTotalGameObject = Object.Instantiate<GameObject>(gymMatchInfoGameObject);
		gymMatchInfoTotalGameObject.transform.parent = gymMatchInfoGameObject.transform;
		((Object)gymMatchInfoTotalGameObject).name = "Total";
		gymMatchInfoTotalComponent = gymMatchInfoTotalGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)gymMatchInfoTotalComponent).text = "Total: ";
		gymMatchInfoWinsGameObject = Object.Instantiate<GameObject>(gymMatchInfoTotalGameObject);
		gymMatchInfoWinsGameObject.transform.parent = gymMatchInfoGameObject.transform;
		((Object)gymMatchInfoWinsGameObject).name = "Wins";
		gymMatchInfoWinsComponent = gymMatchInfoWinsGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)gymMatchInfoWinsComponent).text = "Wins: ";
		gymMatchInfoLossesGameObject = Object.Instantiate<GameObject>(gymMatchInfoTotalGameObject);
		gymMatchInfoLossesGameObject.transform.parent = gymMatchInfoGameObject.transform;
		((Object)gymMatchInfoLossesGameObject).name = "Losses";
		gymMatchInfoLossesComponent = gymMatchInfoLossesGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)gymMatchInfoLossesComponent).text = "Losses: ";
		gymMatchInfoWinPercentGameObject = Object.Instantiate<GameObject>(gymMatchInfoTotalGameObject);
		gymMatchInfoWinPercentGameObject.transform.parent = gymMatchInfoGameObject.transform;
		((Object)gymMatchInfoWinPercentGameObject).name = "WinPercent";
		gymMatchInfoWinPercentComponent = gymMatchInfoWinPercentGameObject.GetComponent<TextMeshPro>();
		((TMP_Text)gymMatchInfoWinPercentComponent).text = "Win Rate: ";
		vsGameObject.transform.position = new Vector3(0f, 0.75f, 0f);
		player1GameObject.transform.position = new Vector3(-0.75f, 1f, 0f);
		player2GameObject.transform.position = new Vector3(0.75f, 1f, 0f);
		player1BPGameObject.transform.position = new Vector3(-1.25f, 0.5f, 0f);
		player2BPGameObject.transform.position = new Vector3(1.25f, 0.5f, 0f);
		player1MatchWinsGameObject.transform.position = new Vector3(-1.25f, 0f, 0f);
		player2MatchWinsGameObject.transform.position = new Vector3(1.25f, 0f, 0f);
		player1PingGameObject.transform.localPosition = new Vector3(-1.25f, 1.5f, 0f);
		player2PingGameObject.transform.localPosition = new Vector3(1.25f, 1.5f, 0f);
		combinedPingGameObject.transform.localPosition = new Vector3(0f, 1.5f, 0f);
		gymMatchInfoGameObject.transform.position = new Vector3(4.6927f, 1.0336f, 12.0491f);
		gymMatchInfoGameObject.transform.rotation = Quaternion.Euler(0f, 309.0233f, 0f);
		gymMatchInfoGameObject.transform.localScale = new Vector3(0.45f, 0.45f, 1f);
		gymMatchInfoTotalGameObject.transform.localPosition = new Vector3(0.0334f, -0.35f, 0.0088f);
		gymMatchInfoWinsGameObject.transform.localPosition = new Vector3(0.0334f, -0.65f, 0.0088f);
		gymMatchInfoLossesGameObject.transform.localPosition = new Vector3(0.0334f, -0.95f, 0.0088f);
		gymMatchInfoWinPercentGameObject.transform.localPosition = new Vector3(0.0334f, -1.25f, 0.0088f);
		gymMatchInfoGameObject.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)matchInfoGameObject);
		Object.DontDestroyOnLoad((Object)(object)gymMatchInfoGameObject);
		init = true;
	}
}
internal enum PingVisualType
{
	[Display(Name = "Off")]
	Off,
	[Display(Name = "Ping")]
	Ping,
	[Display(Name = "Ping Tick Difference")]
	PingTickDifference
}
public class Preferences
{
	private const string CONFIG_FILE = "config.cfg";

	private const string USER_DATA = "UserData/MatchInfo/";

	internal static Dictionary<MelonPreferences_Entry, object> LastSavedValues = new Dictionary<MelonPreferences_Entry, object>();

	internal static MelonPreferences_Category MatchInfoCategory;

	internal static MelonPreferences_Entry<bool> PrefShowGymInfo;

	internal static MelonPreferences_Entry<bool> PrefShowMatchWinLoss;

	internal static MelonPreferences_Entry<PingVisualType> PrefShowMatchIndividualPingVisual;

	internal static MelonPreferences_Entry<PingVisualType> PrefShowMatchCombinedPingVisual;

	internal static void InitPrefs()
	{
		if (!Directory.Exists("UserData/MatchInfo/"))
		{
			Directory.CreateDirectory("UserData/MatchInfo/");
		}
		MatchInfoCategory = MelonPreferences.CreateCategory("MatchInfo", "MatchInfoSettings");
		MatchInfoCategory.SetFilePath(Path.Combine("UserData/MatchInfo/", "config.cfg"));
		PrefShowGymInfo = MatchInfoCategory.CreateEntry<bool>("ShowGymInfo", true, "Show Gym Info", "Toggles Mod Info in Gym On/Off", false, false, (ValueValidator)null, (string)null);
		PrefShowMatchWinLoss = MatchInfoCategory.CreateEntry<bool>("ShowMatchWinLoss", true, "Show Match Win/Loss", "Toggles Mod Info in Matches", false, false, (ValueValidator)null, (string)null);
		PrefShowMatchIndividualPingVisual = MatchInfoCategory.CreateEntry<PingVisualType>("ShowMatchIndividualPingVisual", PingVisualType.PingTickDifference, "Show Match Individual Ping Visual", "Controls the Visuals of the Individual Pings", false, false, (ValueValidator)null, (string)null);
		PrefShowMatchCombinedPingVisual = MatchInfoCategory.CreateEntry<PingVisualType>("ShowMatchCombinedPingVisual", PingVisualType.Ping, "Show Match Combined Ping Visual", "Controls the Visuals of the Combined Pings", false, false, (ValueValidator)null, (string)null);
		StoreLastSavedPrefs();
	}

	internal static void StoreLastSavedPrefs()
	{
		List<MelonPreferences_Entry> list = new List<MelonPreferences_Entry>();
		list.AddRange(MatchInfoCategory.Entries);
		foreach (MelonPreferences_Entry item in list)
		{
			LastSavedValues[item] = item.BoxedValue;
		}
	}

	public static bool AnyPrefsChanged()
	{
		foreach (KeyValuePair<MelonPreferences_Entry, object> lastSavedValue in LastSavedValues)
		{
			if (!lastSavedValue.Key.BoxedValue.Equals(lastSavedValue.Value))
			{
				return true;
			}
		}
		return false;
	}

	public static bool IsPrefChanged(MelonPreferences_Entry entry)
	{
		if (LastSavedValues.TryGetValue(entry, out var value))
		{
			return !entry.BoxedValue.Equals(value);
		}
		return false;
	}
}