Skip to content

Commit

Permalink
[+] seeking in DebugFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
clansty committed Sep 27, 2024
1 parent 0d9c7a4 commit 24e6808
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions AquaMai/Cheat/DebugFeature.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Monitor;
using Process;
using UnityEngine;

Expand All @@ -9,14 +11,19 @@ namespace AquaMai.Cheat;
public class DebugFeature
{
# if SDGA145
private static bool isPause = false;
private static bool isPause;
private static double timer;

[HarmonyPostfix]
[HarmonyPatch(typeof(GameProcess), "OnUpdate")]
public static void PostGameProcessUpdate(GameProcess __instance, byte ____sequence, MovieController ____gameMovie)
public static void PostGameProcessUpdate(GameProcess __instance, byte ____sequence, MovieController ____gameMovie, GameMonitor[] ____monitors)
{
if (____sequence != 4) return;
// GameSequence.Play
if (!isPause)
{
timer += GameManager.GetGameMSecAddD();
}
if (Input.GetKeyDown(KeyCode.Home))
{
GameManager.AutoPlay = (GameManager.AutoPlayMode)((int)(GameManager.AutoPlay + 1) % Enum.GetNames(typeof(GameManager.AutoPlayMode)).Length);
Expand All @@ -28,6 +35,57 @@ public static void PostGameProcessUpdate(GameProcess __instance, byte ____sequen
____gameMovie.Pause(isPause);
NotesManager.Pause(isPause);
}
else if (DebugInput.GetKeyDown(KeyCode.LeftArrow) || DebugInput.GetKeyDown(KeyCode.RightArrow))
{
var num23 = 0;
if (DebugInput.GetKeyDown(KeyCode.LeftArrow))
{
num23 = -1000;
}
if (DebugInput.GetKeyDown(KeyCode.RightArrow))
{
num23 = 1000;
}
int addMsec = ((!DebugInput.GetKey(KeyCode.LeftShift) && !DebugInput.GetKey(KeyCode.RightShift)) ? ((!DebugInput.GetKey(KeyCode.LeftControl) && !DebugInput.GetKey(KeyCode.RightControl)) ? num23 : (num23 * 10)) : (num23 * 5));
Singleton<GamePlayManager>.Instance.Initialize();
DebugTimeSkip(addMsec);
}

return;


void DebugTimeSkip(int addMsec)
{
____gameMovie.Pause(pauseFlag: true);
NotesManager.Pause(true);
if (addMsec >= 0)
{
timer += addMsec;
}
else
{
timer = timer + addMsec >= 0.0 ? timer + addMsec : 0.0;
}
____gameMovie.SetSeekFrame(timer);
SoundManager.SeekMusic((int)timer);
for (int i = 0; i < ____monitors.Length; i++)
{
____monitors[i].Seek((int)timer);
}
// magic number, dont know why
NotesManager.StartPlay((int)timer + 91);
NotesManager.Pause(isPause);
if (!isPause)
{
SoundManager.PauseMusic(pause: false);
____gameMovie.Pause(pauseFlag: false);
}
else
{
____gameMovie.Pause(pauseFlag: true);
}
__instance.UpdateNotes();
}
}
# endif
}

0 comments on commit 24e6808

Please sign in to comment.