SHA256
37 lines
1.8 KiB
C#
37 lines
1.8 KiB
C#
using ADOFAIRenderer.Core;
|
|
using HarmonyLib;
|
|
|
|
namespace ADOFAIRenderer.Patch.Game;
|
|
|
|
/// <summary>
|
|
/// Replaces the "any valid input" check with a render-controlled value, so player input cannot affect the level during a render.
|
|
/// <para>
|
|
/// Patched member: <c>scrPlayerManager.AnyValidInputWasTriggered()</c>, true when any player pressed a valid key this frame.
|
|
/// <c>scrController</c> uses it to leave the press-to-start wait, to restart after a failure (<c>Fail2_Update</c>) and to
|
|
/// leave the level after a win (<c>Won_Update</c>).
|
|
/// </para>
|
|
/// <para>
|
|
/// Active while <see cref="RenderManager.IsActive"/> (stage >= OnScene). The result is true only while
|
|
/// <c>RenderManager.countdown</c> is 0 and <c>RenderManager.frameCount</c> is 0, that is, after the 3 second countdown in
|
|
/// <c>SetupPlay</c> has ended and reset the frame counter and before the next frame increments it; it is false otherwise.
|
|
/// <c>SetupPlay</c> also sets <c>scrController.levelWasSkipped</c>, which ends the press-to-start wait independently of input.
|
|
/// </para>
|
|
/// </summary>
|
|
[HarmonyPatch(typeof(scrPlayerManager))]
|
|
// ReSharper disable once InconsistentNaming
|
|
public static class scrPlayerManagerPatch
|
|
{
|
|
/// <summary>Prefix of <c>scrPlayerManager.AnyValidInputWasTriggered</c>.</summary>
|
|
/// <param name="__result">Return value used when the original is skipped (see class summary).</param>
|
|
/// <returns>True to run the original method (not rendering); false to skip it (rendering).</returns>
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch("AnyValidInputWasTriggered")]
|
|
// ReSharper disable once InconsistentNaming
|
|
private static bool IgnoreInput(ref bool __result)
|
|
{
|
|
if (!RenderManager.IsActive) return true;
|
|
|
|
__result = RenderManager.Instance && RenderManager.Instance.frameCount == 0 && RenderManager.Instance.countdown == 0;
|
|
return false;
|
|
}
|
|
} |