[F] Modify ImproveLoadSpeed to only skip delays to reduce bugs

pull/32/head
Clansty 2024-05-05 19:54:50 +08:00
parent d7287c48cf
commit 770d1ae689
2 changed files with 8 additions and 46 deletions

View File

@ -24,6 +24,5 @@ QuickSkip=true
LoadAssetBundleWithoutManifest=true
[Performance]
# Disable some useless checks and delays to speed up the game boot process
# !! Known issue: The game may crash if DX Pass scanning is enabled
# Disable some useless delays to speed up the game boot process
ImproveLoadSpeed=false

View File

@ -1,7 +1,5 @@
using System.Diagnostics;
using HarmonyLib;
using MAI2.Util;
using Manager;
using Process;
namespace AquaMai.Performance
@ -9,55 +7,20 @@ namespace AquaMai.Performance
public class ImproveLoadSpeed
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PowerOnProcess), "OnUpdate")]
public static bool PrePowerOnUpdate(PowerOnProcess __instance)
[HarmonyPatch(typeof(PowerOnProcess), "OnStart")]
public static void PrePowerOnStart(ref float ____waitTime)
{
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:
case 6:
case 7:
traverse.Field("_state").SetValue((byte)8);
break;
case 9:
traverse.Field("_state").SetValue((byte)10);
break;
}
return true;
____waitTime = 0f;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(StartupProcess), "OnUpdate")]
public static bool PreStartupUpdate(StartupProcess __instance)
public static void PreStartupUpdate(byte ____state, ref Stopwatch ___timer)
{
var traverse = Traverse.Create(__instance);
var state = traverse.Field("_state").GetValue<byte>();
switch (state)
if (____state == 8)
{
case 0:
traverse.Field("_state").SetValue((byte)1);
break;
case 2:
// AimeReader maybe typeof AimeReaderManager or ChimeReaderManager, must build with correct Assembly-CSharp.dll in Libs folder
if(SingletonStateMachine<AmManager, AmManager.EState>.Instance.AimeReader.GetType().FullName == "Manager.AimeReaderManager")
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;
Traverse.Create(___timer).Field("elapsed").SetValue(2 * 10000000L);
}
return true;
}
}
}