[+] Option to disable some useless checks and delays to speedup the game boot process

pull/29/head
Clansty 2024-04-08 17:02:14 +08:00
parent 2630d32764
commit 442ec76828
4 changed files with 69 additions and 1 deletions

View File

@ -266,6 +266,7 @@
<Compile Include="Cheat\TicketUnlock.cs" />
<Compile Include="Config.cs" />
<Compile Include="Fix\FixCharaCrash.cs" />
<Compile Include="Performance\ImproveLoadSpeed.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Main.cs" />
<Compile Include="UX\SinglePlayer.cs" />

View File

@ -13,4 +13,8 @@ SkipWarningScreen=true
# Single player: Show 1P only, at the center of the screen
SinglePlayer=true
# !!EXPERIMENTAL!! Skip from the card-scanning screen directly to music selection screen
SkipToMusicSelection=false
SkipToMusicSelection=false
[Performance]
# Disable some useless checks and delays to speedup the game boot process
ImproveLoadSpeed=false

View File

@ -7,6 +7,7 @@ namespace AquaMai
{
public UXConfig UX { get; set; }
public CheatConfig Cheat { get; set; }
public PerformanceConfig Performance { get; set; }
public class CheatConfig
{
@ -19,5 +20,10 @@ namespace AquaMai
public bool SinglePlayer { get; set; }
public bool SkipToMusicSelection { get; set; }
}
public class PerformanceConfig
{
public bool ImproveLoadSpeed { get; set; }
}
}
}

View File

@ -0,0 +1,57 @@
using System.Diagnostics;
using HarmonyLib;
using MelonLoader;
using Process;
namespace AquaMai.Performance
{
public class ImproveLoadSpeed
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PowerOnProcess), "OnUpdate")]
public static bool PrePowerOnUpdate(PowerOnProcess __instance)
{
var traverse = Traverse.Create(__instance);
var state = traverse.Field("_state").GetValue<byte>();
switch (state)
{
case 3:
traverse.Field("_state").SetValue((byte)4);
break;
case 5:
traverse.Field("_state").SetValue((byte)8);
break;
case 9:
traverse.Field("_state").SetValue((byte)10);
break;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(StartupProcess), "OnUpdate")]
public static bool PreStartupUpdate(StartupProcess __instance)
{
var traverse = Traverse.Create(__instance);
var state = traverse.Field("_state").GetValue<byte>();
switch (state)
{
case 0:
case 1:
case 2:
traverse.Field("_state").SetValue((byte)3);
break;
case 4:
traverse.Field("_state").SetValue((byte)5);
break;
case 8:
var timer = traverse.Field("timer").GetValue<Stopwatch>();
Traverse.Create(timer).Field("elapsed").SetValue(2 * 10000000L);
break;
}
return true;
}
}
}