Skip to content

Commit

Permalink
IS: cleanup & attempted menu audio glitch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AuriRex committed Oct 20, 2023
1 parent 46b286a commit 27edf68
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions TheArchive.IL2CPP/Features/QoL/IntroSkip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,51 @@ public class IntroSkip : Feature

public new static IArchiveLogger FeatureLogger { get; set; }

[ArchivePatch(typeof(CM_PageIntro), "Update")]
internal static class CM_PageIntro_UpdatePatch
{

#if MONO
private static PropertyAccessor<RundownManager, bool> A_RundownManager_RundownProgressionReady;
private static PropertyAccessor<RundownManager, bool> A_RundownManager_RundownProgressionReady;

[RundownConstraint(Utils.RundownFlags.RundownFour)]
public static void Init()
{
public override void Init()
{
if (Is.R4OrLater)
A_RundownManager_RundownProgressionReady = PropertyAccessor<RundownManager, bool>.GetAccessor("RundownProgressionReady");
}
}
#endif

public static bool IsProgressionFileReady()
{
#if MONO
if(Is.R4OrLater)
return A_RundownManager_RundownProgressionReady.Get(null);
return R3BelowIsProgressionFileReady();
#else
return RundownManager.RundownProgressionReady;
#endif
}

#if MONO
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool R3BelowIsProgressionFileReady()
{
return RundownManager.PlayerRundownProgressionFileReady;
}
#endif

[ArchivePatch(typeof(CM_PageIntro), UnityMessages.Update)]
internal static class CM_PageIntro_Update_Patch
{
private static bool _injectPressed = false;

private static MethodAccessor<CM_PageIntro> _onSkip;

public static void Init()
{
_onSkip = MethodAccessor<CM_PageIntro>.GetAccessor("OnSkip");
}

#if IL2CPP
[IsPostfix, RundownConstraint(Utils.RundownFlags.RundownFour, Utils.RundownFlags.Latest)]
public static void Postfix(CM_PageIntro __instance)
public static void PostfixR4OrLater(CM_PageIntro __instance)
{
CheckAndSkipIfReady(__instance, __instance.m_startupLoaded, __instance.m_enemiesLoaded, __instance.m_sharedLoaded);
}
Expand All @@ -53,29 +80,11 @@ public static void CheckAndSkipIfReady(CM_PageIntro __instance, bool ___m_startu
&& !_injectPressed)
{
FeatureLogger.Notice("Automatically pressing the Inject button ...");
_onSkip.Invoke(__instance);
__instance.EXT_PressInject(-1);
_injectPressed = true;
}
}

public static bool IsProgressionFileReady()
{
#if MONO
if(BuildInfo.Rundown.IsIncludedIn(Utils.RundownFlags.RundownFour))
return A_RundownManager_RundownProgressionReady.Get(null);
return R3BelowIsProgressionFileReady();
#else
return RundownManager.RundownProgressionReady;
#endif
}

#if MONO
[MethodImpl(MethodImplOptions.NoInlining)]
private static bool R3BelowIsProgressionFileReady()
{
return RundownManager.PlayerRundownProgressionFileReady;
}
#endif
}
}
}

0 comments on commit 27edf68

Please sign in to comment.