public static class AAssist { // Bản generic (giống template C++) public static void a_ClampRoof(ref T x, T max) where T : System.IComparable { 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(ref T x, T min) where T : System.IComparable { if (x.CompareTo(min) < 0) x = min; } public static void a_Clamp(ref T x, T min, T max) where T : System.IComparable { if (x.CompareTo(min) < 0) x = min; if (x.CompareTo(max) > 0) x = max; } }