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

This commit is contained in:
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 LoadAssetBundleWithoutManifest=true
[Performance] [Performance]
# Disable some useless checks and delays to speed up the game boot process # Disable some useless delays to speed up the game boot process
# !! Known issue: The game may crash if DX Pass scanning is enabled
ImproveLoadSpeed=false ImproveLoadSpeed=false

View File

@@ -1,7 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using HarmonyLib; using HarmonyLib;
using MAI2.Util;
using Manager;
using Process; using Process;
namespace AquaMai.Performance namespace AquaMai.Performance
@@ -9,55 +7,20 @@ namespace AquaMai.Performance
public class ImproveLoadSpeed public class ImproveLoadSpeed
{ {
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(PowerOnProcess), "OnUpdate")] [HarmonyPatch(typeof(PowerOnProcess), "OnStart")]
public static bool PrePowerOnUpdate(PowerOnProcess __instance) public static void PrePowerOnStart(ref float ____waitTime)
{ {
var traverse = Traverse.Create(__instance); ____waitTime = 0f;
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;
} }
[HarmonyPrefix] [HarmonyPrefix]
[HarmonyPatch(typeof(StartupProcess), "OnUpdate")] [HarmonyPatch(typeof(StartupProcess), "OnUpdate")]
public static bool PreStartupUpdate(StartupProcess __instance) public static void PreStartupUpdate(byte ____state, ref Stopwatch ___timer)
{ {
var traverse = Traverse.Create(__instance); if (____state == 8)
var state = traverse.Field("_state").GetValue<byte>();
switch (state)
{ {
case 0: Traverse.Create(___timer).Field("elapsed").SetValue(2 * 10000000L);
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;
} }
return true;
} }
} }
} }