mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* push * fix * push * abstract and more accurate * new abstract method I guess * that table does not explode * webedit major * Update Content.Shared/EntityTable/ValueSelector/BinomialNumberSelector.cs Co-authored-by: SnappingOpossum <snappingopossum@outlook.com> * big ass merge conflicts * sadas * review --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: SnappingOpossum <snappingopossum@outlook.com>
33 lines
789 B
C#
33 lines
789 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);
|
|
}
|
|
|
|
public override float Odds()
|
|
{
|
|
return Range.X == 0 ? 1f / (Range.Y + 1) : 1;
|
|
}
|
|
|
|
public override float Average()
|
|
{
|
|
return (Range.X + Range.Y) / 2f;
|
|
}
|
|
}
|