using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Linq.Expressions; using UnityEngine; #if UNITY_EDITOR using UnityEditorInternal; #endif namespace Mountools.Tools { public static class MountoolsMath { public static bool IsInRange(int n, int min, int max, bool equals = true) { return equals ? n <= max && n >= min : n < max && n > min ; } public static bool IsInRange(float n, float min, float max, bool equals = true) { return equals ? n <= max && n >= min : n < max && n > min ; } public static int InRange(int n, int min, int max) { if (n < min) return min; if (n > max) return max; return n; } public static float InRange(float n, float min, float max) { if (n < min) return min; if (n > max) return max; return n; } public static float To(float a, float b, float t) { if (a > b) return InRange(a - t, b, a); if (a < b) return InRange(a + t, a, b); return a; } public static int To(int a, int b, int t) { if (a > b) return InRange(a - t, b, a); if (a < b) return InRange(a + t, a, b); return a; } } }