Decompiled source of ImRightHere v1.0.1

ImRightHere.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ImRightHere")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImRightHere")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("53c8da4d-b81d-42b5-bb76-bf8e486312c2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ImRightHere;

public static class PinnedPings
{
	public static HashSet<long> PinnedTalkerIDs = new HashSet<long>();
}
[HarmonyPatch(typeof(Chat), "UpdateWorldTextField")]
public static class PingPatches_Appearance
{
	private static void Prefix(ref Chat __instance, ref WorldTextInstance wt)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_0030: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		if ((int)wt.m_type == 3)
		{
			wt.m_timer = __instance.m_worldTextTTL - Plugin.PingDuration.Value;
			((Graphic)wt.m_textMeshField).color = new Color(Plugin.PingColor.Value.r, Plugin.PingColor.Value.g, Plugin.PingColor.Value.b, Plugin.PingColor.Value.a);
		}
	}
}
[HarmonyPatch(typeof(Chat), "UpdateWorldTexts")]
public static class PingPatches_Distance
{
	private static void Postfix(ref List<WorldTextInstance> ___m_worldTexts)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Invalid comparison between Unknown and I4
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		foreach (WorldTextInstance ___m_worldText in ___m_worldTexts)
		{
			if ((int)___m_worldText.m_type == 3)
			{
				if (Plugin.PinOtherPings.Value && PinnedPings.PinnedTalkerIDs.Contains(___m_worldText.m_talkerID))
				{
					___m_worldText.m_timer = 0f;
				}
				if (Plugin.ShowDistance.Value)
				{
					Vector3 position = ((Component)Player.m_localPlayer).transform.position;
					Vector3 val = ___m_worldText.m_position - position;
					float num = (float)Math.Round(((Vector3)(ref val)).magnitude, 1);
					((TMP_Text)___m_worldText.m_textMeshField).SetText($"{___m_worldText.m_name}\n{num}m");
				}
			}
		}
	}
}
[HarmonyPatch(typeof(Minimap), "OnMapDblClick")]
public static class PingPatches_DblClick
{
	private static bool Prefix(Minimap __instance, float ___m_largeZoom)
	{
		//IL_0030: 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_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Invalid comparison between Unknown and I4
		//IL_009a: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		if (!Plugin.PinOtherPings.Value)
		{
			return true;
		}
		if ((Object)(object)Chat.instance == (Object)null)
		{
			return true;
		}
		Vector3 value = Traverse.Create((object)__instance).Method("ScreenToWorldPoint", new object[1] { Input.mousePosition }).GetValue<Vector3>();
		float num = __instance.m_removeRadius * ___m_largeZoom * 2f;
		List<WorldTextInstance> list = new List<WorldTextInstance>();
		Chat.instance.GetPingWorldTexts(list);
		WorldTextInstance val = null;
		float num2 = float.PositiveInfinity;
		Vector2 val3 = default(Vector2);
		foreach (WorldTextInstance item in list)
		{
			if ((int)item.m_type == 3 && item.m_talkerID != ZNet.GetUID())
			{
				Vector2 val2 = new Vector2(value.x, value.z);
				((Vector2)(ref val3))..ctor(item.m_position.x, item.m_position.z);
				float num3 = Vector2.Distance(val2, val3);
				if (num3 < num && num3 < num2)
				{
					val = item;
					num2 = num3;
				}
			}
		}
		if (val == null)
		{
			return true;
		}
		if (PinnedPings.PinnedTalkerIDs.Contains(val.m_talkerID))
		{
			PinnedPings.PinnedTalkerIDs.Remove(val.m_talkerID);
			Plugin.Log.LogInfo((object)("Unpinned ping from " + val.m_name));
		}
		else
		{
			PinnedPings.PinnedTalkerIDs.Add(val.m_talkerID);
			Plugin.Log.LogInfo((object)("Pinned ping from " + val.m_name));
		}
		return false;
	}
}
[BepInPlugin("com.vidguy.imrighthere", "ImRightHere", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
	public const string PluginGUID = "com.vidguy.imrighthere";

	public const string PluginName = "ImRightHere";

	public const string PluginVersion = "1.0.1";

	internal static ManualLogSource Log;

	public static ConfigEntry<KeyboardShortcut> PingHotkey;

	public static ConfigEntry<float> PingDuration;

	public static ConfigEntry<Color> PingColor;

	public static ConfigEntry<bool> ShowDistance;

	public static ConfigEntry<bool> PinOtherPings;

	private void Awake()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		PingHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "PingHotkey", new KeyboardShortcut((KeyCode)105, Array.Empty<KeyCode>()), "Hotkey to ping your current world position.");
		PingDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PingDuration", 10f, "How long pings remain visible, in seconds.");
		PingColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "PingColor", new Color(1f, 1f, 0f, 1f), "Color of your pings. Default is yellow.");
		ShowDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowDistance", true, "Show real-time distance from ping in meters.");
		PinOtherPings = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PinOtherPings", true, "Double-click another player's ping on the map to pin it persistently. Double-click again to unpin.");
		new Harmony("com.vidguy.imrighthere").PatchAll();
		Log.LogInfo((object)"ImRightHere version 1.0.1 has loaded!");
	}

	private void Update()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = PingHotkey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			TrySendPing();
		}
	}

	private void TrySendPing()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Chat.instance == (Object)null))
		{
			Vector3 position = ((Component)Player.m_localPlayer).transform.position;
			Chat.instance.SendPing(position);
		}
	}
}