using HarmonyLib; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine; namespace MiuuDiamondTimeViewer.Patches { [HarmonyPatch(typeof(MedalsDisplay))] [HarmonyPatch("Setup")] internal class MedalsDisplaySetupPatch { static bool Prefix(MedalsDisplay __instance, float silver, float gold, List eggUnlock) { if (!Config.Enabled) return true; // Get diamond time (since it is not passed in as a parameter) float diamond = LevelSelect.instance.level.DiamondTime; bool hasEgg = eggUnlock != null && eggUnlock.Count > 0; bool gotEgg = hasEgg && UnlockManager.Get().IsUnlocked(eggUnlock[0]) && !CosmeticValues.WasPurchased(eggUnlock[0]); string eggText = ""; if (hasEgg) eggText = (gotEgg ? " " : " "); bool showDiamondTime = false; switch (Config.Mode) { case DisplayMode.Always: showDiamondTime = true; break; case DisplayMode.Diamond: showDiamondTime = LevelSelect.instance.bestScore > 0f && LevelSelect.instance.bestScore <= diamond; break; case DisplayMode.Gold: showDiamondTime = LevelSelect.instance.bestScore > 0f && LevelSelect.instance.bestScore <= gold; break; case DisplayMode.Never: showDiamondTime = false; break; } string diamondText = ""; if (showDiamondTime) diamondText = " " + SegmentedTime.SPTimeText(diamond); __instance.MedalTimes.text = string.Concat(new string[] { " ", SegmentedTime.SPTimeText(silver), " ", SegmentedTime.SPTimeText(gold), diamondText, eggText }); // Skip original method return false; } } }