2019-01-26 00:39:37 +00:00
|
|
|
|
using System;
|
2020-09-13 01:16:19 +00:00
|
|
|
|
using System.Diagnostics.Contracts;
|
2019-01-26 00:39:37 +00:00
|
|
|
|
|
2019-02-01 17:19:20 +00:00
|
|
|
|
namespace RobloxFiles.DataTypes
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2019-02-01 18:40:39 +00:00
|
|
|
|
public class NumberRange
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
|
|
|
|
public readonly float Min;
|
|
|
|
|
public readonly float Max;
|
|
|
|
|
|
2019-11-01 02:40:31 +00:00
|
|
|
|
public override string ToString() => $"{Min} {Max}";
|
|
|
|
|
|
2019-06-30 22:01:19 +00:00
|
|
|
|
public NumberRange(float num)
|
|
|
|
|
{
|
|
|
|
|
Min = num;
|
|
|
|
|
Max = num;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 01:16:19 +00:00
|
|
|
|
public NumberRange(float min = 0, float max = 0)
|
2019-11-01 02:40:31 +00:00
|
|
|
|
{
|
2020-09-13 01:16:19 +00:00
|
|
|
|
Contract.Requires(max - min >= 0, "Max must be greater than min.");
|
|
|
|
|
Contract.EndContractBlock();
|
|
|
|
|
|
|
|
|
|
Min = min;
|
|
|
|
|
Max = max;
|
2019-11-01 02:40:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-14 16:20:34 +00:00
|
|
|
|
internal NumberRange(Attribute attr) : this(attr.ReadFloat(), attr.ReadFloat())
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2020-09-13 01:16:19 +00:00
|
|
|
|
}
|
2019-01-26 00:39:37 +00:00
|
|
|
|
|
2020-09-13 01:16:19 +00:00
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return Min.GetHashCode() ^ Max.GetHashCode();
|
2019-01-26 00:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-09-13 01:16:19 +00:00
|
|
|
|
public override bool Equals(object obj)
|
2019-01-26 00:39:37 +00:00
|
|
|
|
{
|
2021-02-18 19:15:08 +00:00
|
|
|
|
if (!(obj is NumberRange other))
|
2020-09-13 01:16:19 +00:00
|
|
|
|
return false;
|
2019-11-01 02:40:31 +00:00
|
|
|
|
|
2020-09-13 01:16:19 +00:00
|
|
|
|
if (!Min.Equals(other.Min))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Max.Equals(other.Max))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return true;
|
2019-01-26 00:39:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|