using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PingMonitor")]
[assembly: AssemblyTitle("PingMonitor")]
[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.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 Empress.PingMonitor
{
[BepInPlugin("Empress.PingMonitor", "Ping Monitor", "1.0.0")]
public class PingMonitorPlugin : BaseUnityPlugin
{
internal static PingMonitorPlugin Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; private set; }
internal static ConfigEntry<bool> AlwaysShowSelfPing { get; private set; }
private void Awake()
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
AlwaysShowSelfPing = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AlwaysShowSelfPing", true, "If enabled, your own ping is always displayed at the top-left of the screen during multiplayer.");
Harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony.PatchAll();
((Component)this).gameObject.AddComponent<PingHUD>();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded. Pretty pings online. AlwaysTopLeft={AlwaysShowSelfPing.Value}");
}
private void OnDestroy()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
internal class PingHUD : MonoBehaviour
{
private GUIStyle _backgroundStyle;
private GUIStyle _titleStyle;
private GUIStyle _selfPingStyle;
private GUIStyle _playerLineStyle;
private GUIStyle _youStyle;
private GUIStyle _cornerBackStyle;
private GUIStyle _cornerPingStyle;
private float _pingUpdateTimer = 0f;
private int _lastSelfPing = -1;
private const float WindowWidth = 280f;
private const float WindowPadding = 12f;
private const float LineHeight = 26f;
private Rect _windowRect = new Rect(20f, 20f, 280f, 200f);
private void Update()
{
if (!SemiFunc.IsMultiplayer())
{
_lastSelfPing = -1;
return;
}
_pingUpdateTimer -= Time.deltaTime;
if (_pingUpdateTimer <= 0f)
{
try
{
_lastSelfPing = PhotonNetwork.GetPing();
}
catch
{
_lastSelfPing = -1;
}
_pingUpdateTimer = 1f;
}
}
private void InitStyles()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0032: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: 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)
//IL_00da: Expected O, but got Unknown
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: 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_0129: Expected O, but got Unknown
//IL_0130: 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_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_0163: 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)
//IL_017a: Expected O, but got Unknown
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Expected O, but got Unknown
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Expected O, but got Unknown
if (_backgroundStyle == null)
{
Texture2D val = new Texture2D(1, 1);
val.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.75f));
val.Apply();
GUIStyle val2 = new GUIStyle();
val2.normal.background = val;
_backgroundStyle = val2;
GUIStyle val3 = new GUIStyle(GUI.skin.label)
{
fontSize = 16,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
val3.normal.textColor = Color.cyan;
_titleStyle = val3;
GUIStyle val4 = new GUIStyle(GUI.skin.label)
{
fontSize = 28,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)4
};
val4.normal.textColor = Color.white;
_selfPingStyle = val4;
GUIStyle val5 = new GUIStyle(GUI.skin.label)
{
fontSize = 15,
alignment = (TextAnchor)3,
padding = new RectOffset(8, 8, 4, 4)
};
val5.normal.textColor = Color.white;
val5.richText = true;
_playerLineStyle = val5;
GUIStyle val6 = new GUIStyle(_playerLineStyle);
val6.normal.textColor = new Color(0.4f, 1f, 0.4f);
val6.fontStyle = (FontStyle)1;
_youStyle = val6;
GUIStyle val7 = new GUIStyle();
val7.normal.background = val;
_cornerBackStyle = val7;
GUIStyle val8 = new GUIStyle(GUI.skin.label)
{
fontSize = 18,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)3,
padding = new RectOffset(8, 8, 4, 4)
};
val8.normal.textColor = Color.white;
_cornerPingStyle = val8;
}
}
private Color GetPingColor(int ping)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_002f: 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_0055: 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_004d: 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)
if (ping < 50)
{
return new Color(0.4f, 1f, 0.4f);
}
if (ping < 100)
{
return Color.yellow;
}
if (ping < 200)
{
return new Color(1f, 0.6f, 0f);
}
return Color.red;
}
private void DrawCornerPing()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
InitStyles();
string text = ((_lastSelfPing >= 0) ? $"{_lastSelfPing} ms" : "-- ms");
GUIContent val = new GUIContent(text);
Vector2 val2 = _cornerPingStyle.CalcSize(val);
float num = 6f;
float num2 = 4f;
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(10f, 10f, val2.x + (float)_cornerPingStyle.padding.horizontal + num * 2f, val2.y + (float)_cornerPingStyle.padding.vertical + num2 * 2f);
GUI.Box(val3, GUIContent.none, _cornerBackStyle);
Color color = GUI.color;
GUI.color = ((_lastSelfPing >= 0) ? GetPingColor(_lastSelfPing) : Color.gray);
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(((Rect)(ref val3)).x + num, ((Rect)(ref val3)).y + num2, ((Rect)(ref val3)).width - num * 2f, ((Rect)(ref val3)).height - num2 * 2f);
GUI.Label(val4, val, _cornerPingStyle);
GUI.color = color;
}
private void OnGUI()
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (PingMonitorPlugin.AlwaysShowSelfPing.Value && SemiFunc.IsMultiplayer())
{
DrawCornerPing();
}
if (SemiFunc.IsMultiplayer() && !((Object)(object)MenuManager.instance == (Object)null) && !((Object)(object)GameDirector.instance == (Object)null) && !((Object)(object)MenuManager.instance.currentMenuPage == (Object)null) && (int)MenuManager.instance.currentMenuPageIndex == 1)
{
InitStyles();
_windowRect = GUILayout.Window(696969, _windowRect, new WindowFunction(DrawWindow), "", _backgroundStyle, Array.Empty<GUILayoutOption>());
((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width);
((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height);
}
}
private void DrawWindow(int id)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
GUILayout.Label("PING MONITOR", _titleStyle, Array.Empty<GUILayoutOption>());
string text = ((_lastSelfPing >= 0) ? $"{_lastSelfPing}" : "--");
Color color = GUI.color;
GUI.color = ((_lastSelfPing >= 0) ? GetPingColor(_lastSelfPing) : Color.gray);
GUILayout.Label(text + " ms", _selfPingStyle, Array.Empty<GUILayoutOption>());
GUI.color = color;
GUILayout.Space(10f);
List<PlayerAvatar> list = (from p in GameDirector.instance.PlayerList?.Where((PlayerAvatar p) => (Object)(object)p != (Object)null)
orderby !p.isLocal, p.playerName
select p).ToList() ?? new List<PlayerAvatar>();
foreach (PlayerAvatar item in list)
{
string text2 = (string.IsNullOrEmpty(item.playerName) ? "<unnamed>" : item.playerName);
int playerPing = item.playerPing;
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (item.isLocal)
{
GUILayout.Label("[*]", _youStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
}
GUILayout.Label(text2, _playerLineStyle, Array.Empty<GUILayoutOption>());
string text3 = ((playerPing > 0) ? playerPing.ToString() : "--");
Color color2 = ((playerPing > 0) ? GetPingColor(playerPing) : Color.gray);
GUI.color = color2;
GUILayout.Label(text3 + " ms", _playerLineStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
GUI.color = Color.white;
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
}
}
}