mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
hail mary fix for s showing up uninvited
This commit is contained in:
2 files changed
+49
-1
No files matched your search
@@ -60,4 +60,52 @@ public static class SettingPatches
|
||||
__result = result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Prefix for the <see cref="IntGameSetting.GetValueString"/> method. Adds support for custom number suffixes.
|
||||
/// </summary>
|
||||
/// <param name="__instance">The <see cref="IntGameSetting"/> instance.</param>
|
||||
/// <param name="__result">The result of the <see cref="IntGameSetting.GetValueString"/> method.</param>
|
||||
/// <param name="value">The <see langword="float"/> value.</param>
|
||||
/// <returns><see langword="false"/> to skip original method.</returns>
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(IntGameSetting), nameof(IntGameSetting.GetValueString))]
|
||||
public static bool ValueStringPatch(
|
||||
IntGameSetting __instance,
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public sealed class MiraPluginManager
|
||||
|
||||
foreach (var type in AccessTools.GetTypesFromAssembly(assembly))
|
||||
{
|
||||
if (type.IsDefined<MiraIgnoreAttribute>())
|
||||
if (type.IsDefined<MiraIgnoreAttribute>() || type.IsDefined<HarmonyAttribute>())
|
||||
continue;
|
||||
|
||||
foreach (var (logContext, handler) in RegistrationHandlers)
|
||||
|
||||
Reference in new issue
Block a user