Decompiled source of Empress RunTracker v1.0.0

EmpressRunTracker.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmpressRunTracker")]
[assembly: AssemblyTitle("EmpressRunTracker")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RepoRunsDisplay
{
	[BepInPlugin("com.Empress.reporunsdisplay", "Repo Runs Display", "1.1.0")]
	public class RepoRunsDisplayPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("com.Empress.reporunsdisplay");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Repo Runs Display Loaded!");
		}
	}
	[HarmonyPatch(typeof(MainMenuOpen), "Start")]
	public static class MainMenuRunCountPatch
	{
		public static void Postfix()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			if ((Object)(object)DataDirector.instance != (Object)null)
			{
				num = DataDirector.instance.SettingValueFetch((Setting)31);
			}
			GameObject val = new GameObject("RunsDisplayCanvas");
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 999;
			val.AddComponent<CanvasScaler>();
			val.AddComponent<GraphicRaycaster>();
			GameObject val3 = new GameObject("RunsText");
			val3.transform.SetParent(val.transform, false);
			TextMeshProUGUI val4 = val3.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val4).text = $"Runs: <color=#FFD700>{num}</color>";
			((TMP_Text)val4).fontSize = 32f;
			((TMP_Text)val4).alignment = (TextAlignmentOptions)260;
			((Graphic)val4).color = Color.white;
			((Graphic)val4).raycastTarget = false;
			RectTransform rectTransform = ((TMP_Text)val4).rectTransform;
			rectTransform.anchorMin = new Vector2(1f, 1f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(1f, 1f);
			rectTransform.anchoredPosition = new Vector2(-20f, -20f);
			rectTransform.sizeDelta = new Vector2(300f, 50f);
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "Start")]
	public static class PlayerAvatarSetupPatch
	{
		public static void Postfix(PlayerAvatar __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			if (__instance.photonView.IsMine)
			{
				int num = 0;
				if ((Object)(object)DataDirector.instance != (Object)null)
				{
					num = DataDirector.instance.SettingValueFetch((Setting)31);
				}
				Hashtable val = new Hashtable();
				val[(object)"RunsPlayed"] = num;
				PhotonNetwork.LocalPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				if ((Object)(object)RunScoreboardController.Instance == (Object)null)
				{
					GameObject val2 = new GameObject("RunScoreboardController");
					val2.AddComponent<RunScoreboardController>();
				}
			}
		}
	}
	public class RunScoreboardController : MonoBehaviour
	{
		public static RunScoreboardController Instance;

		private GameObject canvasObj;

		private TextMeshProUGUI textMesh;

		private void Awake()
		{
			Instance = this;
			SetupUI();
		}

		private void SetupUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			canvasObj = new GameObject("TabScoreboardCanvas");
			Canvas val = canvasObj.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 1000;
			CanvasScaler val2 = canvasObj.AddComponent<CanvasScaler>();
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = new Vector2(1920f, 1080f);
			canvasObj.AddComponent<GraphicRaycaster>();
			GameObject val3 = new GameObject("ScoreboardText");
			val3.transform.SetParent(canvasObj.transform, false);
			textMesh = val3.AddComponent<TextMeshProUGUI>();
			((TMP_Text)textMesh).fontSize = 36f;
			((TMP_Text)textMesh).alignment = (TextAlignmentOptions)260;
			((Graphic)textMesh).color = Color.white;
			((Graphic)textMesh).raycastTarget = false;
			RectTransform rectTransform = ((TMP_Text)textMesh).rectTransform;
			rectTransform.anchorMin = new Vector2(1f, 0f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(1f, 1f);
			rectTransform.anchoredPosition = new Vector2(-50f, -100f);
			rectTransform.sizeDelta = new Vector2(600f, 900f);
			canvasObj.SetActive(false);
		}

		private void Update()
		{
			if (Input.GetKey((KeyCode)9))
			{
				if (!canvasObj.activeSelf)
				{
					canvasObj.SetActive(true);
				}
				UpdateList();
			}
			else if (canvasObj.activeSelf)
			{
				canvasObj.SetActive(false);
			}
		}

		private void UpdateList()
		{
			if (!PhotonNetwork.InRoom)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("<size=42><b>PLAYERS</b></size>");
			stringBuilder.AppendLine("");
			Player[] playerList = PhotonNetwork.PlayerList;
			foreach (Player val in playerList)
			{
				string text = val.NickName;
				if (string.IsNullOrEmpty(text))
				{
					text = "Unknown";
				}
				string text2 = "0";
				if (((Dictionary<object, object>)(object)val.CustomProperties).TryGetValue((object)"RunsPlayed", out object value))
				{
					text2 = value.ToString();
				}
				stringBuilder.AppendLine(text + "  <color=#FFD700>Runs: " + text2 + "</color>");
			}
			((TMP_Text)textMesh).text = stringBuilder.ToString();
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)canvasObj))
			{
				Object.Destroy((Object)(object)canvasObj);
			}
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}
	}
}