consolidate patches

This commit is contained in:
Az committed 2026-11-17 00:25:35 -05:00
1 parent 13dce32ae3
commit c51ad7e0de
1 file changed
+13 -44
+13 -44
View File
@@ -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 = $"<b>{moddedNumberOption.NegativeWordValue}</b>";
}
else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f)
{
result = $"<b>{moddedNumberOption.ZeroWordValue}</b>";
}
else
{
result = Helpers.FormatValue(value, suffix, __instance.FormatString);
}
}
else if (__instance.ZeroIsInfinity && Mathf.Abs(value) < 0.0001f)
{
result = "<b>∞</b>";
}
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);
}
/// <summary>
@@ -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 = $"<b>{moddedNumberOption.NegativeWordValue}</b>";
__result = $"<b>{moddedNumberOption.NegativeWordValue}</b>";
}
else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f)
{
result = $"<b>{moddedNumberOption.ZeroWordValue}</b>";
__result = $"<b>{moddedNumberOption.ZeroWordValue}</b>";
}
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 = "<b>∞</b>";
__result = "<b>∞</b>";
}
else
{
result = Helpers.FormatValue(value, suffix, __instance.FormatString);
__result = Helpers.FormatValue(value, suffix, formatString);
}
__result = result;
return false;
}
}