Skip to content

Commit 3c4b3f5

Browse files
committed
[+] QuickRetry 自由模式时间检测
1 parent 7fc6009 commit 3c4b3f5

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

AquaMai.Mods/GameSystem/QuickRetry.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using AquaMai.Core.Attributes;
1+
using System.Collections.Generic;
2+
using System.Reflection.Emit;
3+
using AquaMai.Core.Attributes;
24
using AquaMai.Config.Attributes;
35
using HarmonyLib;
46
using MAI2.Util;
@@ -49,4 +51,30 @@ public static void ExecutePostfix(double ____pushTimer)
4951
if (____pushTimer < 500) return;
5052
Singleton<GamePlayManager>.Instance.SetQuickRetryFrag(flag: true);
5153
}
54+
55+
// if (GameManager.GetFreedomModeMSec() > 0)
56+
public static long GetFreedomModeMSecOverride()
57+
{
58+
return 999999;
59+
}
60+
61+
[HarmonyTranspiler]
62+
[HarmonyPatch(typeof(Monitor.QuickRetry), "Execute")]
63+
public static IEnumerable<CodeInstruction> ExecuteTranspiler(IEnumerable<CodeInstruction> instructions)
64+
{
65+
var original = AccessTools.Method(typeof(GameManager), nameof(GameManager.GetFreedomModeMSec));
66+
var replacement = AccessTools.Method(typeof(QuickRetry), nameof(GetFreedomModeMSecOverride));
67+
68+
foreach (var instruction in instructions)
69+
{
70+
if (instruction.Calls(original))
71+
{
72+
yield return new CodeInstruction(OpCodes.Call, replacement);
73+
}
74+
else
75+
{
76+
yield return instruction;
77+
}
78+
}
79+
}
5280
}

0 commit comments

Comments
 (0)