Decompiled source of PingDistance v0.2.0

plugins/com.github.boxofbiscuits97.PingDistance.dll

Decompiled 3 weeks 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;

[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.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: AssemblyProduct("com.github.boxofbiscuits97.PingDistance")]
[assembly: AssemblyTitle("PingDistance")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.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.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		private static GameObject? distanceText;

		private static GameObject? distanceInstance;

		private static GameObject? PingDistanceCanvas;

		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.2.0";

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

		[HarmonyPrefix]
		[HarmonyPatch(typeof(PointPinger), "ReceivePoint_Rpc")]
		private static void PingDistancePatch(PointPinger __instance, ref Vector3 __0, ref Vector3 __1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = __0;
			Vector3 val2 = __1;
			Vector3 position = default(Vector3);
			((Vector3)(ref position))..ctor(val.x + val2.x, val.y + val2.y, val.z + val2.z);
			if ((Object)(object)PingDistanceCanvas == (Object)null)
			{
				GameObject val3 = GameObject.Find("GAME/GUIManager");
				GameObject val4 = GameObject.Find("GAME/GUIManager/Canvas_Names");
				PingDistanceCanvas = Object.Instantiate<GameObject>(val4, val3.transform);
				((Object)PingDistanceCanvas).name = "Canvas_PingDistance";
				UIPlayerNames val5 = default(UIPlayerNames);
				PingDistanceCanvas.TryGetComponent<UIPlayerNames>(ref val5);
				Object.Destroy((Object)(object)val5);
				Log.LogInfo((object)PingDistanceCanvas.transform.childCount);
				distanceText = ((Component)PingDistanceCanvas.transform.GetChild(0)).gameObject;
				((Object)distanceText).name = "DistanceText";
				for (int i = 0; i < PingDistanceCanvas.transform.childCount; i++)
				{
					GameObject gameObject = ((Component)PingDistanceCanvas.transform.GetChild(i)).gameObject;
					if (((Object)gameObject).name.Contains("UI_PlayerName"))
					{
						Object.Destroy((Object)(object)gameObject);
					}
				}
				PlayerName val6 = default(PlayerName);
				distanceText.TryGetComponent<PlayerName>(ref val6);
				Object.Destroy((Object)(object)val6);
				Object.Destroy((Object)(object)((Component)distanceText.transform.GetChild(0)).gameObject);
				distanceText.AddComponent<PingDistance>();
			}
			if (!((Object)(object)distanceText == (Object)null))
			{
				if ((Object)(object)distanceInstance != (Object)null)
				{
					Object.Destroy((Object)(object)distanceInstance);
				}
				distanceInstance = Object.Instantiate<GameObject>(distanceText, PingDistanceCanvas.transform);
				distanceInstance.SetActive(true);
				PingDistance component = distanceInstance.GetComponent<PingDistance>();
				component.position = position;
				component.character = __instance.character;
				Object.Destroy((Object)(object)distanceInstance, 1.25f);
			}
		}
	}
	public class PingDistance : MonoBehaviour
	{
		public float scaleFactor = 0.3f;

		public Vector3 position;

		public Character? character;

		private TextMeshProUGUI? tmp;

		private void LateUpdate()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00a0: 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)Camera.main == (Object)null))
			{
				if ((Object)(object)tmp == (Object)null)
				{
					tmp = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
				}
				float num = Vector3.Angle(((Component)MainCamera.instance).transform.forward, position - ((Component)MainCamera.instance).transform.position);
				((Component)tmp).gameObject.SetActive(num < 90f);
				((TMP_Text)tmp).fontSize = 30f;
				((Component)this).transform.position = MainCamera.instance.cam.WorldToScreenPoint(position);
				float num2 = Vector3.Distance(position, ((Component)Camera.main).transform.position);
				num2 = Mathf.Round(num2);
				((TMP_Text)tmp).text = num2 + "m";
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}