Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PingSystem v1.0.0
PingSystem.dll
Decompiled 22 minutes agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 PingSystem { [BepInPlugin("wuguishifu.PingSystem", "PingSystem", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "wuguishifu.PingSystem"; public const string PluginName = "PingSystem"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<string> PingKey; internal static ConfigEntry<float> PingDuration; internal static ConfigEntry<float> MaxDistance; internal static ConfigEntry<float> MarkerScale; internal static ConfigEntry<float> Cooldown; private void Awake() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; PingKey = ((BaseUnityPlugin)this).Config.Bind<string>("Controls", "PingKey", "<Mouse>/middleButton", "Input System binding path for the ping key. Examples: <Mouse>/middleButton, <Keyboard>/g, <Keyboard>/z, <Mouse>/forwardButton, <Gamepad>/dpad/up"); PingDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Pings", "PingDuration", 6f, new ConfigDescription("Seconds a ping stays visible.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Pings", "MaxDistance", 150f, new ConfigDescription("How far away (in meters) you can ping.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 500f), Array.Empty<object>())); Cooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Pings", "Cooldown", 0.4f, new ConfigDescription("Minimum seconds between your pings.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); MarkerScale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "MarkerScale", 1f, new ConfigDescription("Size multiplier for ping markers and text.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>())); GameObject val = new GameObject("PingSystem") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); val.AddComponent<PingManager>(); Log.LogInfo((object)("PingSystem 1.0.0 loaded (key: " + PingKey.Value + ")")); } } internal class Ping { public int Actor; public string Owner; public Color Color; public Vector3 Position; public Transform Target; public Vector3 LocalOffset; public string FallbackLabel; public float SpawnTime; public Vector3 WorldPosition { get { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Target != (Object)null)) { return Position; } return Target.TransformPoint(LocalOffset); } } } internal class PingManager : MonoBehaviour, IOnEventCallback { private const byte PingEventCode = 147; private static readonly Color[] Palette = (Color[])(object)new Color[8] { new Color(1f, 0.78f, 0.1f), new Color(0.25f, 0.8f, 1f), new Color(1f, 0.35f, 0.35f), new Color(0.45f, 1f, 0.45f), new Color(0.85f, 0.5f, 1f), new Color(1f, 0.6f, 0.2f), new Color(1f, 0.5f, 0.8f), new Color(0.95f, 0.95f, 0.95f) }; private static readonly FieldRef<ValuableObject, float> ValuableDollarValue = AccessTools.FieldRefAccess<ValuableObject, float>("dollarValueCurrent"); private readonly Dictionary<int, Ping> _pings = new Dictionary<int, Ping>(); private InputAction _pingAction; private float _lastPingTime = -999f; private Texture2D _ring; private Texture2D _dot; private GUIStyle _labelStyle; private GUIStyle _subStyle; private void Awake() { BuildAction(); Plugin.PingKey.SettingChanged += delegate { BuildAction(); }; _ring = MakeCircleTexture(64, 0.7f, 1f); _dot = MakeCircleTexture(64, 0f, 0.35f); } private void OnEnable() { PhotonNetwork.AddCallbackTarget((object)this); } private void OnDisable() { PhotonNetwork.RemoveCallbackTarget((object)this); } private void BuildAction() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown InputAction pingAction = _pingAction; if (pingAction != null) { pingAction.Disable(); } InputAction pingAction2 = _pingAction; if (pingAction2 != null) { pingAction2.Dispose(); } try { _pingAction = new InputAction("Ping", (InputActionType)1, Plugin.PingKey.Value, (string)null, (string)null, (string)null); _pingAction.Enable(); } catch (Exception ex) { Plugin.Log.LogError((object)("Invalid PingKey '" + Plugin.PingKey.Value + "': " + ex.Message)); _pingAction = null; } } private static bool InGameplay() { try { return SemiFunc.RunIsLevel() || SemiFunc.RunIsShop() || SemiFunc.RunIsLobby() || SemiFunc.RunIsArena(); } catch { return false; } } private void Update() { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Invalid comparison between Unknown and I4 if (!InGameplay()) { if (_pings.Count > 0) { _pings.Clear(); } return; } if (_pings.Count > 0) { float time = Time.time; List<int> list = new List<int>(); foreach (KeyValuePair<int, Ping> ping in _pings) { if (time - ping.Value.SpawnTime > Plugin.PingDuration.Value) { list.Add(ping.Key); } } foreach (int item in list) { _pings.Remove(item); } } if (_pingAction != null && _pingAction.WasPressedThisFrame() && !(Time.time - _lastPingTime < Plugin.Cooldown.Value) && (int)Cursor.lockState == 1 && SemiFunc.NoTextInputsActive()) { TryPing(); } } private void TryPing() { //IL_0025: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown Camera main = Camera.main; PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if ((Object)(object)main == (Object)null || (Object)(object)val == (Object)null) { return; } RaycastHit[] array = Physics.RaycastAll(new Ray(((Component)main).transform.position, ((Component)main).transform.forward), Plugin.MaxDistance.Value, -5, (QueryTriggerInteraction)1); if (array.Length == 0) { return; } Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); Transform root = ((Component)val).transform.root; Transform val2 = (((Object)(object)PlayerController.instance != (Object)null) ? ((Component)PlayerController.instance).transform.root : null); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val3 = array2[num]; Transform root2 = ((Component)((RaycastHit)(ref val3)).collider).transform.root; if (!((Object)(object)root2 == (Object)(object)root) && !((Object)(object)root2 == (Object)(object)val2)) { PhotonView componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<PhotonView>(); int num2 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.ViewID : 0); string text = Describe(((Component)((RaycastHit)(ref val3)).collider).gameObject); string text2 = SemiFunc.PlayerGetName(val) ?? "Player"; _lastPingTime = Time.time; int actor = ((PhotonNetwork.LocalPlayer == null) ? 1 : PhotonNetwork.LocalPlayer.ActorNumber); AddPing(actor, text2, ((RaycastHit)(ref val3)).point, num2, text); if (PhotonNetwork.InRoom && !PhotonNetwork.OfflineMode) { object[] array3 = new object[4] { ((RaycastHit)(ref val3)).point, num2, text, text2 }; PhotonNetwork.RaiseEvent((byte)147, (object)array3, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } break; } } } public void OnEvent(EventData photonEvent) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (photonEvent.Code != 147) { return; } try { if (photonEvent.CustomData is object[] array && array.Length >= 4) { AddPing(photonEvent.Sender, (string)array[3], (Vector3)array[0], (int)array[1], (string)array[2]); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Bad ping event: " + ex.Message)); } } private void AddPing(int actor, string owner, Vector3 point, int viewId, string label) { //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_0032: 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_0074: 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) Ping ping = new Ping { Actor = actor, Owner = owner, Color = Palette[Mathf.Abs(actor) % Palette.Length], Position = point, FallbackLabel = label, SpawnTime = Time.time }; if (viewId != 0) { PhotonView val = PhotonView.Find(viewId); if ((Object)(object)val != (Object)null) { ping.Target = ((Component)val).transform; ping.LocalOffset = ((Component)val).transform.InverseTransformPoint(point); } } _pings[actor] = ping; } private static string Describe(GameObject go) { EnemyParent componentInParent = go.GetComponentInParent<EnemyParent>(); if ((Object)(object)componentInParent != (Object)null) { if (!string.IsNullOrEmpty(componentInParent.enemyName)) { return "Enemy: " + componentInParent.enemyName; } return "Enemy"; } ValuableObject componentInParent2 = go.GetComponentInParent<ValuableObject>(); if ((Object)(object)componentInParent2 != (Object)null) { int num = Mathf.RoundToInt(ValuableDollarValue.Invoke(componentInParent2)); if (num <= 0) { return "Valuable"; } return "Valuable $" + SemiFunc.DollarGetString(num); } ItemAttributes componentInParent3 = go.GetComponentInParent<ItemAttributes>(); if ((Object)(object)componentInParent3 != (Object)null) { if (!((Object)(object)componentInParent3.item != (Object)null) || string.IsNullOrEmpty(componentInParent3.item.itemName)) { return "Item"; } return componentInParent3.item.itemName; } PlayerAvatar componentInParent4 = go.GetComponentInParent<PlayerAvatar>(); if ((Object)(object)componentInParent4 != (Object)null) { return SemiFunc.PlayerGetName(componentInParent4) ?? "Player"; } if ((Object)(object)go.GetComponentInParent<PhysGrabCart>() != (Object)null) { return "Cart"; } if ((Object)(object)go.GetComponentInParent<ExtractionPoint>() != (Object)null) { return "Extraction"; } return "Here"; } private string CurrentLabel(Ping ping) { if ((Object)(object)ping.Target != (Object)null) { try { return Describe(((Component)ping.Target).gameObject); } catch { } } return ping.FallbackLabel; } private void OnGUI() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0079: 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_008a: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) if (_pings.Count == 0 || (int)Event.current.type != 7) { return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null) { return; } float num = (float)Screen.height / 1080f * Plugin.MarkerScale.Value; if (_labelStyle == null) { _labelStyle = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontStyle = (FontStyle)1 }; _subStyle = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4 }; } _labelStyle.fontSize = Mathf.RoundToInt(20f * num); _subStyle.fontSize = Mathf.RoundToInt(15f * num); Color color = GUI.color; Vector2 down = default(Vector2); foreach (Ping value in _pings.Values) { Vector3 worldPosition = value.WorldPosition; Vector3 val = main.WorldToViewportPoint(worldPosition); bool num2 = val.z < 0f; if (num2) { val.x = 1f - val.x; val.y = 1f - val.y; } float num3 = 40f * num; float num4 = val.x * (float)Screen.width; float num5 = (1f - val.y) * (float)Screen.height; bool flag = num2 || num4 < num3 || num4 > (float)Screen.width - num3 || num5 < num3 || num5 > (float)Screen.height - num3; if (num2) { ((Vector2)(ref down))..ctor(num4 - (float)Screen.width / 2f, num5 - (float)Screen.height / 2f); if (((Vector2)(ref down)).sqrMagnitude < 1f) { down = Vector2.down; } ((Vector2)(ref down)).Normalize(); num4 = (float)Screen.width / 2f + down.x * (float)Screen.width; num5 = (float)Screen.height / 2f + down.y * (float)Screen.height; } num4 = Mathf.Clamp(num4, num3, (float)Screen.width - num3); num5 = Mathf.Clamp(num5, num3, (float)Screen.height - num3); float num6 = Time.time - value.SpawnTime; float num7 = Mathf.Clamp01((Plugin.PingDuration.Value - num6) / 1f); float num8 = 1f + 0.6f * Mathf.Clamp01(1f - num6 / 0.25f); if (num6 < 0.8f) { float num9 = num6 / 0.8f; float num10 = Mathf.Lerp(16f, 60f, num9) * num; GUI.color = new Color(value.Color.r, value.Color.g, value.Color.b, (1f - num9) * num7); GUI.DrawTexture(new Rect(num4 - num10, num5 - num10, num10 * 2f, num10 * 2f), (Texture)(object)_ring); } float num11 = 16f * num * num8 * (flag ? 0.8f : 1f); GUI.color = new Color(0f, 0f, 0f, 0.5f * num7); GUI.DrawTexture(new Rect(num4 - num11 - 2f, num5 - num11 - 2f, num11 * 2f + 4f, num11 * 2f + 4f), (Texture)(object)_ring); GUI.color = new Color(value.Color.r, value.Color.g, value.Color.b, num7); GUI.DrawTexture(new Rect(num4 - num11, num5 - num11, num11 * 2f, num11 * 2f), (Texture)(object)_ring); GUI.DrawTexture(new Rect(num4 - num11, num5 - num11, num11 * 2f, num11 * 2f), (Texture)(object)_dot); int num12 = Mathf.RoundToInt(Vector3.Distance(((Component)main).transform.position, worldPosition)); string text = CurrentLabel(value); string text2 = $"{value.Owner} · {num12}m"; float num13 = 400f * num; float num14 = 26f * num; float num15 = num5 - num11 - num14 * 2.1f; if (num15 < 4f) { num15 = num5 + num11 + 4f; } DrawShadowed(new Rect(num4 - num13 / 2f, num15, num13, num14), text, _labelStyle, new Color(1f, 1f, 1f, num7), num7); DrawShadowed(new Rect(num4 - num13 / 2f, num15 + num14, num13, num14), text2, _subStyle, new Color(value.Color.r, value.Color.g, value.Color.b, num7), num7); } GUI.color = color; } private static void DrawShadowed(Rect rect, string text, GUIStyle style, Color color, float alpha) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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) //IL_0071: Unknown result type (might be due to invalid IL or missing references) GUI.color = Color.white; style.normal.textColor = new Color(0f, 0f, 0f, 0.8f * alpha); GUI.Label(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style); style.normal.textColor = color; GUI.Label(rect, text, style); } private static Texture2D MakeCircleTexture(int size, float inner, float outer) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; float num = (float)(size - 1) / 2f; float num2 = 1.5f / num; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)) / num; float num4 = Mathf.Clamp01((outer - num3) / num2); if (inner > 0f) { num4 *= Mathf.Clamp01((num3 - inner) / num2); } val.SetPixel(j, i, new Color(1f, 1f, 1f, num4)); } } val.Apply(); ((Object)val).hideFlags = (HideFlags)61; return val; } } }