Files
2025-10-10 15:10:36 +07:00

26 lines
774 B
C#

public static class AAssist
{
// Bản generic (giống template C++)
public static void a_ClampRoof<T>(ref T x, T max) where T : System.IComparable<T>
{
if (x.CompareTo(max) > 0) x = max;
}
// Tiện dụng cho float (Unity)
public static void a_ClampRoof(ref float x, float max)
{
if (x > max) x = max;
}
// (Tuỳ chọn) giữ luôn 2 hàm “họ hàng” như trong header gốc:
public static void a_ClampFloor<T>(ref T x, T min) where T : System.IComparable<T>
{
if (x.CompareTo(min) < 0) x = min;
}
public static void a_Clamp<T>(ref T x, T min, T max) where T : System.IComparable<T>
{
if (x.CompareTo(min) < 0) x = min;
if (x.CompareTo(max) > 0) x = max;
}
}