Skip to content

Range

With this struct we can easily define number ranges, which is currently especially useful for particle emitter configuration.

The range struct is defined like this.

public struct Range<T> where T : IComparable<T>
{
    public T Minimum { get; private set; }
    public T Maximum { get; private set; }

    public Range(T minimum, T maximum)
    {
        Minimum = minimum;
        Maximum = maximum;
    }

    public Range(T value)
    {
        Minimum = value;
        Maximum = value;
    }

    public override string ToString()
    {
        return $"[{Minimum}, {Maximum}]";
    }

    // Implicit Conversions
    public static implicit operator Range<T>(T value)
    {
        return new Range<T>(value);
    }
}