miuu-sandbox/Patches/GemReplayPatch.cs

27 lines
623 B
C#
Raw Permalink Normal View History

2025-01-03 22:01:45 -05:00
using HarmonyLib;
namespace Sandbox.Patches
{
/*
* Fixes the gem counter when watching a replay
*/
[HarmonyPatch(typeof(GameHUD), "SetGems")]
internal class GameHUDSetGemsPatch
{
static bool Prefix(ref int collected)
{
// TODO, validate that we're actually writing to SelfGemCounter and not GhostGemCounter
// Though I don't think you can watch a replay and ghost at the same time, so it's probably ok
if (MarbleManager.Replaying)
{
MarbleController player = CameraController.instance?.player;
if (player)
{
collected = player.CollectedGems;
}
}
return true;
}
}
}