Files
tbd-station-14/Content.Shared/EntityTable/ValueSelector/RangeNumberSelector.cs
Nemanja 91e441ada1 Infer NumberSelector type in EntityTables (#36568)
* Infer number selector types from context

* forgor
2025-05-15 11:21:54 +10:00

23 lines
599 B
C#

namespace Content.Shared.EntityTable.ValueSelector;
/// <summary>
/// Gives a value between the two numbers specified, inclusive.
/// </summary>
public sealed partial class RangeNumberSelector : NumberSelector
{
[DataField]
public Vector2i Range = new(1, 1);
public RangeNumberSelector(Vector2i range)
{
Range = range;
}
public override int Get(System.Random rand)
{
// 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);
}
}