using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("FPSLimitMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FPSLimitMod")] [assembly: AssemblyTitle("FPSLimitMod")] [assembly: AssemblyVersion("1.0.0.0")] [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; } } } [BepInPlugin("com.liamgaming.fpslimitmod", "FPSLimitMod", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class FPSLimitModPlugin : BaseUnityPlugin { private ConfigEntry fpsLimit; private ConfigEntry showFps; private ConfigEntry fpsRight; private GameObject fpsCanvas; private Text fpsText; private Font mainFont; private float fpsMeasurePeriod = 0.2f; private float fpsNextPeriod = 0f; private int fpsAccumulator = 0; private float currentFps = 0f; private void Awake() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown ModRegistry.Register(new ModEntry { ModName = "FPSLimitMod", ModType = ((object)this).GetType() }); fpsLimit = ((BaseUnityPlugin)this).Config.Bind("General", "FPS Limit", 60f, "Limits the game framerate."); showFps = ((BaseUnityPlugin)this).Config.Bind("General", "Show FPS", false, "Displays real-time FPS overlay."); fpsRight = ((BaseUnityPlugin)this).Config.Bind("General", "FPS Position - Right Side", false, "Aligns FPS overlay to the right side of the screen."); ApplyFpsLimit(); fpsLimit.SettingChanged += delegate { ApplyFpsLimit(); }; showFps.SettingChanged += delegate { UpdateFpsCounterState(); }; fpsRight.SettingChanged += delegate { UpdateFpsCounterPosition(); }; } private void ApplyFpsLimit() { float value = fpsLimit.Value; if (value <= 0f) { Application.targetFrameRate = -1; } else { Application.targetFrameRate = Mathf.Clamp((int)value, 10, 1000); } } private void Start() { try { mainFont = Font.CreateDynamicFontFromOSFont("Arial", 14); } catch { mainFont = Resources.GetBuiltinResource("Arial.ttf"); } CreateFpsUI(); } private void Update() { if (showFps.Value && (Object)(object)fpsText != (Object)null) { fpsAccumulator++; if (Time.unscaledTime > fpsNextPeriod) { currentFps = (float)fpsAccumulator / fpsMeasurePeriod; fpsAccumulator = 0; fpsNextPeriod = Time.unscaledTime + fpsMeasurePeriod; fpsText.text = $"FPS: {Mathf.RoundToInt(currentFps)}"; } } } private void CreateFpsUI() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00d0: 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_00f9: Unknown result type (might be due to invalid IL or missing references) fpsCanvas = new GameObject("FpsCanvas"); Object.DontDestroyOnLoad((Object)(object)fpsCanvas); Canvas val = fpsCanvas.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 10000; CanvasScaler val2 = fpsCanvas.AddComponent(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.screenMatchMode = (ScreenMatchMode)0; val2.matchWidthOrHeight = 0.5f; GameObject val3 = new GameObject("FpsText"); val3.transform.SetParent(fpsCanvas.transform, false); fpsText = val3.AddComponent(); fpsText.font = mainFont; fpsText.fontSize = 16; ((Graphic)fpsText).color = Color.green; Outline val4 = val3.AddComponent(); ((Shadow)val4).effectColor = Color.black; ((Shadow)val4).effectDistance = new Vector2(1.5f, 1.5f); UpdateFpsCounterPosition(); UpdateFpsCounterState(); } private void UpdateFpsCounterState() { if ((Object)(object)fpsCanvas != (Object)null) { fpsCanvas.SetActive(showFps.Value); } } private void UpdateFpsCounterPosition() { //IL_00a6: 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_00d2: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)fpsText == (Object)null)) { RectTransform component = ((Component)fpsText).GetComponent(); if (fpsRight.Value) { component.anchorMin = new Vector2(1f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(-15f, -15f); fpsText.alignment = (TextAnchor)2; } else { component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(0f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = new Vector2(15f, -15f); fpsText.alignment = (TextAnchor)0; } } } }