mirror of
https://gitea.tendokyu.moe/beerpsi/sinmai-mods.git
synced 2024-11-23 23:31:02 +01:00
44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using HarmonyLib;
|
|
using Monitor;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Reflection.Emit;
|
|
|
|
namespace UnlockFrameRate;
|
|
|
|
[HarmonyPatch(typeof(NoteBase), "GetMaiBugAdjustMSec")]
|
|
internal class PatchGetMaiBugAdjustMSec
|
|
{
|
|
private const float OriginalFrameRate = 60f;
|
|
|
|
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod)
|
|
{
|
|
var i = 0;
|
|
|
|
foreach (var instruction in instructions)
|
|
{
|
|
if (instruction.opcode != OpCodes.Ldc_R4 || instruction.operand is not float operand)
|
|
{
|
|
yield return instruction;
|
|
i++;
|
|
continue;
|
|
}
|
|
|
|
if (Math.Abs(operand - OriginalFrameRate) < float.Epsilon)
|
|
{
|
|
instruction.operand = (float)FrameRatePlugin.Instance.TargetFrameRate;
|
|
FrameRatePlugin.Logger.LogDebug(
|
|
"Overrode constant at opcode index {0} in {1}: {2} => {3}",
|
|
i,
|
|
__originalMethod.Name,
|
|
operand,
|
|
instruction.operand);
|
|
}
|
|
|
|
yield return instruction;
|
|
i++;
|
|
}
|
|
}
|
|
}
|