mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* documentation pass on content.server -> E! * APi pass on content.server for the E folder. * documentation pass on content.shared for e. * Apply suggestions from code review Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> * fixing documentation according to review part 1. * typo * Very minor fixes * And a short explanation about EUI --------- Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
37 lines
923 B
C#
37 lines
923 B
C#
using Robust.Shared.Random;
|
|
|
|
namespace Content.Shared.EntityTable.ValueSelector;
|
|
|
|
/// <summary>
|
|
/// Gives a value between the two numbers specified, inclusive.
|
|
/// </summary>
|
|
public sealed partial class RangeNumberSelector : NumberSelector
|
|
{
|
|
/// <summary>
|
|
/// The min and max value of this selector, both are inclusive.
|
|
/// </summary>
|
|
[DataField]
|
|
public Vector2i Range = new(1, 1);
|
|
|
|
public RangeNumberSelector(Vector2i range)
|
|
{
|
|
Range = range;
|
|
}
|
|
|
|
public override int Get(IRobustRandom 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);
|
|
}
|
|
|
|
public override float Odds()
|
|
{
|
|
return Range.X == 0 ? 1f / (Range.Y + 1) : 1;
|
|
}
|
|
|
|
public override float Average()
|
|
{
|
|
return (Range.X + Range.Y) / 2f;
|
|
}
|
|
}
|