Decompiled source of Root Stats UI v0.5.0

RSUI.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using TMPro;
using UnboundLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("Systems.R00t.RSUI", "Root's Stat UI", "0.5.0")]
[BepInProcess("Rounds.exe")]
public class RSUI : BaseUnityPlugin
{
	public class StatDesplyer : MonoBehaviour
	{
		public TextMeshProUGUI textMesh;

		public string Format(float value)
		{
			string text = "";
			if (Mathf.Abs(value) < 100f)
			{
				return ((Single)(ref value)).ToString("#0.0#");
			}
			if (Mathf.Abs(value) < 999999f)
			{
				return ((Single)(ref value)).ToString("##,#");
			}
			return ((Single)(ref value)).ToString("0.00e0");
		}

		public string SanitizeName(string name)
		{
			string text = "";
			int num = 0;
			for (int i = 0; i < name.Length; i++)
			{
				char c = name[i];
				if (c == '<')
				{
					num++;
				}
				if (num == 0)
				{
					text = String.Concat(text, ((Char)(ref c)).ToString());
				}
				if (c == '>')
				{
					num--;
				}
			}
			return text.Substring(0, Math.Min(text.Length, 15));
		}

		public string Pad(string str)
		{
			string text = str;
			while (text.Length < 16)
			{
				text = String.Concat(text, " ");
			}
			return text;
		}

		public string Separator()
		{
			return String.Concat(Enumerable.Repeat<string>("—", 71));
		}

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			textMesh = ((Component)this).gameObject.AddComponent<TextMeshProUGUI>();
			((Graphic)textMesh).color = Color.green;
		}

		private void Update()
		{
			string text = String.Concat("<align=\"center\"><mspace=0.7em><line-height=80%>", Separator(), "\n");
			PlayerManager instance = PlayerManager.instance;
			if (instance != null && instance.players.Count > 0)
			{
				List<Player> val = Enumerable.ToList<Player>((IEnumerable<Player>)(object)Enumerable.ThenBy<Player, int>(Enumerable.ThenBy<Player, int>(Enumerable.OrderBy<Player, bool>((IEnumerable<Player>)(object)PlayerManager.instance.players, (Func<Player, bool>)((Player p) => !p.data.view.IsMine)), (Func<Player, int>)((Player p) => p.teamID)), (Func<Player, int>)((Player p) => p.playerID)));
				int num = 1;
				if (val.Count > 4)
				{
					num = 2;
				}
				for (int i = 0; i < num; i++)
				{
					int num2 = Mathf.Min(val.Count, 4 + 4 * i);
					for (int j = 4 * i; j < num2; j++)
					{
						text = String.Concat(text, "| ", Pad(SanitizeName(val[j].data.view.Owner.NickName)));
					}
					text = String.Concat(text, "|\r\n");
					for (int k = 4 * i; k < num2; k++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat("    HP: ", Format(val[k].data.health))));
					}
					text = String.Concat(text, "|\r\n");
					for (int l = 4 * i; l < num2; l++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat("   MAX: ", Format(val[l].data.maxHealth))));
					}
					text = String.Concat(text, "|\r\n");
					for (int m = 4 * i; m < num2; m++)
					{
						text = String.Concat(text, "| ", Pad(""));
					}
					text = String.Concat(text, "|\r\n");
					for (int n = 4 * i; n < num2; n++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat("   DMG: ", Format(val[n].data.weaponHandler.gun.damage * val[n].data.weaponHandler.gun.bulletDamageMultiplier * val[n].data.weaponHandler.gun.projectiles[0].objectToSpawn.GetComponent<ProjectileHit>().damage))));
					}
					text = String.Concat(text, "|\r\n");
					for (int num3 = 4 * i; num3 < num2; num3++)
					{
						text = String.Concat(text, "| ", Pad(""));
					}
					text = String.Concat(text, "|\r\n");
					for (int num4 = 4 * i; num4 < num2; num4++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat(" BLOCK: ", Format(Mathf.Min(val[num4].data.block.counter, val[num4].data.block.Cooldown())), "s")));
					}
					text = String.Concat(text, "|\r\n");
					for (int num5 = 4 * i; num5 < num2; num5++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat("    CD: ", Format(val[num5].data.block.Cooldown()), "s")));
					}
					text = String.Concat(text, "|\r\n");
					for (int num6 = 4 * i; num6 < num2; num6++)
					{
						text = String.Concat(text, "| ", Pad(""));
					}
					text = String.Concat(text, "|\r\n");
					for (int num7 = 4 * i; num7 < num2; num7++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat("RELOAD: ", Format(val[num7].data.weaponHandler.gun.gunAmmo.ReloadTime() - Mathf.Max(0f, val[num7].data.weaponHandler.gun.gunAmmo.reloadCounter)), "s")));
					}
					text = String.Concat(text, "|\r\n");
					for (int num8 = 4 * i; num8 < num2; num8++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat("    CD: ", Format(val[num8].data.weaponHandler.gun.gunAmmo.ReloadTime()), "s")));
					}
					text = String.Concat(text, "|\r\n");
					for (int num9 = 4 * i; num9 < num2; num9++)
					{
						text = String.Concat(text, "| ", Pad(""));
					}
					text = String.Concat(text, "|\r\n");
					for (int num10 = 4 * i; num10 < num2; num10++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat(" ATKCD: ", Format(Mathf.Min(((Weapon)val[num10].data.weaponHandler.gun).sinceAttack, val[num10].data.weaponHandler.gun.usedCooldown)), "s")));
					}
					text = String.Concat(text, "|\r\n");
					for (int num11 = 4 * i; num11 < num2; num11++)
					{
						text = String.Concat(text, "| ", Pad(String.Concat("ATKSPD: ", Format(val[num11].data.weaponHandler.gun.usedCooldown), "s")));
					}
					text = String.Concat(text, "|\r\n");
					text = String.Concat(text, Separator(), "\n");
				}
			}
			else
			{
				text = String.Concat(text, "Root's Stats UI\n", Separator());
			}
			((TMP_Text)textMesh).text = text;
		}
	}

	private const string ModId = "Systems.R00t.RSUI";

	private const string ModName = "Root's Stat UI";

	public const string Version = "0.5.0";

	public static GameObject camra;

	private void Awake()
	{
		Unbound.RegisterClientSideMod("Systems.R00t.RSUI");
	}

	private void Start()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)camra == (Object)null && Display.displays.Length > 1)
		{
			camra = new GameObject("Camra");
			camra.transform.position = new Vector3(1000f, 1000f, -50f);
			Object.DontDestroyOnLoad((Object)(object)camra);
			Camera val = camra.AddComponent<Camera>();
			val.orthographic = true;
			val.orthographicSize = 55f;
			val.targetDisplay = Display.displays.Length - 1;
			val.backgroundColor = Color.black;
			GameObject val2 = new GameObject("text");
			val2.transform.parent = camra.transform;
			Canvas obj = val2.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)1;
			obj.worldCamera = val;
			val2.AddComponent<StatDesplyer>();
			Display.displays[Display.displays.Length - 1].Activate();
		}
	}
}