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 BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MycopunkShared;
using Netcode.Transports.Facepunch;
using Steamworks;
using Steamworks.Data;
using Unity.Netcode;
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("MycopunkSystemMonitor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2+fe8cef1291afd0a7f7ea8a9ddfd28d3607c4cdd5")]
[assembly: AssemblyProduct("MycopunkSystemMonitor")]
[assembly: AssemblyTitle("MycopunkSystemMonitor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[module: UnverifiableCode]
[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 MycopunkSystemMonitor
{
internal static class MenuText
{
private static readonly Dictionary<string, Dictionary<string, string>> Names = new Dictionary<string, Dictionary<string, string>>
{
["en"] = new Dictionary<string, string>
{
["monitor.top"] = "Show at top",
["monitor.right"] = "Show on right"
},
["ja"] = new Dictionary<string, string>
{
["monitor.top"] = "画面の上に表示",
["monitor.right"] = "画面の右に表示"
}
};
private static readonly Dictionary<string, Dictionary<string, string>> Descriptions = new Dictionary<string, Dictionary<string, string>> { ["ja"] = new Dictionary<string, string>
{
["monitor.top"] = "モニターを画面の下ではなく上に表示します。",
["monitor.right"] = "モニターを画面の左ではなく右に表示します。"
} };
public static object[] Label(string key)
{
return ModsMenuTag.Label(key, (IDictionary<string, Dictionary<string, string>>)Names, (IDictionary<string, Dictionary<string, string>>)Descriptions);
}
}
internal static class MonitorText
{
public static string Format(float fps, bool client, int ping)
{
string text = $"FPS {fps:F0}";
if (!client)
{
return text;
}
return text + ((ping > 0) ? $" / PING {ping} ms" : " / PING --");
}
}
[BepInPlugin("f1w3.mycopunk.systemmonitor", "Mycopunk System Monitor", "0.1.2")]
[BepInDependency("doku_macaron.mycopunk.macaroncore", "1.1.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private Harmony _harmony;
private float _elapsed;
private int _frames;
private string _text = "FPS --";
private GUIStyle _style;
private readonly GUIContent _content = new GUIContent();
private ConfigEntry<bool> _top;
private ConfigEntry<bool> _right;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
_top = ((BaseUnityPlugin)this).Config.Bind<bool>("Position", "Top", false, new ConfigDescription("Show the monitor at the top of the screen instead of the bottom.", (AcceptableValueBase)null, MenuText.Label("monitor.top")));
_right = ((BaseUnityPlugin)this).Config.Bind<bool>("Position", "Right", false, new ConfigDescription("Show the monitor at the right of the screen instead of the left.", (AcceptableValueBase)null, MenuText.Label("monitor.right")));
_harmony = new Harmony("f1w3.mycopunk.systemmonitor");
ModsMenu.Install(_harmony, (BaseUnityPlugin)(object)this);
}
private void Update()
{
//IL_0087: 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)
_elapsed += Time.unscaledDeltaTime;
_frames++;
if (_elapsed < 0.5f)
{
return;
}
NetworkManager singleton = NetworkManager.Singleton;
bool flag = (Object)(object)singleton != (Object)null && singleton.IsConnectedClient && !singleton.IsServer;
int ping = 0;
if (flag)
{
NetworkTransport networkTransport = singleton.NetworkConfig.NetworkTransport;
FacepunchTransport val = (FacepunchTransport)(object)((networkTransport is FacepunchTransport) ? networkTransport : null);
if (val != null)
{
ConnectionManager connectionManager = val.connectionManager;
if (connectionManager != null && connectionManager.Connected)
{
ConnectionStatus val2 = ((Connection)(ref connectionManager.Connection)).QuickStatus();
ping = ((ConnectionStatus)(ref val2)).Ping;
}
}
}
_text = MonitorText.Format((float)_frames / _elapsed, flag, ping);
_elapsed = 0f;
_frames = 0;
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void OnGUI()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Invalid comparison between Unknown and I4
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_0051: Expected O, but got Unknown
//IL_0051: 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_0060: Expected O, but got Unknown
//IL_0065: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: 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_0184: Unknown result type (might be due to invalid IL or missing references)
if ((int)Event.current.type == 7)
{
if (_style == null)
{
_style = new GUIStyle(GUI.skin.label)
{
fontStyle = (FontStyle)1,
alignment = (TextAnchor)3,
wordWrap = false,
clipping = (TextClipping)0,
padding = new RectOffset(0, 0, 0, 0),
margin = new RectOffset(0, 0, 0, 0)
};
}
float num = (float)Screen.height / 1080f;
_style.fontSize = Mathf.Max(1, Mathf.RoundToInt(14f * num));
_content.text = _text;
Vector2 val = _style.CalcSize(_content);
float num2 = val.x + 12f * num;
float num3 = val.y + 6f * num;
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(_right.Value ? ((float)Screen.width - num2) : 0f, _top.Value ? 0f : ((float)Screen.height - num3), num2, num3);
Color color = GUI.color;
GUI.color = new Color(0f, 0f, 0f, 0.6f);
GUI.DrawTexture(val2, (Texture)(object)Texture2D.whiteTexture);
GUI.color = color;
_style.normal.textColor = Color.white;
GUI.Label(new Rect(((Rect)(ref val2)).x + 6f * num, ((Rect)(ref val2)).y + 3f * num, val.x, val.y), _content, _style);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}