Decompiled source of UpgradeChecker v1.0.0

plugins/yazirushi-UpgradeChecker/UpgradeChecker.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
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: AssemblyTitle("UpgradeList")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UpgradeList")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8fe69c6e-dd26-4621-b94c-1aa64d4213f6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UpgradeChecker;

[BepInPlugin("yazirushi.UpgradeChecker", "UpgradeChecker", "1.0.0")]
public class UpgradeChecker : BaseUnityPlugin
{
	public enum Upgrades
	{
		Total,
		Health,
		Stamina,
		ExtraJump,
		TumbleLaunch,
		TumbleClimb,
		DeathHeadBattery,
		MapPlayerCount,
		Speed,
		Strength,
		Range,
		CrouchRest,
		TumbleWings
	}

	private readonly Harmony harmony = new Harmony("yazirushi.UpgradeChecker");

	internal static ManualLogSource mls;

	public static ConfigEntry<Upgrades> Type;

	public static ConfigEntry<float> UIText_Offset_X;

	public static ConfigEntry<float> UIText_Offset_Y;

	public static ConfigEntry<float> UIText_FontSize;

	public static ConfigEntry<Color> UIText_Color;

	public static ConfigEntry<bool> DebugLog;

	public static Canvas canvas;

	public static TextMeshProUGUI text;

	public static void CreateUI()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Expected O, but got Unknown
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("UpgradeCheckerCanvas");
		canvas = val.AddComponent<Canvas>();
		canvas.renderMode = (RenderMode)0;
		canvas.worldCamera = null;
		canvas.sortingOrder = 999;
		canvas.scaleFactor = 1f;
		CanvasScaler val2 = val.AddComponent<CanvasScaler>();
		val2.uiScaleMode = (ScaleMode)1;
		val2.referenceResolution = new Vector2(1920f, 1080f);
		val2.matchWidthOrHeight = 1f;
		val.AddComponent<GraphicRaycaster>();
		Object.DontDestroyOnLoad((Object)(object)val);
		GameObject val3 = new GameObject("UpgradeCheckerText");
		val3.transform.SetParent(val.transform);
		text = val3.AddComponent<TextMeshProUGUI>();
		TMP_FontAsset tekoFont = FontUtil.GetTekoFont();
		if ((Object)(object)tekoFont != (Object)null)
		{
			((TMP_Text)text).font = tekoFont;
			((TMP_Text)text).fontMaterial = FontUtil.GetTekoMaterial();
		}
		((TMP_Text)text).enableWordWrapping = false;
		((TMP_Text)text).overflowMode = (TextOverflowModes)0;
		((TMP_Text)text).alignment = (TextAlignmentOptions)1028;
		((TMP_Text)text).rectTransform.anchorMin = new Vector2(0f, 1f);
		((TMP_Text)text).rectTransform.anchorMax = new Vector2(0f, 1f);
		((TMP_Text)text).rectTransform.pivot = new Vector2(0f, 1f);
		((TMP_Text)text).rectTransform.anchoredPosition = Vector2.zero;
		((TMP_Text)text).rectTransform.sizeDelta = new Vector2(300f, 1080f);
		if (DebugLog.Value)
		{
			mls.LogInfo((object)"CreateUI!");
		}
	}

	public static void UpdateUI(string __text)
	{
		//IL_0027: 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)
		((TMP_Text)text).text = __text;
		((TMP_Text)text).fontSize = UIText_FontSize.Value;
		((Graphic)text).color = Color.white;
		((TMP_Text)text).rectTransform.anchoredPosition = new Vector2(UIText_Offset_X.Value, UIText_Offset_Y.Value);
		if (DebugLog.Value)
		{
			mls.LogInfo((object)"UpdateUI!");
		}
	}

	private void Awake()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Expected O, but got Unknown
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		Type = ((BaseUnityPlugin)this).Config.Bind<Upgrades>("Settings", "Show Upgrades Type", Upgrades.Total, new ConfigDescription("Show upgrades", (AcceptableValueBase)null, Array.Empty<object>()));
		UIText_Offset_X = ((BaseUnityPlugin)this).Config.Bind<float>("UI Settings", "X Offset", 0f, new ConfigDescription("X-axis offset", (AcceptableValueBase)null, Array.Empty<object>()));
		UIText_Offset_Y = ((BaseUnityPlugin)this).Config.Bind<float>("UI Settings", "Y Offset", 0f, new ConfigDescription("Y-axis offset", (AcceptableValueBase)null, Array.Empty<object>()));
		UIText_FontSize = ((BaseUnityPlugin)this).Config.Bind<float>("UI Settings", "Text Size", 30f, new ConfigDescription("UI text size", (AcceptableValueBase)null, Array.Empty<object>()));
		DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("DebugLog", "EnableLogging", false, new ConfigDescription("Display the logs used during debugging", (AcceptableValueBase)null, Array.Empty<object>()));
		mls = ((BaseUnityPlugin)this).Logger;
		mls.LogInfo((object)"Starting UpgradeChecker...");
		harmony.PatchAll();
	}
}
public class FontUtil
{
	private static TMP_FontAsset cachedFont;

	private static Material cachedMat;

	public static TMP_FontAsset GetTekoFont()
	{
		if ((Object)(object)cachedFont != (Object)null)
		{
			return cachedFont;
		}
		TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
		foreach (TMP_FontAsset val in array)
		{
			if (((Object)val).name.Contains("Teko") && ((Object)val).name.Contains("SDF"))
			{
				cachedFont = val;
				cachedMat = ((TMP_Asset)val).material;
				return cachedFont;
			}
		}
		return null;
	}

	public static Material GetTekoMaterial()
	{
		return cachedMat;
	}
}
[HarmonyPatch(typeof(StatsManager), "Update")]
public class UpgradeListUpdate
{
	private static UpgradeChecker.Upgrades Type;

	private static bool createdUI;

	public static void Postfix()
	{
		List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
		if (list == null || list.Count == 0)
		{
			return;
		}
		if ((Object)(object)UpgradeChecker.canvas != (Object)null && Input.GetKey((KeyCode)308) && Input.GetKeyDown((KeyCode)99))
		{
			((Behaviour)UpgradeChecker.canvas).enabled = !((Behaviour)UpgradeChecker.canvas).enabled;
		}
		UpgradeChecker.Upgrades[] array = (UpgradeChecker.Upgrades[])Enum.GetValues(typeof(UpgradeChecker.Upgrades));
		int num = Array.IndexOf(array, Type);
		if (Input.GetKey((KeyCode)308) && Input.GetKeyDown((KeyCode)276))
		{
			num = (num - 1 + array.Length) % array.Length;
		}
		if (Input.GetKey((KeyCode)308) && Input.GetKeyDown((KeyCode)275))
		{
			num = (num + 1) % array.Length;
		}
		Type = array[num];
		string text = $" < {Type} >  \n";
		foreach (PlayerAvatar item in list)
		{
			if ((Object)(object)item == (Object)null)
			{
				continue;
			}
			if ((Object)(object)UpgradeChecker.canvas != (Object)null && !((Behaviour)UpgradeChecker.canvas).enabled)
			{
				return;
			}
			string text2 = SemiFunc.PlayerGetName(item);
			text = text + " " + text2.PadRight(10).Substring(0, 10) + " : ";
			string key = SemiFunc.PlayerGetSteamID(item);
			bool flag = Type == UpgradeChecker.Upgrades.Total;
			int num2 = 0;
			if (flag || Type == UpgradeChecker.Upgrades.Health)
			{
				int num3 = StatsManager.instance.playerUpgradeHealth[key];
				num2 += num3;
				if (!flag)
				{
					text += $" {num3,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.Stamina)
			{
				int num4 = StatsManager.instance.playerUpgradeStamina[key];
				num2 += num4;
				if (!flag)
				{
					text += $" {num4,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.ExtraJump)
			{
				int num5 = StatsManager.instance.playerUpgradeExtraJump[key];
				num2 += num5;
				if (!flag)
				{
					text += $" {num5,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.TumbleLaunch)
			{
				int num6 = StatsManager.instance.playerUpgradeLaunch[key];
				num2 += num6;
				if (!flag)
				{
					text += $" {num6,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.TumbleClimb)
			{
				int num7 = StatsManager.instance.playerUpgradeTumbleClimb[key];
				num2 += num7;
				if (!flag)
				{
					text += $" {num7,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.DeathHeadBattery)
			{
				int num8 = StatsManager.instance.playerUpgradeDeathHeadBattery[key];
				num2 += num8;
				if (!flag)
				{
					text += $" {num8,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.MapPlayerCount)
			{
				int num9 = StatsManager.instance.playerUpgradeMapPlayerCount[key];
				num2 += num9;
				if (!flag)
				{
					text += $" {num9,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.Speed)
			{
				int num10 = StatsManager.instance.playerUpgradeSpeed[key];
				num2 += num10;
				if (!flag)
				{
					text += $" {num10,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.Strength)
			{
				int num11 = StatsManager.instance.playerUpgradeStrength[key];
				num2 += num11;
				if (!flag)
				{
					text += $" {num11,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.Range)
			{
				int num12 = StatsManager.instance.playerUpgradeRange[key];
				num2 += num12;
				if (!flag)
				{
					text += $" {num12,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.CrouchRest)
			{
				int num13 = StatsManager.instance.playerUpgradeCrouchRest[key];
				num2 += num13;
				if (!flag)
				{
					text += $" {num13,4} ";
				}
			}
			if (flag || Type == UpgradeChecker.Upgrades.TumbleWings)
			{
				int num14 = StatsManager.instance.playerUpgradeTumbleWings[key];
				num2 += num14;
				if (!flag)
				{
					text += $" {num14,4} ";
				}
			}
			if (Type == UpgradeChecker.Upgrades.Total)
			{
				text += $" {num2,5} ";
			}
			text += "\n";
		}
		if (!createdUI)
		{
			createdUI = true;
			UpgradeChecker.CreateUI();
			if ((Object)(object)UpgradeChecker.canvas != (Object)null)
			{
				((Behaviour)UpgradeChecker.canvas).enabled = false;
			}
		}
		if ((Object)(object)UpgradeChecker.canvas != (Object)null && ((Behaviour)UpgradeChecker.canvas).enabled)
		{
			UpgradeChecker.UpdateUI(text);
		}
	}
}