From 13c6db4d6492f3ced6ded6ddb0e5e376c5c76cb9 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Thu, 19 Nov 2026 01:38:44 -0500 Subject: [PATCH] use Math/MathF instead of Mathf because il2cpp --- MiraAPI/GameModes/AbstractGameMode.cs | 7 +++--- MiraAPI/GameModes/HideAndSeekMode.cs | 4 ++-- .../HnsReimplemented/HideAndSeekHudHelper.cs | 7 +++--- MiraAPI/HnsReimplemented/HnsDangerMeter.cs | 4 ++-- MiraAPI/HnsReimplemented/HnsMusicHandler.cs | 9 ++++---- MiraAPI/Hud/CustomActionButton.cs | 4 ++-- MiraAPI/Hud/CustomPaginableMenu.cs | 4 ++-- .../SettingTypes/LocalSliderSetting.cs | 4 ++-- .../MeetingAbilityBehaviour.cs | 3 ++- .../MeetingAbilities/MeetingActionButton.cs | 5 +++-- .../MeetingAbilities/TargetedMeetingButton.cs | 2 +- .../ModifierDisplayComponent.cs | 9 ++++---- MiraAPI/Patches/Freeplay/TaskAdderPatches.cs | 4 ++-- .../Patches/Options/GameOptionsMenuPatch.cs | 2 +- .../Patches/Options/PlayerOptionPatches.cs | 6 ++--- .../Patches/Options/RoleSettingMenuPatches.cs | 4 +--- MiraAPI/Patches/Options/SettingPatches.cs | 8 +++---- MiraAPI/Patches/RoleGuidePatches.cs | 4 ++-- MiraAPI/Patches/Roles/TaskPanelPatch.cs | 7 +++--- MiraAPI/Roles/ICustomRole.cs | 8 +++---- .../Components/CenteredGridArrange.cs | 2 +- MiraAPI/Utilities/Components/LoadingRing.cs | 8 +++---- MiraAPI/Utilities/Extensions.cs | 4 ++-- MiraAPI/Utilities/GuideOptionsPatches.cs | 2 +- MiraAPI/Utilities/Helpers.cs | 22 +++++++++---------- 25 files changed, 74 insertions(+), 69 deletions(-) diff --git a/MiraAPI/GameModes/AbstractGameMode.cs b/MiraAPI/GameModes/AbstractGameMode.cs index 8f90de2b..2aababb7 100644 --- a/MiraAPI/GameModes/AbstractGameMode.cs +++ b/MiraAPI/GameModes/AbstractGameMode.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using AmongUs.GameOptions; using MiraAPI.GameOptions; @@ -300,8 +301,8 @@ public abstract class AbstractGameMode : IOptionable instance.closedPosition = new Vector3(xPos, yPos, instance.closedPosition.z); instance.openPosition = new Vector3(instance.openPosition.x, yPos, instance.openPosition.z); instance.timer = instance.open - ? Mathf.Min(1f, instance.timer + (Time.deltaTime / instance.animationTimeSeconds)) - : Mathf.Max(0f, instance.timer - (Time.deltaTime / instance.animationTimeSeconds)); + ? Math.Min(1f, instance.timer + (Time.deltaTime / instance.animationTimeSeconds)) + : Math.Max(0f, instance.timer - (Time.deltaTime / instance.animationTimeSeconds)); Vector3 relativePos = new( Mathf.SmoothStep(instance.closedPosition.x, instance.openPosition.x, instance.timer), diff --git a/MiraAPI/GameModes/HideAndSeekMode.cs b/MiraAPI/GameModes/HideAndSeekMode.cs index 922e5449..e3ac7608 100644 --- a/MiraAPI/GameModes/HideAndSeekMode.cs +++ b/MiraAPI/GameModes/HideAndSeekMode.cs @@ -516,8 +516,8 @@ public class HideAndSeekMode : AbstractGameMode instance.closedPosition = new Vector3(xPos, yPos, instance.closedPosition.z); instance.openPosition = new Vector3(instance.openPosition.x, yPos, instance.openPosition.z); instance.timer = instance.open - ? Mathf.Min(1f, instance.timer + (Time.deltaTime / instance.animationTimeSeconds)) - : Mathf.Max(0f, instance.timer - (Time.deltaTime / instance.animationTimeSeconds)); + ? Math.Min(1f, instance.timer + (Time.deltaTime / instance.animationTimeSeconds)) + : Math.Max(0f, instance.timer - (Time.deltaTime / instance.animationTimeSeconds)); Vector3 relativePos = new( Mathf.SmoothStep(instance.closedPosition.x, instance.openPosition.x, instance.timer), diff --git a/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs b/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs index 7d73f59f..2c7b90e5 100644 --- a/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs +++ b/MiraAPI/HnsReimplemented/HideAndSeekHudHelper.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Diagnostics.CodeAnalysis; using System.Linq; using BepInEx.Unity.IL2CPP.Utils.Collections; @@ -266,7 +267,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr) { var num = currentHideTime; currentHideTime -= timeDeduction; - currentHideTime = Mathf.Max(currentHideTime, 0f); + currentHideTime = Math.Max(currentHideTime, 0f); if (currentHideTime <= 10f && beepCoroutine == null) { beepCoroutine = StartCoroutine(BeepAlmostEverySecond().WrapToIl2Cpp()); @@ -308,7 +309,7 @@ public sealed class HideAndSeekHudHelper(nint cppPtr) : MonoBehaviour(cppPtr) private void AdjustFinalEscapeTimer(float timeDeduction) { currentFinalHideTime -= timeDeduction; - currentFinalHideTime = Mathf.Max(currentFinalHideTime, 0f); + currentFinalHideTime = Math.Max(currentFinalHideTime, 0f); timerBar.UpdateTimer(currentFinalHideTime, totalFinalHideTime); if (secondsSinceLastSetDirty > 1f) { diff --git a/MiraAPI/HnsReimplemented/HnsDangerMeter.cs b/MiraAPI/HnsReimplemented/HnsDangerMeter.cs index f831af4d..734b5ea1 100644 --- a/MiraAPI/HnsReimplemented/HnsDangerMeter.cs +++ b/MiraAPI/HnsReimplemented/HnsDangerMeter.cs @@ -91,9 +91,9 @@ public sealed class HnsDangerMeter(nint cppPtr) : MonoBehaviour(cppPtr) } } - dangerLevel1 = Mathf.Clamp01( + dangerLevel1 = MathUtilities.Clamp01( (scaryMusicDistance - num) / (scaryMusicDistance - veryScaryMusicDistance)); - dangerLevel2 = Mathf.Clamp01((veryScaryMusicDistance - num) / veryScaryMusicDistance); + dangerLevel2 = MathUtilities.Clamp01((veryScaryMusicDistance - num) / veryScaryMusicDistance); } UpdateDangerMeter(); diff --git a/MiraAPI/HnsReimplemented/HnsMusicHandler.cs b/MiraAPI/HnsReimplemented/HnsMusicHandler.cs index cf4524e7..d714e322 100644 --- a/MiraAPI/HnsReimplemented/HnsMusicHandler.cs +++ b/MiraAPI/HnsReimplemented/HnsMusicHandler.cs @@ -3,6 +3,7 @@ using System.Diagnostics.CodeAnalysis; using Amongus.GameModes.HideAndSeek; using MiraAPI.GameOptions; using MiraAPI.HnsReimplemented.Options; +using MiraAPI.Utilities; using Reactor.Utilities.Attributes; using UnityEngine; @@ -178,19 +179,19 @@ public sealed class HnsMusicHandler(nint cppPtr) : MonoBehaviour(cppPtr) SyncMusic(); } - normalSource.volume = Mathf.Lerp( + normalSource.volume = MathUtilities.Lerp( normalSource.volume, normalVolume, Time.fixedDeltaTime * musicLerpSpeed); - taskSource.volume = Mathf.Lerp( + taskSource.volume = MathUtilities.Lerp( taskSource.volume, taskVolume, Time.fixedDeltaTime * musicLerpSpeed); - dangerLevel1Source.volume = Mathf.Lerp( + dangerLevel1Source.volume = MathUtilities.Lerp( dangerLevel1Source.volume, dangerLevel1Volume, Time.fixedDeltaTime * musicLerpSpeed); - dangerLevel2Source.volume = Mathf.Lerp( + dangerLevel2Source.volume = MathUtilities.Lerp( dangerLevel2Source.volume, dangerLevel2Volume, Time.fixedDeltaTime * musicLerpSpeed); diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs index 7763aac0..379bb2f2 100644 --- a/MiraAPI/Hud/CustomActionButton.cs +++ b/MiraAPI/Hud/CustomActionButton.cs @@ -297,7 +297,7 @@ public abstract class CustomActionButton /// The time you want to set to. public virtual void SetTimer(float time) { - Timer = Mathf.Clamp(time, -1, float.MaxValue); + Timer = Math.Clamp(time, -1, float.MaxValue); } /// @@ -333,7 +333,7 @@ public abstract class CustomActionButton /// The amount you want to set to. public virtual void SetUses(int amount) { - UsesLeft = Mathf.Clamp(amount, 0, int.MaxValue); + UsesLeft = Math.Clamp(amount, 0, int.MaxValue); Button?.SetUsesRemaining(UsesLeft); if (Button != null) Button.usesRemainingSprite.color = UsesLeft == 0 ? Color.red : Color.white; diff --git a/MiraAPI/Hud/CustomPaginableMenu.cs b/MiraAPI/Hud/CustomPaginableMenu.cs index 1a13429d..f25e44eb 100644 --- a/MiraAPI/Hud/CustomPaginableMenu.cs +++ b/MiraAPI/Hud/CustomPaginableMenu.cs @@ -121,7 +121,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu list) @@ -170,7 +170,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu(); diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs index 75909a28..47cca20a 100644 --- a/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs +++ b/MiraAPI/LocalSettings/SettingTypes/LocalSliderSetting.cs @@ -88,8 +88,8 @@ public class LocalSliderSetting( newSlider.OnValueChange.AddListener((UnityAction)(() => { SetValue(RoundValue - ? Mathf.Round(Mathf.Lerp(SliderRange.min, SliderRange.max, newSlider.Value)) - : Mathf.Lerp(SliderRange.min, SliderRange.max, newSlider.Value)); + ? MathF.Round(MathUtilities.Lerp(SliderRange.min, SliderRange.max, newSlider.Value)) + : MathUtilities.Lerp(SliderRange.min, SliderRange.max, newSlider.Value)); newSlider.Title.text = GetValueText(); })); diff --git a/MiraAPI/MeetingAbilities/MeetingAbilityBehaviour.cs b/MiraAPI/MeetingAbilities/MeetingAbilityBehaviour.cs index 1f0f7f18..774ec023 100644 --- a/MiraAPI/MeetingAbilities/MeetingAbilityBehaviour.cs +++ b/MiraAPI/MeetingAbilities/MeetingAbilityBehaviour.cs @@ -1,3 +1,4 @@ +using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; using Il2CppInterop.Runtime.Attributes; @@ -125,7 +126,7 @@ public class MeetingAbilityBehaviour : MonoBehaviour /// The maximum timer. public void SetFillUp(float timer, float maxTimer) { - var percentCool = Mathf.Clamp(timer / maxTimer, 0.001f, 1f); + var percentCool = Math.Clamp(timer / maxTimer, 0.001f, 1f); if (percentCool <= 0) percentCool = 1f; Renderer.material.SetFloat(ShaderID.Percent, percentCool); } diff --git a/MiraAPI/MeetingAbilities/MeetingActionButton.cs b/MiraAPI/MeetingAbilities/MeetingActionButton.cs index 290419b5..4db78d63 100644 --- a/MiraAPI/MeetingAbilities/MeetingActionButton.cs +++ b/MiraAPI/MeetingAbilities/MeetingActionButton.cs @@ -1,3 +1,4 @@ +using System; using MiraAPI.Utilities; using MiraAPI.Utilities.Assets; using UnityEngine; @@ -179,7 +180,7 @@ public abstract class MeetingActionButton /// The time you want to set to. public virtual void SetTimer(float time) { - Timer = Mathf.Clamp(time, -1, float.MaxValue); + Timer = Math.Clamp(time, -1, float.MaxValue); } /// @@ -215,7 +216,7 @@ public abstract class MeetingActionButton /// The amount you want to set to. public virtual void SetUses(int amount) { - UsesLeft = Mathf.Clamp(amount, 0, int.MaxValue); + UsesLeft = Math.Clamp(amount, 0, int.MaxValue); Button?.SetUsesRemaining(UsesLeft); if (Button != null) diff --git a/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs b/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs index 0a05c5a0..a1cfd1a8 100644 --- a/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs +++ b/MiraAPI/MeetingAbilities/TargetedMeetingButton.cs @@ -115,7 +115,7 @@ public abstract class TargetedMeetingButton public virtual void UpdateHandler() { Timer -= Time.deltaTime; - Timer = Mathf.Clamp(Timer, 0, int.MaxValue); + Timer = System.Math.Clamp(Timer, 0, int.MaxValue); FixedUpdate(); } diff --git a/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs b/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs index 2760ddbb..54b9e9e3 100644 --- a/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs +++ b/MiraAPI/Modifiers/ModifierDisplay/ModifierDisplayComponent.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -165,7 +166,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr) private void UpdatePage() { var totalPages = Mathf.CeilToInt((float)_modifiers.Count / ItemsPerPage); - _currentPage = Mathf.Clamp(_currentPage, 0, Mathf.Max(0, totalPages - 1)); + _currentPage = Math.Clamp(_currentPage, 0, Math.Max(0, totalPages - 1)); if (_modifiers.Count <= ItemsPerPage) { @@ -177,7 +178,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr) _pagination.gameObject.SetActive(true); if (_pageText != null) { - _pageText.text = $"{MiraLocaleManager.Get("MiraApi.ModifierDisplay.Page", "Page")} {_currentPage + 1}/{Mathf.Max(totalPages, 1)}"; + _pageText.text = $"{MiraLocaleManager.Get("MiraApi.ModifierDisplay.Page", "Page")} {_currentPage + 1}/{Math.Max(totalPages, 1)}"; } _nextButton.gameObject.SetActive(true); @@ -185,7 +186,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr) _modifiers.Do(x => x.Value.gameObject.SetActive(false)); var start = _currentPage * ItemsPerPage; - var end = Mathf.Min(start + ItemsPerPage, _modifiers.Count); + var end = Math.Min(start + ItemsPerPage, _modifiers.Count); var modifiers = _modifiers.ToArray(); for (var i = start; i < end; i++) diff --git a/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs b/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs index b2bba192..4138a570 100644 --- a/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs +++ b/MiraAPI/Patches/Freeplay/TaskAdderPatches.cs @@ -238,7 +238,7 @@ public static class TaskAdderPatches item.transform.SetParent(instance.TaskParent); item.transform.localPosition = new Vector3(xCursor, yCursor, 0f); item.transform.localScale = Vector3.one; - maxHeight = Mathf.Max(maxHeight, item.Text.bounds.size.y + 1.3f); + maxHeight = Math.Max(maxHeight, item.Text.bounds.size.y + 1.3f); xCursor += instance.fileWidth; if (xCursor > instance.lineWidth) { @@ -289,7 +289,7 @@ public static class TaskAdderPatches taskFolder2.Parent = __instance; taskFolder2.transform.localPosition = new Vector3(num, num2, 0f); taskFolder2.transform.localScale = Vector3.one; - num3 = Mathf.Max(num3, taskFolder2.Text.bounds.size.y + 1.1f); + num3 = Math.Max(num3, taskFolder2.Text.bounds.size.y + 1.1f); num += __instance.folderWidth; if (num > __instance.lineWidth) { diff --git a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs index 10dc5c21..41bd4744 100644 --- a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs +++ b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs @@ -93,7 +93,7 @@ internal static class GameOptionsMenuPatch _gamemodeDescription.transform.localPosition = new Vector3(0.3f, 0, -0.01f); _gamemodeDescription.horizontalAlignment = HorizontalAlignmentOptions.Left; var texture = icon.LoadAsset().texture; - var scale = Mathf.Min(128f / texture.width, 128f / texture.height); + var scale = Math.Min(128f / texture.width, 128f / texture.height); var newSprite = Sprite.Create( texture, diff --git a/MiraAPI/Patches/Options/PlayerOptionPatches.cs b/MiraAPI/Patches/Options/PlayerOptionPatches.cs index 0edeb232..cc7ca9d0 100644 --- a/MiraAPI/Patches/Options/PlayerOptionPatches.cs +++ b/MiraAPI/Patches/Options/PlayerOptionPatches.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using HarmonyLib; using MiraAPI.GameOptions; using MiraAPI.Utilities; -using UnityEngine; namespace MiraAPI.Patches.Options; @@ -52,7 +52,7 @@ public static class PlayerOptionPatches return true; } - var newIndex = Mathf.Clamp(index, 0, __instance.Values.Count - 1); + var newIndex = Math.Clamp(index, 0, __instance.Values.Count - 1); __instance.playerIndex = newIndex; __instance.Value = __instance.Values[newIndex].PlayerId; return false; diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index b6372387..8f7fbe04 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -688,8 +688,6 @@ public static class RoleSettingMenuPatches var roleOptionSetting = Object.Instantiate( __instance.roleOptionSettingOrigin, - Vector3.zero, - Quaternion.identity, __instance.RoleChancesSettings.transform); roleOptionSetting.transform.localPosition = new Vector3(-0.1f, scrollerNum, -2f); @@ -743,7 +741,7 @@ public static class RoleSettingMenuPatches passiveButton.interactableColor = btnRend.color = customRole.OptionsMenuColor.FindAlternateColor(); passiveButton.interactableHoveredColor = Color.white; - passiveButton.OnClick.AddListener((UnityAction)(() => { ChangeTab(role, __instance); })); + passiveButton.OnClick.AddListener((UnityAction)(() => ChangeTab(role, __instance))); } if (customRole.Configuration is { MaxRoleCount: 0 }) diff --git a/MiraAPI/Patches/Options/SettingPatches.cs b/MiraAPI/Patches/Options/SettingPatches.cs index fbafc0a0..2b2527b6 100644 --- a/MiraAPI/Patches/Options/SettingPatches.cs +++ b/MiraAPI/Patches/Options/SettingPatches.cs @@ -1,9 +1,9 @@ -using System.Linq; +using System; +using System.Linq; using HarmonyLib; using MiraAPI.GameOptions; using MiraAPI.GameOptions.OptionTypes; using MiraAPI.Utilities; -using UnityEngine; namespace MiraAPI.Patches.Options; @@ -57,7 +57,7 @@ public static class SettingPatches { __result = $"{moddedNumberOption.NegativeWordValue}"; } - else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f) + else if (moddedNumberOption.ZeroWordValue != "#" && Math.Abs(value) < 0.0001f) { __result = $"{moddedNumberOption.ZeroWordValue}"; } @@ -66,7 +66,7 @@ public static class SettingPatches __result = Helpers.FormatValue(value, suffix, formatString); } } - else if (zeroIsInfinity && Mathf.Abs(value) < 0.0001f) + else if (zeroIsInfinity && Math.Abs(value) < 0.0001f) { __result = "∞"; } diff --git a/MiraAPI/Patches/RoleGuidePatches.cs b/MiraAPI/Patches/RoleGuidePatches.cs index 88043ef9..6802e09a 100644 --- a/MiraAPI/Patches/RoleGuidePatches.cs +++ b/MiraAPI/Patches/RoleGuidePatches.cs @@ -147,7 +147,7 @@ public static class RoleGuidePatches } var targetSize = Helpers.MatchInfoGuideBaseScale * - Mathf.Clamp(scaleFactor, MinGuideScaleFactor, MaxGuideScaleFactor); + Math.Clamp(scaleFactor, MinGuideScaleFactor, MaxGuideScaleFactor); instance.transitionOpen.targetSize = targetSize; if (instance.MatchInfoParent.activeSelf) { @@ -1018,7 +1018,7 @@ public static class RoleGuidePatches private static float GetGridScrollBounds(int count) { - return Mathf.Clamp(Mathf.Ceil(count / 2f) * 1.3f - 1.5f, 0f, 999f); + return Math.Clamp(MathF.Ceiling(count / 2f) * 1.3f - 1.5f, 0f, 999f); } private static void StartPopulate(float delay = 0f) diff --git a/MiraAPI/Patches/Roles/TaskPanelPatch.cs b/MiraAPI/Patches/Roles/TaskPanelPatch.cs index e97646da..4e186f87 100644 --- a/MiraAPI/Patches/Roles/TaskPanelPatch.cs +++ b/MiraAPI/Patches/Roles/TaskPanelPatch.cs @@ -1,4 +1,5 @@ -using HarmonyLib; +using System; +using HarmonyLib; using UnityEngine; namespace MiraAPI.Patches.Roles; @@ -52,8 +53,8 @@ internal static class TaskPanelPatch __instance.closedPosition = closePosition; __instance.timer = __instance.open - ? Mathf.Min(1f, __instance.timer + Time.deltaTime / __instance.animationTimeSeconds) - : Mathf.Max(0f, __instance.timer - Time.deltaTime / __instance.animationTimeSeconds); + ? Math.Min(1f, __instance.timer + Time.deltaTime / __instance.animationTimeSeconds) + : Math.Max(0f, __instance.timer - Time.deltaTime / __instance.animationTimeSeconds); var relativePos = new Vector3( Mathf.SmoothStep(__instance.closedPosition.x, __instance.openPosition.x, __instance.timer), diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs index 51ed457f..ca658df9 100644 --- a/MiraAPI/Roles/ICustomRole.cs +++ b/MiraAPI/Roles/ICustomRole.cs @@ -231,7 +231,7 @@ public interface ICustomRole : IOptionable return !Configuration.CanModifyChance ? Configuration.DefaultChance : ParentMod.PluginConfig.TryGetEntry(ChanceConfigDefinition, out ConfigEntry entry) - ? Mathf.Clamp(entry.Value, 0, 100) + ? Math.Clamp(entry.Value, 0, 100) : null; } @@ -242,7 +242,7 @@ public interface ICustomRole : IOptionable int? GetCount() { return ParentMod.PluginConfig.TryGetEntry(NumConfigDefinition, out ConfigEntry entry) - ? Mathf.Clamp(entry.Value, 0, Configuration.MaxRoleCount) + ? Math.Clamp(entry.Value, 0, Configuration.MaxRoleCount) : null; } @@ -260,7 +260,7 @@ public interface ICustomRole : IOptionable if (ParentMod.PluginConfig.TryGetEntry(ChanceConfigDefinition, out ConfigEntry entry)) { - entry.Value = Mathf.Clamp(chance, 0, 100); + entry.Value = Math.Clamp(chance, 0, 100); return; } @@ -275,7 +275,7 @@ public interface ICustomRole : IOptionable { if (ParentMod.PluginConfig.TryGetEntry(NumConfigDefinition, out ConfigEntry entry)) { - entry.Value = Mathf.Clamp(count, 0, Configuration.MaxRoleCount); + entry.Value = Math.Clamp(count, 0, Configuration.MaxRoleCount); return; } diff --git a/MiraAPI/Utilities/Components/CenteredGridArrange.cs b/MiraAPI/Utilities/Components/CenteredGridArrange.cs index 6035f1c6..129860aa 100644 --- a/MiraAPI/Utilities/Components/CenteredGridArrange.cs +++ b/MiraAPI/Utilities/Components/CenteredGridArrange.cs @@ -76,7 +76,7 @@ public class CenteredGridArrange(IntPtr iPtr) : MonoBehaviour(iPtr) { var row = index / MaxColumns; var rowStartIndex = row * MaxColumns; - var itemsInRow = Mathf.Min(MaxColumns, cells.Count - rowStartIndex); + var itemsInRow = Math.Min(MaxColumns, cells.Count - rowStartIndex); var col = index - rowStartIndex; var rowWidth = (itemsInRow - 1) * CellSize.x; diff --git a/MiraAPI/Utilities/Components/LoadingRing.cs b/MiraAPI/Utilities/Components/LoadingRing.cs index b0ba1285..a9675d64 100644 --- a/MiraAPI/Utilities/Components/LoadingRing.cs +++ b/MiraAPI/Utilities/Components/LoadingRing.cs @@ -72,10 +72,10 @@ public class LoadingRing(IntPtr cppPtr) : MonoBehaviour(cppPtr) { var dx = x + 0.5f - (size / 2f); var dy = y + 0.5f - (size / 2f); - var radius = Mathf.Sqrt((dx * dx) + (dy * dy)); - var ring = Mathf.Clamp01(radius - innerRadius) * Mathf.Clamp01(outerRadius - radius); - var angle = (Mathf.Atan2(dy, dx) + Mathf.PI) / (2f * Mathf.PI); - pixels[(y * size) + x] = new Color(1f, 1f, 1f, ring * Mathf.Lerp(1f, 0.1f, angle)); + var radius = MathF.Sqrt((dx * dx) + (dy * dy)); + var ring = MathUtilities.Clamp01(radius - innerRadius) * MathUtilities.Clamp01(outerRadius - radius); + var angle = (MathF.Atan2(dy, dx) + MathF.PI) / (2f * MathF.PI); + pixels[(y * size) + x] = new Color(1f, 1f, 1f, ring * MathUtilities.Lerp(1f, 0.1f, angle)); } } diff --git a/MiraAPI/Utilities/Extensions.cs b/MiraAPI/Utilities/Extensions.cs index a2efe4ac..eee53ddc 100644 --- a/MiraAPI/Utilities/Extensions.cs +++ b/MiraAPI/Utilities/Extensions.cs @@ -89,7 +89,7 @@ public static class Extensions /// The format string to use for the timer text. public static void SetCooldownFormat(this ActionButton? button, float timer, float maxTimer, string format = "0") { - var num = Mathf.Clamp(timer / maxTimer, 0f, 1f); + var num = Math.Clamp(timer / maxTimer, 0f, 1f); button!.isCoolingDown = num > 0f; button.SetCooldownFill(num); if (button.isCoolingDown) @@ -111,7 +111,7 @@ public static class Extensions /// The format string to use for the timer text. public static void SetFillUpFormat(this ActionButton button, float timer, float maxTimer, string format = "0") { - var num = Mathf.Clamp(timer / maxTimer, 0f, 1f); + var num = Math.Clamp(timer / maxTimer, 0f, 1f); button.isCoolingDown = num > 0f; if (button.isCoolingDown && timer < 3f) { diff --git a/MiraAPI/Utilities/GuideOptionsPatches.cs b/MiraAPI/Utilities/GuideOptionsPatches.cs index f9bc6988..1667606b 100644 --- a/MiraAPI/Utilities/GuideOptionsPatches.cs +++ b/MiraAPI/Utilities/GuideOptionsPatches.cs @@ -125,7 +125,7 @@ internal static class GuideOptionPages item.Group.MatchInfoGuidePageOrder, GetMenuOrder(item.Group.ParentMenu), item.Group.GroupPriority, - Mathf.Clamp(item.Group.MatchInfoGuidePageColumns, 1, 6), + Math.Clamp(item.Group.MatchInfoGuidePageColumns, 1, 6), item.ModAbbreviation, modSearchTerms, entries); diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs index 0c334a42..3d1016e2 100644 --- a/MiraAPI/Utilities/Helpers.cs +++ b/MiraAPI/Utilities/Helpers.cs @@ -284,7 +284,7 @@ public static class Helpers where T : MonoBehaviour { T? closest = null; - var closestDistanceSqr = Mathf.Infinity; + var closestDistanceSqr = float.PositiveInfinity; foreach (var obj in objectList) { @@ -805,8 +805,8 @@ public static class Helpers obj.transform.localPosition = new Vector3(0f, 0.5f, 0f); var scrollHeight = variableTextSizing ? desc.textBounds.size.y - 2.5f + maxTextSize + 0.475f - : desc.textBounds.size.y - 2.5f + Mathf.Ceil(num / 2f) * 1.45f; - parent.SetYBoundsMax(Mathf.Clamp(scrollHeight, 0f, 999f)); + : desc.textBounds.size.y - 2.5f + MathF.Ceiling(num / 2f) * 1.45f; + parent.SetYBoundsMax(Math.Clamp(scrollHeight, 0f, 999f)); return obj; } @@ -888,7 +888,7 @@ public static class Helpers const float groupHeaderContentGap = 0.05f; const int contentSortingOrder = 151; - columns = Mathf.Clamp(columns, 1, 6); + columns = Math.Clamp(columns, 1, 6); var inner = parent.Inner; var layout = inner.GetComponent(); if (layout) @@ -896,11 +896,11 @@ public static class Helpers layout.enabled = false; } - var columnGap = layout ? Mathf.Clamp(layout.spacing.x, 0.1f, 0.6f) : 0.3f; + var columnGap = layout ? Math.Clamp(layout.spacing.x, 0.1f, 0.6f) : 0.3f; const int baseColumnCount = 2; - var baseColumnWidth = layout ? Mathf.Clamp(layout.cellSize.x, 2f, 3.2f) : 2.7f; + var baseColumnWidth = layout ? Math.Clamp(layout.cellSize.x, 2f, 3.2f) : 2.7f; var availableWidth = baseColumnWidth * baseColumnCount + columnGap * (baseColumnCount - 1); - var columnWidth = Mathf.Clamp( + var columnWidth = Math.Clamp( (availableWidth - (columns - 1) * columnGap) / columns, 1f, 3.2f); @@ -971,7 +971,7 @@ public static class Helpers var group = groupedSettings[i].Key; var band = i / columns; groupColumns[group] = i % columns; - bandHeights[band] = Mathf.Max( + bandHeights[band] = Math.Max( bandHeights[band], rowPitch * (groupedSettings[i].Count() + 1) + groupHeaderContentGap + 0.25f); } @@ -979,7 +979,7 @@ public static class Helpers var bandOffset = 0f; for (var band = 0; band < bandCount; band++) { - for (var i = band * columns; i < Mathf.Min((band + 1) * columns, groupedSettings.Count); i++) + for (var i = band * columns; i < Math.Min((band + 1) * columns, groupedSettings.Count); i++) { groupTopOffsets[groupedSettings[i].Key] = bandOffset; groupRows[groupedSettings[i].Key] = 0; @@ -1209,7 +1209,7 @@ public static class Helpers { if (renderer.enabled && renderer.gameObject.activeInHierarchy) { - contentBottom = Mathf.Min( + contentBottom = Math.Min( contentBottom, inner.InverseTransformPoint(renderer.bounds.min).y); } @@ -1225,7 +1225,7 @@ public static class Helpers var scrollRange = contentOverflow > 0.05f ? contentOverflow + 0.05f : 0f; - parent.SetYBoundsMax(Mathf.Clamp(scrollRange, 0f, 999f)); + parent.SetYBoundsMax(Math.Clamp(scrollRange, 0f, 999f)); return page; }