Decompiled source of TotalUpgradeCount v1.0.2

BepInEx/plugins/Avalon-TotalUpgradeCount/TotalUpgradeCount.dll

Decompiled 3 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace TotalUpgradeCount
{
	[BepInPlugin("Avalon.TotalUpgradeCount", "TotalUpgradeCount", "1.0.1")]
	public class TotalUpgradeCount : BaseUnityPlugin
	{
		public const string pluginGUID = "ds9.avalon.totalupgradecount";

		public const string pluginName = "Total Upgrade Count";

		public const string pluginVersion = "1.0.1";

		public void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("ds9.avalon.totalupgradecount").PatchAll();
		}
	}
}
namespace TotalCount
{
	internal class TotalCountPatch
	{
		[HarmonyPatch(typeof(PlayerAvatar), "Awake")]
		private class VoicePatch
		{
			public static TotalCountBehaviour instance;

			[HarmonyPostfix]
			private static void Patch(PlayerAvatar __instance)
			{
				if (Object.op_Implicit((Object)(object)Traverse.Create((object)__instance).Field("photonView").GetValue<PhotonView>()))
				{
					instance = ((Component)__instance).gameObject.AddComponent<TotalCountBehaviour>();
				}
			}
		}
	}
	internal class TotalCountBehaviour : MonoBehaviour
	{
		private PlayerAvatar selectedPlayer;

		private bool showUpgrades;

		private List<string> playerTotals = new List<string> { "NULL" };

		private void Awake()
		{
			selectedPlayer = SemiFunc.PlayerGetList()[0];
		}

		private void OnGUI()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (showUpgrades)
			{
				GUIStyle style = GUI.skin.GetStyle("label");
				style.fontSize = 24;
				style.fontStyle = (FontStyle)1;
				for (int i = 0; i < playerTotals.Count; i++)
				{
					GUI.Label(new Rect(20f, (float)(Screen.height - 100 - 50 * i), 400f, 50f), playerTotals[i]);
				}
			}
		}

		private void Update()
		{
			if ((!Input.GetKey((KeyCode)308) && !Input.GetKey((KeyCode)307)) || !Input.GetKeyDown((KeyCode)120))
			{
				return;
			}
			playerTotals.Clear();
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				string arg = SemiFunc.PlayerGetName(item);
				int num = StatsManager.instance.FetchPlayerUpgrades(SemiFunc.PlayerGetSteamID(item))?.Values.Sum() ?? 0;
				playerTotals.Add($"{num}   {arg}");
			}
			showUpgrades = !showUpgrades;
			Debug.Log((object)$"Player totals visible {showUpgrades}");
		}
	}
}