Add patch for replay gem counter

This commit is contained in:
Terry Hearst 2025-01-03 22:01:45 -05:00
parent 17a2fd1760
commit f0b5684e7e

26
Patches/GemReplayPatch.cs Normal file
View file

@ -0,0 +1,26 @@
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;
}
}
}