[+] Disable DisableTimeout In game start process

This commit is contained in:
Clansty 2025-01-10 17:26:20 +08:00
parent 19634edabc
commit 7fb2e2a9fa
No known key found for this signature in database
GPG Key ID: 3A6BE8BAF2EDE134

View File

@ -1,6 +1,10 @@
using AquaMai.Config.Attributes;
using System.Diagnostics;
using System.Linq;
using AquaMai.Config.Attributes;
using AquaMai.Core.Attributes;
using HarmonyLib;
using Manager;
using MelonLoader;
using Monitor;
using Process;
using Process.Entry.State;
@ -9,20 +13,32 @@ using Process.ModeSelect;
namespace AquaMai.Mods.GameSystem;
[ConfigSection(
en: """
Disable timers (hidden and set to 65535 seconds).
Not recommand to enable when SinglePlayer is off.
""",
zh: """
""")]
en: "Disable timers (hidden and set to 65535 seconds).",
zh: "去除并隐藏游戏中的倒计时")]
public class DisableTimeout
{
[ConfigEntry(
en: "Disable game start timer.",
zh: "也移除刷卡和选择模式界面的倒计时")]
private static readonly bool inGameStart = true;
private static bool CheckInGameStart()
{
if (inGameStart) return false;
var stackTrace = new StackTrace();
var stackFrames = stackTrace.GetFrames();
var names = stackFrames.Select(it => it.GetMethod().DeclaringType.Name).ToArray();
# if DEBUG
MelonLogger.Msg(names.Join());
# endif
return names.Contains("EntryProcess") || names.Contains("ModeSelectProcess");
}
[HarmonyPrefix]
[HarmonyPatch(typeof(TimerController), "PrepareTimer")]
public static void PrePrepareTimer(ref int second)
{
if (CheckInGameStart()) return;
second = 65535;
}
@ -30,11 +46,13 @@ public class DisableTimeout
[HarmonyPatch(typeof(CommonTimer), "SetVisible")]
public static void CommonTimerSetVisible(ref bool isVisible)
{
if (CheckInGameStart()) return;
isVisible = false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(EntryProcess), "DecrementTimerSecond")]
[EnableIf(nameof(inGameStart))]
public static bool EntryProcessDecrementTimerSecond(ContextEntry ____context)
{
SoundManager.PlaySE(Mai2.Mai2Cue.Cue.SE_SYS_SKIP, 0);
@ -44,6 +62,7 @@ public class DisableTimeout
[HarmonyPrefix]
[HarmonyPatch(typeof(ModeSelectProcess), "UpdateInput")]
[EnableIf(nameof(inGameStart))]
public static bool ModeSelectProcessUpdateInput(ModeSelectProcess __instance)
{
if (!InputManager.GetButtonDown(0, InputManager.ButtonSetting.Button05)) return true;
@ -62,4 +81,4 @@ public class DisableTimeout
____monitors[0].SetButtonPressed(InputManager.ButtonSetting.Button04);
Traverse.Create(__instance).Method("OnTimeUp").GetValue();
}
}
}