Skip to content

Commit

Permalink
[+] Disable DisableTimeout In game start process
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Jan 10, 2025
1 parent 19634ed commit 7fb2e2a
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions AquaMai.Mods/GameSystem/DisableTimeout.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,32 +13,46 @@
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;
}

[HarmonyPrefix]
[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);
Expand All @@ -44,6 +62,7 @@ public static bool EntryProcessDecrementTimerSecond(ContextEntry ____context)

[HarmonyPrefix]
[HarmonyPatch(typeof(ModeSelectProcess), "UpdateInput")]
[EnableIf(nameof(inGameStart))]
public static bool ModeSelectProcessUpdateInput(ModeSelectProcess __instance)
{
if (!InputManager.GetButtonDown(0, InputManager.ButtonSetting.Button05)) return true;
Expand All @@ -62,4 +81,4 @@ public static void PhotoEditProcess(PhotoEditMonitor[] ____monitors, PhotoEditPr
____monitors[0].SetButtonPressed(InputManager.ButtonSetting.Button04);
Traverse.Create(__instance).Method("OnTimeUp").GetValue();
}
}
}

0 comments on commit 7fb2e2a

Please sign in to comment.