Files
ADOFAIRenderer/Patch/Game/scrMistakesManagerPatch.cs
2026-10-15 16:17:13 +09:00

31 lines
1.3 KiB
C#

using ADOFAIRenderer.Core;
using HarmonyLib;
namespace ADOFAIRenderer.Patch.Game;
/// <summary>
/// Keeps a render from writing custom level results to the player's save data.
/// <para>
/// Patched member: <c>scrMistakesManager.SaveCustom(string hash, bool wonLevel, float multiplier)</c>, which compares the
/// run with the stored completion, accuracy, speed trial and death records of the custom level (keyed by the level hash),
/// stores new bests through <c>Persistence</c> and returns an <c>EndLevelInfo</c>. The game calls it from
/// <c>scrController.OnLandOnPortal</c> (custom level win) and <c>Fail2Action</c> (custom boss level failure).
/// </para>
/// <para>
/// Active while <see cref="RenderManager.IsActive"/> (stage &gt;= OnScene); the run of a render is not stored as a player
/// record. The skipped call returns a default <c>EndLevelInfo</c>.
/// </para>
/// </summary>
[HarmonyPatch(typeof(scrMistakesManager))]
// ReSharper disable once InconsistentNaming
public static class scrMistakesManagerPatch
{
/// <summary>Prefix of <c>scrMistakesManager.SaveCustom</c>.</summary>
/// <returns>True to run the original method (not rendering); false to skip it (rendering).</returns>
[HarmonyPrefix]
[HarmonyPatch("SaveCustom")]
public static bool PreventSaveCustom()
{
return !RenderManager.IsActive;
}
}