mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 14:15:49 +00:00
22 lines
571 B
C#
22 lines
571 B
C#
using System;
|
|
|
|
namespace PckStudio.Core.Extensions
|
|
{
|
|
public static class MathExtensions
|
|
{
|
|
public static T Clamp<T>(T value, T min, T max) where T : IComparable<T>
|
|
{
|
|
if (value.CompareTo(min) < 0)
|
|
return min;
|
|
if (value.CompareTo(max) > 0)
|
|
return max;
|
|
return value;
|
|
}
|
|
|
|
public static bool IsWithinRangeOf<T>(this T value, T min, T max) where T : IComparable<T>
|
|
{
|
|
return value.CompareTo(min) >= 0 && value.CompareTo(max) <= 0;
|
|
}
|
|
}
|
|
}
|