Photon Fusion 2.1.1

NetworkRNG Struct Reference

PCG32 random generator, 16 bytes in size. http://www.pcg-random.org. More...

Inherits INetworkStruct.

Public Member Functions

readonly override int GetHashCode ()
 Overrides the default hash function.
 NetworkRNG (int seed)
 Create a new RNGSession with the given seed.
float Next ()
int Next (int minInclusive, int maxExclusive)
 Returns a random int within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped.
long Next (long minInclusive, long maxExclusive)
 Returns a random long within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped.
uint Next (uint maxExclusive)
 Returns a random uint within [0, maxExclusive ).
uint Next (uint minInclusive, uint maxExclusive)
 Returns a random uint within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped.
ulong Next (ulong maxExclusive)
 Returns a random ulong within [0, maxExclusive ).
ulong Next (ulong minInclusive, ulong maxExclusive)
 Returns a random ulong within [minInclusive, maxExclusive) (range is exclusive). If minInclusive and maxExclusive are equal, then the "exclusive rule" is ignored and minInclusive will be returned. If minInclusive is greater than maxExclusive, then the numbers are automatically swapped.
double NextDouble ()
 Generates a random double value within the inclusive range [0, 1].
double NextDoubleExclusive ()
 Generates a random double value within the exclusive range [0, 1).
double NextInclusive (double minInclusive, double maxInclusive)
 Returns a random double within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.
float NextInclusive (float minInclusive, float maxInclusive)
 Returns a random float within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.
int NextInclusive (int minInclusive, int maxInclusive)
 Returns a random int within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.
long NextInclusive (long minInclusive, long maxInclusive)
 Returns a random long within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.
uint NextInclusive (uint maxInclusive)
 Returns a random uint within [0, maxInclusive ].
uint NextInclusive (uint minInclusive, uint maxInclusive)
 Returns a random uint within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.
ulong NextInclusive (ulong maxInclusive)
 Returns a random uint within [0, maxInclusive ].
ulong NextInclusive (ulong minInclusive, ulong maxInclusive)
 Returns a random ulong within [minInclusive, maxInclusive] (range is inclusive). If minInclusive is greater than maxInclusive, then the numbers are automatically swapped.
int NextInt32 ()
 Generates a uniformly distributed random int.
long NextInt64 ()
 Generates a uniformly distributed random int64.
float NextSingle ()
 Generates a random float value within the inclusive range [0, 1].
float NextSingleExclusive ()
 Generates a random float value within the exclusive range [0, 1).
uint NextUInt32 ()
 Gets the.
ulong NextUInt64 ()
 Generates a uniformly distributed random ulong.
int RangeExclusive (int minExclusive, int maxExclusive)
uint RangeExclusive (uint minExclusive, uint maxExclusive)
double RangeInclusive (double minInclusive, double maxInclusive)
float RangeInclusive (float minInclusive, float maxInclusive)
int RangeInclusive (int minInclusive, int maxInclusive)
uint RangeInclusive (uint minInclusive, uint maxInclusive)

Static Public Attributes

const uint MAX = uint.MaxValue
 The maximum possible value to generate.
const int SIZE = 16
 The size of the struct in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed.

Properties

readonly NetworkRNG Peek [get]
 Returns a copy of this RNGSession, can be used to check what next random values will be without affecting the state.

Detailed Description

PCG32 random generator, 16 bytes in size. http://www.pcg-random.org.

Constructor & Destructor Documentation

◆ NetworkRNG()

NetworkRNG ( int seed)

Create a new RNGSession with the given seed.

Parameters
seedThe random number generator seed.

Member Function Documentation

◆ GetHashCode()

readonly override int GetHashCode ( )

Overrides the default hash function.

Returns
A hash code for the current object.

◆ Next() [1/2]

uint Next ( uint maxExclusive)

Returns a random uint within [0, maxExclusive ).

Returns
A random int within [0, maxExclusive )

◆ Next() [2/2]

ulong Next ( ulong maxExclusive)

Returns a random ulong within [0, maxExclusive ).

Returns
A random ulong within [0, maxExclusive )

◆ NextDouble()

double NextDouble ( )

Generates a random double value within the inclusive range [0, 1].

Returns
A random double value between 0 and 1, inclusive.

◆ NextDoubleExclusive()

double NextDoubleExclusive ( )

Generates a random double value within the exclusive range [0, 1).

Returns
A random double value between 0 (inclusive) and 1 (exclusive).

◆ NextSingle()

float NextSingle ( )

Generates a random float value within the inclusive range [0, 1].

Returns
A random float value between 0 and 1, inclusive.

◆ NextSingleExclusive()

float NextSingleExclusive ( )

Generates a random float value within the exclusive range [0, 1).

Returns
A random float value between 0 (inclusive) and 1 (exclusive).

◆ NextUInt32()

uint NextUInt32 ( )

Gets the.

Returns