mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
use Math/MathF instead of Mathf because il2cpp
This commit is contained in:
25 files changed
+74
-69
No files matched your search
@@ -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),
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -297,7 +297,7 @@ public abstract class CustomActionButton
|
||||
/// <param name="time">The time you want to set to.</param>
|
||||
public virtual void SetTimer(float time)
|
||||
{
|
||||
Timer = Mathf.Clamp(time, -1, float.MaxValue);
|
||||
Timer = Math.Clamp(time, -1, float.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -333,7 +333,7 @@ public abstract class CustomActionButton
|
||||
/// <param name="amount">The amount you want to set to.</param>
|
||||
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;
|
||||
|
||||
@@ -121,7 +121,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
||||
|
||||
private static int GetTotalPages(int itemCount)
|
||||
{
|
||||
return Mathf.Max(1, Mathf.CeilToInt(itemCount / (float)ItemsPerPage));
|
||||
return Math.Max(1, Mathf.CeilToInt(itemCount / (float)ItemsPerPage));
|
||||
}
|
||||
|
||||
private void RefreshControllerOverlay(CppCollections.List<UiElement> list)
|
||||
@@ -170,7 +170,7 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu<CustomPaginableMenu.
|
||||
var filtered = GetFilteredEntries();
|
||||
noResultsText?.gameObject.SetActive(filtered.Count == 0 && !string.IsNullOrWhiteSpace(searchText));
|
||||
var totalPages = GetTotalPages(filtered.Count);
|
||||
currentPage = Mathf.Clamp(currentPage, 0, totalPages - 1);
|
||||
currentPage = Math.Clamp(currentPage, 0, totalPages - 1);
|
||||
|
||||
var list = filtered.Skip(currentPage * ItemsPerPage).Take(ItemsPerPage).ToList();
|
||||
var list2 = new CppCollections.List<UiElement>();
|
||||
|
||||
@@ -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();
|
||||
}));
|
||||
|
||||
@@ -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
|
||||
/// <param name="maxTimer">The maximum timer.</param>
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
@@ -179,7 +180,7 @@ public abstract class MeetingActionButton
|
||||
/// <param name="time">The time you want to set to.</param>
|
||||
public virtual void SetTimer(float time)
|
||||
{
|
||||
Timer = Mathf.Clamp(time, -1, float.MaxValue);
|
||||
Timer = Math.Clamp(time, -1, float.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -215,7 +216,7 @@ public abstract class MeetingActionButton
|
||||
/// <param name="amount">The amount you want to set to.</param>
|
||||
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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -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 = $"<b>{moddedNumberOption.NegativeWordValue}</b>";
|
||||
}
|
||||
else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f)
|
||||
else if (moddedNumberOption.ZeroWordValue != "#" && Math.Abs(value) < 0.0001f)
|
||||
{
|
||||
__result = $"<b>{moddedNumberOption.ZeroWordValue}</b>";
|
||||
}
|
||||
@@ -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 = "<b>∞</b>";
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -231,7 +231,7 @@ public interface ICustomRole : IOptionable
|
||||
return !Configuration.CanModifyChance
|
||||
? Configuration.DefaultChance
|
||||
: ParentMod.PluginConfig.TryGetEntry(ChanceConfigDefinition, out ConfigEntry<int> 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<int> 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<int> 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<int> entry))
|
||||
{
|
||||
entry.Value = Mathf.Clamp(count, 0, Configuration.MaxRoleCount);
|
||||
entry.Value = Math.Clamp(count, 0, Configuration.MaxRoleCount);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public static class Extensions
|
||||
/// <param name="format">The format string to use for the timer text.</param>
|
||||
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
|
||||
/// <param name="format">The format string to use for the timer text.</param>
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<GridLayoutGroup>();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user