-
Notifications
You must be signed in to change notification settings - Fork 9
/
ForceFramerate.cs
44 lines (39 loc) · 1.24 KB
/
ForceFramerate.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
}
}
}