Decompiled source of MultiplayerPermanentPings v1.0.0

MultiplayerPermanentPing.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MultiplayerPermanentPing")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+69790f9fb15e57dbf2c4dfcbea491af90705d461")]
[assembly: AssemblyProduct("MultiplayerPermanentPing")]
[assembly: AssemblyTitle("MultiplayerPermanentPing")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MultiplayerPermanentPing
{
	[BepInPlugin("com.pambe.permanentpings", "Multiplayer Permanent Pings", "1.0.0")]
	public class PermanentPingsPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_RebuildPing <>9__1_0;

			internal void <Awake>b__1_0(orig_RebuildPing orig, PingerController self, PingInfo npi)
			{
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				GameObject targetGameObject = ((PingInfo)(ref npi)).targetGameObject;
				Debug.Log((object)("[PermanentPings] RebuildPing called! target=" + (((targetGameObject != null) ? ((Object)targetGameObject).name : null) ?? "null")));
				if ((Object)(object)((PingInfo)(ref npi)).targetGameObject != (Object)null)
				{
					for (int num = permanentPings.Count - 1; num >= 0; num--)
					{
						if ((Object)(object)permanentPings[num].target == (Object)(object)((PingInfo)(ref npi)).targetGameObject)
						{
							Debug.Log((object)"[PermanentPings] Toggle off - removing ping");
							permanentPings[num].Destroy();
							permanentPings.RemoveAt(num);
							return;
						}
					}
				}
				orig.Invoke(self, npi);
				if ((Object)(object)((PingInfo)(ref npi)).targetGameObject != (Object)null)
				{
					PermanentPing item = new PermanentPing(npi, ((Component)self).gameObject);
					permanentPings.Add(item);
				}
			}
		}

		private static List<PermanentPing> permanentPings = new List<PermanentPing>();

		public void Awake()
		{
			//IL_001e: 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_0029: Expected O, but got Unknown
			Debug.Log((object)"[PermanentPings] Plugin loaded!");
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				hook_RebuildPing val = delegate(orig_RebuildPing orig, PingerController self, PingInfo npi)
				{
					//IL_0097: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
					GameObject targetGameObject = ((PingInfo)(ref npi)).targetGameObject;
					Debug.Log((object)("[PermanentPings] RebuildPing called! target=" + (((targetGameObject != null) ? ((Object)targetGameObject).name : null) ?? "null")));
					if ((Object)(object)((PingInfo)(ref npi)).targetGameObject != (Object)null)
					{
						for (int num = permanentPings.Count - 1; num >= 0; num--)
						{
							if ((Object)(object)permanentPings[num].target == (Object)(object)((PingInfo)(ref npi)).targetGameObject)
							{
								Debug.Log((object)"[PermanentPings] Toggle off - removing ping");
								permanentPings[num].Destroy();
								permanentPings.RemoveAt(num);
								return;
							}
						}
					}
					orig.Invoke(self, npi);
					if ((Object)(object)((PingInfo)(ref npi)).targetGameObject != (Object)null)
					{
						PermanentPing item = new PermanentPing(npi, ((Component)self).gameObject);
						permanentPings.Add(item);
					}
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			PingerController.RebuildPing += (hook_RebuildPing)obj;
		}
	}
	internal class PermanentPing
	{
		public GameObject target;

		public GameObject pingGO;

		private PingIndicator indicator;

		public PermanentPing(PingInfo npi, GameObject owner)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			target = ((PingInfo)(ref npi)).targetGameObject;
			pingGO = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("Prefabs/PingIndicator"));
			indicator = pingGO.GetComponent<PingIndicator>();
			if ((Object)(object)indicator != (Object)null)
			{
				indicator.pingOwner = owner;
				indicator.pingOrigin = npi.origin;
				indicator.pingNormal = npi.normal;
				indicator.pingTarget = ((PingInfo)(ref npi)).targetGameObject;
				indicator.RebuildPing();
				indicator.fixedTimer = float.PositiveInfinity;
			}
			DestroyOnTimer component = pingGO.GetComponent<DestroyOnTimer>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
		}

		public void Destroy()
		{
			if ((Object)(object)pingGO != (Object)null)
			{
				Object.Destroy((Object)(object)pingGO);
			}
		}
	}
}