Decompiled source of REPO FPS Counter v1.0.3

RepoFPSCounter.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RepoFPSCounter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RepoFPSCounter")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e6f9f96b-0cb1-4d2b-82b9-b36953b345fe")]
[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 RepoFPSCounter;

public enum FPSColor
{
	Green,
	White,
	Red,
	Blue,
	Cyan,
	Yellow,
	Magenta,
	Pink,
	Black
}
public enum ScreenPosition
{
	TopLeft,
	TopCenter,
	TopRight,
	MiddleLeft,
	MiddleRight,
	BottomLeft,
	BottomCenter,
	BottomRight
}
[BepInPlugin("com.MishkaFreddy.REPO_FPS_Counter", "REPO FPS Counter", "1.0.3")]
public class FPSPlugin : BaseUnityPlugin
{
	private float deltaTime = 0f;

	private GUIStyle style;

	private GUIStyle shadowStyle;

	private ConfigEntry<bool> enableFPS;

	private ConfigEntry<int> fontSize;

	private ConfigEntry<FPSColor> selectedColor;

	private ConfigEntry<ScreenPosition> selectedPosition;

	private void Awake()
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		enableFPS = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable FPS Counter", true, "Toggle the FPS counter on or off.");
		fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "Font Size", 25, new ConfigDescription("Set the font size of the FPS text.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 80), Array.Empty<object>()));
		selectedColor = ((BaseUnityPlugin)this).Config.Bind<FPSColor>("Appearance", "Text Color", FPSColor.Green, "Select the text color for the FPS counter.");
		selectedPosition = ((BaseUnityPlugin)this).Config.Bind<ScreenPosition>("Appearance", "Position", ScreenPosition.TopLeft, "Select the screen position for the FPS counter.");
	}

	private void Update()
	{
		if (enableFPS.Value)
		{
			deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
		}
	}

	private void OnGUI()
	{
		//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)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: 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_0141: 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_0035: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		if (enableFPS.Value)
		{
			if (style == null)
			{
				style = new GUIStyle();
				shadowStyle = new GUIStyle();
			}
			TextAnchor alignment = GetAlignment(selectedPosition.Value);
			style.alignment = alignment;
			shadowStyle.alignment = alignment;
			style.fontSize = fontSize.Value;
			style.normal.textColor = GetColor(selectedColor.Value);
			shadowStyle.fontSize = fontSize.Value;
			shadowStyle.normal.textColor = Color.black;
			float num = 1f / deltaTime;
			string text = $"{num:0.} FPS";
			Rect rect = GetRect(selectedPosition.Value);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 1f, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height);
			GUI.Label(val, text, shadowStyle);
			GUI.Label(rect, text, style);
		}
	}

	private TextAnchor GetAlignment(ScreenPosition position)
	{
		//IL_002e: 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_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0046: 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_0051: 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)
		return (TextAnchor)(position switch
		{
			ScreenPosition.TopLeft => 0, 
			ScreenPosition.TopCenter => 1, 
			ScreenPosition.TopRight => 2, 
			ScreenPosition.MiddleLeft => 3, 
			ScreenPosition.MiddleRight => 5, 
			ScreenPosition.BottomLeft => 6, 
			ScreenPosition.BottomCenter => 7, 
			ScreenPosition.BottomRight => 8, 
			_ => 0, 
		});
	}

	private Rect GetRect(ScreenPosition position)
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: 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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		int num = 10;
		int num2 = 300;
		int num3 = 100;
		return (Rect)(position switch
		{
			ScreenPosition.TopLeft => new Rect((float)num, (float)num, (float)num2, (float)num3), 
			ScreenPosition.TopCenter => new Rect((float)(Screen.width - num2) / 2f, (float)num, (float)num2, (float)num3), 
			ScreenPosition.TopRight => new Rect((float)(Screen.width - num2 - num), (float)num, (float)num2, (float)num3), 
			ScreenPosition.MiddleLeft => new Rect((float)num, (float)(Screen.height - num3) / 2f, (float)num2, (float)num3), 
			ScreenPosition.MiddleRight => new Rect((float)(Screen.width - num2 - num), (float)(Screen.height - num3) / 2f, (float)num2, (float)num3), 
			ScreenPosition.BottomLeft => new Rect((float)num, (float)(Screen.height - num3 - num), (float)num2, (float)num3), 
			ScreenPosition.BottomCenter => new Rect((float)(Screen.width - num2) / 2f, (float)(Screen.height - num3 - num), (float)num2, (float)num3), 
			ScreenPosition.BottomRight => new Rect((float)(Screen.width - num2 - num), (float)(Screen.height - num3 - num), (float)num2, (float)num3), 
			_ => new Rect((float)num, (float)num, (float)num2, (float)num3), 
		});
	}

	private Color GetColor(FPSColor color)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: 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_0060: 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_0070: 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_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)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		return (Color)(color switch
		{
			FPSColor.White => Color.white, 
			FPSColor.Red => Color.red, 
			FPSColor.Blue => Color.blue, 
			FPSColor.Cyan => new Color(0f, 1f, 1f), 
			FPSColor.Yellow => Color.yellow, 
			FPSColor.Green => Color.green, 
			FPSColor.Magenta => Color.magenta, 
			FPSColor.Pink => new Color(1f, 0.41f, 0.71f), 
			FPSColor.Black => Color.black, 
			_ => Color.green, 
		});
	}
}