2024-08-09 22:12:40 -04:00
|
|
|
namespace Content.Shared.EntityTable.ValueSelector;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gives a value between the two numbers specified, inclusive.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public sealed partial class RangeNumberSelector : NumberSelector
|
|
|
|
|
{
|
|
|
|
|
[DataField]
|
2025-04-14 14:02:49 -07:00
|
|
|
public Vector2i Range = new(1, 1);
|
2024-08-09 22:12:40 -04:00
|
|
|
|
2025-05-14 21:21:54 -04:00
|
|
|
public RangeNumberSelector(Vector2i range)
|
|
|
|
|
{
|
|
|
|
|
Range = range;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-14 14:02:49 -07:00
|
|
|
public override int Get(System.Random rand)
|
2024-08-09 22:12:40 -04:00
|
|
|
{
|
2025-04-14 14:02:49 -07:00
|
|
|
// rand.Next() is inclusive on the first number and exclusive on the second number,
|
|
|
|
|
// so we add 1 to the second number.
|
|
|
|
|
return rand.Next(Range.X, Range.Y + 1);
|
2024-08-09 22:12:40 -04:00
|
|
|
}
|
|
|
|
|
}
|