1
0
mirror of synced 2024-11-23 22:10:57 +01:00
TaikoModStuff/ForceFramerate.cs
2022-01-27 16:39:40 -07:00

45 lines
1.2 KiB
C#

using HarmonyLib;
using UnityEngine;
namespace TaikoModStuff
{
internal class ForceFramerate
{
private static readonly int VSyncFrames = Plugin.configToggleVSync.Value ? 1 : 0;
// Skip the original method, we're doing magic here
[HarmonyPatch(typeof(ForceRenderRate), "Start")]
[HarmonyPrefix]
static bool PrefixFocus()
{
return false;
}
// Skip the original method, we're doing magic here
[HarmonyPatch(typeof(ForceRenderRate), "Update")]
[HarmonyPrefix]
static bool PrefixScreenType()
{
return false;
}
[HarmonyPatch(typeof(ForceRenderRate), "Start")]
[HarmonyPrefix]
static void customStart()
{
// Force vsync at all times
QualitySettings.vSyncCount = VSyncFrames;
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
}
[HarmonyPatch(typeof(ForceRenderRate), "Update")]
[HarmonyPrefix]
static void customUpdate()
{
// Force vsync at all times
QualitySettings.vSyncCount = VSyncFrames;
Application.targetFrameRate = Plugin.configCustomFramerate.Value;
}
}
}