Skip to content

Commit ece9020

Browse files
authored
[F] account for JudgeAdjust.B offset in UnstableRate display (#106)
* fix: account for JudgeAdjust.B offset in UnstableRate display * refactor: use static constructor for thread safety
1 parent 4919d4f commit ece9020

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

AquaMai.Mods/Utils/UnstableRate.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
using System.Collections.Generic;
2+
using System.Reflection;
23
using AquaMai.Config.Attributes;
34
using HarmonyLib;
45
using MAI2.Util;
56
using Manager;
67
using Monitor;
78
using Process;
89
using UnityEngine;
10+
using AquaMai.Mods.GameSettings;
911

1012
namespace AquaMai.Mods.Utils;
1113

@@ -54,6 +56,22 @@ private struct Timing
5456

5557
private static GameObject[] baseObjects = new GameObject[2];
5658
private static LinePool[] linePools = new LinePool[2];
59+
private static readonly FieldInfo _judgeAdjustBField;
60+
61+
static UnstableRate()
62+
{
63+
// 尝试通过反射获取 AquaMai.Mods.GameSettings.JudgeAdjust 类中的私有字段 'b'
64+
_judgeAdjustBField = AccessTools.Field(typeof(JudgeAdjust), "b");
65+
}
66+
67+
private static double GetJudgeAdjustB()
68+
{
69+
if (_judgeAdjustBField != null)
70+
{
71+
return (double)_judgeAdjustBField.GetValue(null);
72+
}
73+
return 0;
74+
}
5775

5876
[HarmonyPostfix]
5977
[HarmonyPatch(typeof(GameProcess), "OnStart")]
@@ -87,6 +105,10 @@ public static void OnJudge(NoteBase __instance, float ___JudgeTimingDiffMsec)
87105
var optionJudgeTiming = Singleton<GamePlayManager>.Instance.GetGameScore(__instance.MonitorId).UserOption.GetJudgeTimingFrame();
88106
msec -= optionJudgeTiming * TimingBin;
89107

108+
// Account for the mod adjustment B judgement offset
109+
double modAdjustB = GetJudgeAdjustB();
110+
msec += (float)(modAdjustB * TimingBin);
111+
90112
// Don't process misses
91113
var timing = GetTiming(msec);
92114
if (timing.windowStart == Miss.windowStart)

0 commit comments

Comments
 (0)