Decompiled source of PingScaler v1.0.0

PingTextReducer.dll

Decompiled 8 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2.UI;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PingTextReducer")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PingTextReducer")]
[assembly: AssemblyTitle("PingTextReducer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PingTextReducer;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("thebugreport.PingTextReducer", "PingTextReducer", "1.0.0")]
public class PingTextReducer : BaseUnityPlugin
{
	private ConfigEntry<float> pingOwnerScaleMultiplier;

	private ConfigEntry<float> pingOwnerSpriteScale;

	private ConfigEntry<bool> nullScaleInSingleplayer;

	public Vector3 trueScale = Vector3.zero;

	public void Awake()
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Expected O, but got Unknown
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		pingOwnerScaleMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Owner Scale Multiplier", 0.7f, "Multiplier used to scale the nameplate when someone pings something.");
		pingOwnerSpriteScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Owner Sprite Scale", 0.9f, "Multiplier used to scale the sprite when someone pings something.");
		nullScaleInSingleplayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Hide Name In Singleplayer", false, "If playing in singleplayer or alone in multiplayer, sets the name scale to 0 if true.");
		PingIndicator.RebuildPing += new hook_RebuildPing(PingIndicator_Overload);
		ChargeIndicatorController.TriggerPing += new hook_TriggerPing(ChargePing_Overload);
	}

	private void PingIndicator_Overload(orig_RebuildPing orig, PingIndicator self)
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self);
		float num = pingOwnerScaleMultiplier.Value;
		string text = ((TMP_Text)self.pingText).text;
		if (nullScaleInSingleplayer.Value && NetworkUser.readOnlyInstancesList.Count <= 1)
		{
			num = 0f;
		}
		int num2 = (int)Math.Round(num * 100f);
		string text2 = $"<size={num2}%>";
		string text3 = Regex.Replace(text, "^\\s*<size=\\d+%>", text2);
		if (text3 == text)
		{
			text3 = text2 + text;
		}
		((TMP_Text)self.pingText).text = text3;
		GameObject val = self.interactablePingGameObjects[0];
		if (trueScale == Vector3.zero)
		{
			trueScale = val.transform.localScale;
		}
		val.transform.localScale = trueScale * pingOwnerSpriteScale.Value;
	}

	private void ChargePing_Overload(orig_TriggerPing orig, ChargeIndicatorController self, string pingOwnerName, bool triggerAnimation)
	{
		float num = pingOwnerScaleMultiplier.Value;
		if (nullScaleInSingleplayer.Value && NetworkUser.readOnlyInstancesList.Count <= 1)
		{
			num = 0f;
		}
		int num2 = (int)Math.Round(num * 100f);
		string text = $"<size={num2}%>";
		string text2 = Regex.Replace(pingOwnerName, "^\\s*<size=\\d+%>", text);
		if (text2 == pingOwnerName)
		{
			text2 = text + pingOwnerName;
		}
		orig.Invoke(self, text2, triggerAnimation);
	}
}