|
1 | 1 | using System.Collections.Generic; |
| 2 | +using System.Reflection; |
2 | 3 | using AquaMai.Config.Attributes; |
3 | 4 | using HarmonyLib; |
4 | 5 | using MAI2.Util; |
5 | 6 | using Manager; |
6 | 7 | using Monitor; |
7 | 8 | using Process; |
8 | 9 | using UnityEngine; |
| 10 | +using AquaMai.Mods.GameSettings; |
9 | 11 |
|
10 | 12 | namespace AquaMai.Mods.Utils; |
11 | 13 |
|
@@ -54,6 +56,22 @@ private struct Timing |
54 | 56 |
|
55 | 57 | private static GameObject[] baseObjects = new GameObject[2]; |
56 | 58 | 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 | + } |
57 | 75 |
|
58 | 76 | [HarmonyPostfix] |
59 | 77 | [HarmonyPatch(typeof(GameProcess), "OnStart")] |
@@ -87,6 +105,10 @@ public static void OnJudge(NoteBase __instance, float ___JudgeTimingDiffMsec) |
87 | 105 | var optionJudgeTiming = Singleton<GamePlayManager>.Instance.GetGameScore(__instance.MonitorId).UserOption.GetJudgeTimingFrame(); |
88 | 106 | msec -= optionJudgeTiming * TimingBin; |
89 | 107 |
|
| 108 | + // Account for the mod adjustment B judgement offset |
| 109 | + double modAdjustB = GetJudgeAdjustB(); |
| 110 | + msec += (float)(modAdjustB * TimingBin); |
| 111 | + |
90 | 112 | // Don't process misses |
91 | 113 | var timing = GetTiming(msec); |
92 | 114 | if (timing.windowStart == Miss.windowStart) |
|
0 commit comments