LethalCompany/Lethal Company/ExportedProject/Assets/Scripts/Assembly-CSharp/DunGen/NumberUtil.cs

29 lines
558 B
C#
Raw Normal View History

2023-12-22 22:51:17 +00:00
using UnityEngine;
namespace DunGen
{
public static class NumberUtil
{
public static float ClampToNearest(float value, params float[] possibleValues)
{
float[] array = new float[possibleValues.Length];
for (int i = 0; i < possibleValues.Length; i++)
{
array[i] = Mathf.Abs(value - possibleValues[i]);
}
float num = float.MaxValue;
int num2 = 0;
for (int j = 0; j < array.Length; j++)
{
float num3 = array[j];
if (num3 < num)
{
num = num3;
num2 = j;
}
}
return possibleValues[num2];
}
}
}