Repository navigation
MinMax
Inclusive numeric intervals. Endpoints A and B are unordered: (5, 1) is the same interval as (1, 5). Min / Max always return the numeric bounds.
Three structs: MinMaxInt, MinMaxFloat, MinMaxDouble. All are [Serializable] and IEquatable<>.
using Mane.DotNet;
MinMaxInt damage = new(3, 10);
int rolled = damage.Clamp(12); // 10
bool inside = damage.Contains(3); // true
MinMaxFloat speed = new(.5f, 2f);
float capped = 3f.Clamp(speed); // 2 — MinMaxExtensionsContains(value, includeMin = true, includeMax = true) is inclusive by default. Pass includeMin: false or includeMax: false for half-open ranges.
Clamp(value) returns value limited to [Min, Max].
Sugar on the value side (same types): value.IsInRange(range) and value.Clamp(range).
-
+—[a.Min + b.Min, a.Max + b.Max] -
-—[a.Min - b.Max, a.Max - b.Min] -
*//— scale stored endpointsAandB(intdivision is integer division) -
MinMaxInt+,-,*usecheckedarithmetic and throw on overflow
Equality compares normalized bounds, so (5, 1) equals (1, 5).
For MinMaxFloat and MinMaxDouble, == and != compare within ManeConst.FloatTolerance / DoubleTolerance, while Equals and GetHashCode are exact, the same split as Unity's Vector3. Dictionaries and sets use Equals, so they work as keys: two intervals that are only within the tolerance of each other are different keys.
Assert.IsTrue(new MinMaxInt(5, 1) == new MinMaxInt(1, 5));
Console.WriteLine(new MinMaxInt(1, 5)); // [1, 5]When you serialize these structs from ManeTools-Unity, a property drawer draws linked min/max fields and swaps them if you invert the order. Decorators from that package can still sit on the same field.

openupm add com.manefunction.tools-dotnet