From c51ad7e0de88d0e742c8e662b6022a02a8a5c68a Mon Sep 17 00:00:00 2001
From: Az <56699741+AlchlcDvl@users.noreply.github.com>
Date: Tue, 17 Nov 2026 00:25:35 -0500
Subject: [PATCH] consolidate patches
---
MiraAPI/Patches/Options/SettingPatches.cs | 57 ++++++-----------------
1 file changed, 13 insertions(+), 44 deletions(-)
diff --git a/MiraAPI/Patches/Options/SettingPatches.cs b/MiraAPI/Patches/Options/SettingPatches.cs
index 88a22655..fbafc0a0 100644
--- a/MiraAPI/Patches/Options/SettingPatches.cs
+++ b/MiraAPI/Patches/Options/SettingPatches.cs
@@ -27,38 +27,7 @@ public static class SettingPatches
ref string __result,
[HarmonyArgument(0)] float value)
{
- string result;
- var suffix = (MiraNumberSuffixes)__instance.SuffixType;
-
- var custom =
- ModdedOptionsManager.ModdedOptions.Values.FirstOrDefault(opt =>
- opt.OptionBehaviour != null && opt.OptionBehaviour.Data == __instance);
- if (custom is ModdedNumberOption moddedNumberOption)
- {
- if (moddedNumberOption.NegativeWordValue != "#" && (int)value == -1)
- {
- result = $"{moddedNumberOption.NegativeWordValue}";
- }
- else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f)
- {
- result = $"{moddedNumberOption.ZeroWordValue}";
- }
- else
- {
- result = Helpers.FormatValue(value, suffix, __instance.FormatString);
- }
- }
- else if (__instance.ZeroIsInfinity && Mathf.Abs(value) < 0.0001f)
- {
- result = "∞";
- }
- else
- {
- result = Helpers.FormatValue(value, suffix, __instance.FormatString);
- }
-
- __result = result;
- return false;
+ return SetResult(ref __result, value, (MiraNumberSuffixes)__instance.SuffixType, __instance.FormatString, __instance.ZeroIsInfinity, __instance);
}
///
@@ -75,37 +44,37 @@ public static class SettingPatches
ref string __result,
[HarmonyArgument(0)] float value)
{
- string result;
- var suffix = (MiraNumberSuffixes)__instance.SuffixType;
+ return SetResult(ref __result, value, (MiraNumberSuffixes)__instance.SuffixType, __instance.FormatString, __instance.ZeroIsInfinity, __instance);
+ }
+
+ private static bool SetResult(ref string __result, float value, MiraNumberSuffixes suffix, string formatString, bool zeroIsInfinity, BaseGameSetting setting)
+ {
+ var custom = ModdedOptionsManager.ModdedOptions.Values.FirstOrDefault(opt => opt.Data == setting);
- var custom =
- ModdedOptionsManager.ModdedOptions.Values.FirstOrDefault(opt =>
- opt.OptionBehaviour != null && opt.OptionBehaviour.Data == __instance);
if (custom is ModdedNumberOption moddedNumberOption)
{
if (moddedNumberOption.NegativeWordValue != "#" && (int)value == -1)
{
- result = $"{moddedNumberOption.NegativeWordValue}";
+ __result = $"{moddedNumberOption.NegativeWordValue}";
}
else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f)
{
- result = $"{moddedNumberOption.ZeroWordValue}";
+ __result = $"{moddedNumberOption.ZeroWordValue}";
}
else
{
- result = Helpers.FormatValue(value, suffix, __instance.FormatString);
+ __result = Helpers.FormatValue(value, suffix, formatString);
}
}
- else if (__instance.ZeroIsInfinity && Mathf.Abs(value) < 0.0001f)
+ else if (zeroIsInfinity && Mathf.Abs(value) < 0.0001f)
{
- result = "∞";
+ __result = "∞";
}
else
{
- result = Helpers.FormatValue(value, suffix, __instance.FormatString);
+ __result = Helpers.FormatValue(value, suffix, formatString);
}
- __result = result;
return false;
}
}