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;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FPS Counter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FPS Counter")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("098e08ae-fcf1-404e-857d-c1e2b1100add")]
[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")]
[BepInPlugin("sekond.yapyap.fpscounter", "YAPYAP FPS Counter", "1.3")]
public class FPSCounter : BaseUnityPlugin
{
private GameObject canvasObject;
private GameObject fpsObject;
private Text fpsText;
private float deltaTime;
private bool visible = true;
private ConfigEntry<bool> enabledConfig;
private ConfigEntry<KeyCode> toggleKey;
private void Awake()
{
enabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable FPS counter");
toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleKey", (KeyCode)283, "Toggle FPS counter");
if (enabledConfig.Value)
{
CreateCanvasAndUI();
}
}
private void Update()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)fpsText == (Object)null || !enabledConfig.Value)
{
return;
}
if (Input.GetKeyDown(toggleKey.Value))
{
visible = !visible;
fpsObject.SetActive(visible);
}
if (Time.timeScale == 0f)
{
fpsObject.SetActive(false);
return;
}
if (visible)
{
fpsObject.SetActive(true);
}
deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
int num = Mathf.RoundToInt(1f / deltaTime);
fpsText.text = num + " FPS";
((Graphic)fpsText).color = ((num <= 10) ? Color.red : Color.white);
}
private void CreateCanvasAndUI()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_00ca: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: 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_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
canvasObject = new GameObject("FPSCounterCanvas");
Object.DontDestroyOnLoad((Object)(object)canvasObject);
Canvas val = canvasObject.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 9999;
canvasObject.AddComponent<CanvasScaler>();
canvasObject.AddComponent<GraphicRaycaster>();
fpsObject = new GameObject("FPSCounter");
fpsObject.transform.SetParent(canvasObject.transform, false);
fpsText = fpsObject.AddComponent<Text>();
fpsText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
fpsText.fontSize = 14;
fpsText.alignment = (TextAnchor)2;
((Graphic)fpsText).color = Color.white;
fpsText.text = "FPS";
Outline val2 = fpsObject.AddComponent<Outline>();
((Shadow)val2).effectColor = Color.black;
((Shadow)val2).effectDistance = new Vector2(1f, -1f);
RectTransform component = fpsObject.GetComponent<RectTransform>();
component.anchorMin = new Vector2(1f, 1f);
component.anchorMax = new Vector2(1f, 1f);
component.pivot = new Vector2(1f, 1f);
component.anchoredPosition = new Vector2(-15f, -5f);
component.sizeDelta = new Vector2(100f, 25f);
((BaseUnityPlugin)this).Logger.LogInfo((object)"FPS Counter created successfully");
}
}