Decompiled source of PingDistance v0.1.0

plugins/com.github.boxofbiscuits97.PingDistance.dll

Decompiled 3 days 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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.boxofbiscuits97.PingDistance")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.github.boxofbiscuits97.PingDistance")]
[assembly: AssemblyTitle("PingDistance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PingDistance
{
	[BepInPlugin("com.github.boxofbiscuits97.PingDistance", "PingDistance", "0.1.0")]
	public class PingDistance : BaseUnityPlugin
	{
		private static TMP_FontAsset? distanceFont;

		private static GameObject? distanceInstance;

		public const string Id = "com.github.boxofbiscuits97.PingDistance";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "PingDistance";

		public static string Version => "0.1.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			Harmony.CreateAndPatchAll(typeof(PingDistance), (string)null);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PointPinger), "ReceivePoint_Rpc")]
		private static void PingDistancePatch(PointPinger __instance, ref Vector3 __0, ref Vector3 __1)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)distanceInstance != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)distanceInstance);
				Object.Destroy((Object)(object)GameObject.Find("DistanceText(Clone)"));
			}
			Vector3 val = __0;
			Vector3 val2 = __1;
			Vector3 head = Character.localCharacter.Head;
			float num = Vector3.Distance(val, head);
			num = Mathf.Round(num);
			distanceInstance = new GameObject("DistanceText");
			TextMeshPro val3 = distanceInstance.AddComponent<TextMeshPro>();
			((TMP_Text)val3).text = num + "m";
			((TMP_Text)val3).fontSize = 3f;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
			((Graphic)val3).color = new Color(0.8745f, 0.8549f, 0.7608f, 1f);
			distanceInstance.AddComponent<BillboardToCamera>();
			if ((Object)(object)distanceFont == (Object)null)
			{
				TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				TMP_FontAsset[] array2 = array;
				foreach (TMP_FontAsset val4 in array2)
				{
					if (((Object)val4).name == "DarumaDropOne-Regular SDF")
					{
						distanceFont = val4;
						((TMP_Text)val3).font = distanceFont;
						break;
					}
				}
			}
			else
			{
				((TMP_Text)val3).font = distanceFont;
			}
			Object.Instantiate<GameObject>(distanceInstance);
			distanceInstance.transform.position = new Vector3(val.x + val2.x, val.y + val2.y, val.z + val2.z);
			Object.Destroy((Object)(object)distanceInstance, 1.25f);
			Object.Destroy((Object)(object)GameObject.Find("DistanceText(Clone)"));
		}
	}
	public class BillboardToCamera : MonoBehaviour
	{
		public float scaleFactor = 0.3f;

		private void LateUpdate()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Camera.main == (Object)null))
			{
				((Component)this).transform.LookAt(((Component)Camera.main).transform);
				((Component)this).transform.Rotate(0f, 180f, 0f);
				float num = Vector3.Distance(((Component)this).transform.position, ((Component)Camera.main).transform.position);
				((Component)this).transform.localScale = Vector3.one * num * scaleFactor;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}