Class ThreadSafeRandom
- Namespace
- Vintagestory.API.Util
- Assembly
- VintagestoryAPI.dll
public class ThreadSafeRandom : Random
- Inheritance
-
ThreadSafeRandom
- Inherited Members
- Extension Methods
Constructors
ThreadSafeRandom()
public ThreadSafeRandom()
ThreadSafeRandom(int)
public ThreadSafeRandom(int seed)
Parameters
seedint
Methods
Next()
Returns a non-negative random integer.
public override int Next()
Returns
- int
A 32-bit signed integer that is greater than or equal to 0 and less than Int32.MaxValue.
Next(int)
Returns a non-negative random integer that is less than the specified maximum.
public override int Next(int maxValue)
Parameters
maxValueintThe exclusive upper bound of the random number to be generated.
maxValuemust be greater than or equal to 0.
Returns
- int
A 32-bit signed integer that is greater than or equal to 0, and less than
maxValue; that is, the range of return values ordinarily includes 0 but notmaxValue. However, ifmaxValueequals 0, 0 is returned.
Exceptions
- ArgumentOutOfRangeException
maxValueis less than 0.
Next(int, int)
Returns a random integer that is within a specified range.
public override int Next(int minValue, int maxValue)
Parameters
minValueintThe inclusive lower bound of the random number returned.
maxValueintThe exclusive upper bound of the random number returned.
maxValuemust be greater than or equal tominValue.
Returns
- int
A 32-bit signed integer greater than or equal to
minValueand less thanmaxValue; that is, the range of return values includesminValuebut notmaxValue. IfminValueequalsmaxValue,minValueis returned.
Exceptions
- ArgumentOutOfRangeException
minValueis greater thanmaxValue.
NextBytes(byte[])
Fills the elements of a specified array of bytes with random numbers.
public override void NextBytes(byte[] buffer)
Parameters
bufferbyte[]The array to be filled with random numbers.
Exceptions
- ArgumentNullException
bufferis null.
NextDouble()
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
public override double NextDouble()
Returns
- double
A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.