diff --git a/.gitignore b/.gitignore index ed6d1d2..d16f686 100644 --- a/.gitignore +++ b/.gitignore @@ -400,3 +400,4 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml +/AssemblyReferences diff --git a/Managers/PingPongManager.cs b/Managers/PingPongManager.cs new file mode 100644 index 0000000..411dcb8 --- /dev/null +++ b/Managers/PingPongManager.cs @@ -0,0 +1,55 @@ +using System; +using UnityEngine; + +namespace Radium.PingPongPatch.Managers; + +public sealed class PingPongManager(IntPtr ptr) : MonoBehaviour(ptr) +{ + private PerformanceCounters performanceCounters; + + private void Awake() + => performanceCounters = FindObjectOfType(); + + private void OnGUI() + { + if (performanceCounters == null) + { + performanceCounters = FindObjectOfType(); + if (performanceCounters == null) + return; + } + + var x = 0f; + + if (Plugin.ShowFPS.Value) + { + var fps = performanceCounters.JLBFLIBDIIN; + + var text = $"FPS: {fps:F1}"; + var size = GUI.skin.label.CalcSize(new GUIContent(text)); + + GUI.Box(new Rect(x, 0, size.x + 12, 22), string.Empty); + GUI.Label(new Rect(x + 6, 1, size.x, 20), text); + + x += size.x + 12; + } + + if (Plugin.ShowPing.Value) + { + var ping = performanceCounters.GABBHJIKILN; + + var text = $"Ping: {ping}ms"; + var size = GUI.skin.label.CalcSize(new GUIContent(text)); + + var t = Mathf.Clamp01(ping / 270f); + var oldColor = GUI.contentColor; + + GUI.contentColor = t < 0.5f ? Color.Lerp(Color.green, Color.yellow, t * 2f) : Color.Lerp(Color.yellow, Color.red, (t - 0.5f) * 2f); + + GUI.Box(new Rect(x, 0, size.x + 12, 22), string.Empty); + GUI.Label(new Rect(x + 6, 1, size.x, 20), text); + + GUI.contentColor = oldColor; + } + } +} \ No newline at end of file diff --git a/Plugin.cs b/Plugin.cs new file mode 100644 index 0000000..265d185 --- /dev/null +++ b/Plugin.cs @@ -0,0 +1,45 @@ +using BepInEx; +using BepInEx.Configuration; +using BepInEx.Logging; +using BepInEx.Unity.IL2CPP; +using Radium.PingPongPatch.Managers; +using UnityEngine; + +namespace Radium.PingPongPatch; + +[BepInPlugin("com.radium.pingpong", "Radium.PingPongPatch", "1.0.0")] +internal class Plugin : BasePlugin +{ + internal static new ManualLogSource Log; + + #region Config + /// + /// If this plugin should be enabled or not or if we should break before anything gets patched + /// + internal static ConfigEntry Enabled; + + /// + /// Determines if we should show a UI for FPS + /// + internal static ConfigEntry ShowFPS; + /// + /// Determines if we should show a UI for local ping + /// + internal static ConfigEntry ShowPing; + #endregion + + public override void Load() + { + Log = base.Log; + + Enabled = Config.Bind(section: "General", key: "Enabled", defaultValue: true, description: "Determines if the patch is enabled."); + if (!Enabled.Value) return; + + ShowFPS = Config.Bind(section: "General", key: "Show FPS", defaultValue: true, description: "Determines if we should show a UI for FPS"); + ShowPing = Config.Bind(section: "General", key: "Show Ping", defaultValue: true, description: "Determines if we should show a UI for local ping"); + + AddComponent(); + + Log.LogInfo($"Ping, pong, ping, pong, ping, pong! Scram, you two! This is my bedroom now! No way, this is our REC ROOM"); + } +} \ No newline at end of file diff --git a/README.md b/README.md index 3c7ef20..7414d9c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Radium.PingPongPatch +![Ping Pong](media/ping-pong.gif) + Scram you two, this is my bedroom now! No way, this is our REC ROOM Displays FPS and Ping on screen platforms of Radium \ No newline at end of file diff --git a/Radium.PingPongPatch.csproj b/Radium.PingPongPatch.csproj new file mode 100644 index 0000000..a5ec749 --- /dev/null +++ b/Radium.PingPongPatch.csproj @@ -0,0 +1,38 @@ + + + + net6.0 + Radium.PingPongPatch + pingpong + 1.0.0 + true + latest + + https://api.nuget.org/v3/index.json; + https://nuget.bepinex.dev/v3/index.json; + https://nuget.samboy.dev/v3/index.json + + Radium.PingPongPatch + + + + + + + + + + AssemblyReferences\Assembly-CSharp.dll + + + AssemblyReferences\Il2Cppmscorlib.dll + + + AssemblyReferences\UnityEngine.IMGUIModule.dll + + + AssemblyReferences\UnityEngine.CoreModule.dll + + + + \ No newline at end of file diff --git a/media/ping-pong.gif b/media/ping-pong.gif new file mode 100644 index 0000000..17a5fac Binary files /dev/null and b/media/ping-pong.gif differ