Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FRandomStream Struct Reference

#include <RandomStream.h>

Public Member Functions

 FRandomStream ()
 
 FRandomStream (int32 InSeed)
 
 FRandomStream (FName InName)
 
void Initialize (int32 InSeed)
 
void Initialize (FName InName)
 
void Reset () const
 
int32 GetInitialSeed () const
 
void GenerateNewSeed ()
 
float GetFraction () const
 
uint32 GetUnsignedInt () const
 
FVector GetUnitVector () const
 
int32 GetCurrentSeed () const
 
FORCEINLINE float FRand () const
 
FORCEINLINE int32 RandHelper (int32 A) const
 
FORCEINLINE int32 RandRange (int32 Min, int32 Max) const
 
FORCEINLINE FVector::FReal FRandRange (FVector::FReal InMin, FVector::FReal InMax) const
 
FORCEINLINE FVector VRand () const
 
FORCEINLINE FVector RandPointInBox (const FBox &Box) const
 
FORCEINLINE FVector VRandCone (FVector const &Dir, float ConeHalfAngleRad) const
 
FORCEINLINE FVector VRandCone (FVector const &Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad) const
 
FString ToString () const
 

Protected Member Functions

void MutateSeed () const
 

Private Attributes

int32 InitialSeed
 
uint32 Seed
 

Friends

struct Z_Construct_UScriptStruct_FRandomStream_Statics
 

Detailed Description

Implements a thread-safe SRand based RNG.

Very bad quality in the lower bits. Don't use the modulus (%) operator.

Definition at line 19 of file RandomStream.h.

Constructor & Destructor Documentation

◆ FRandomStream() [1/3]

FRandomStream::FRandomStream ( )
inline

Default constructor.

The seed should be set prior to use.

Definition at line 30 of file RandomStream.h.

◆ FRandomStream() [2/3]

FRandomStream::FRandomStream ( int32 InSeed)
inline

Creates and initializes a new random stream from the specified seed value.

Parameters
InSeedThe seed value.

Definition at line 40 of file RandomStream.h.

+ Here is the call graph for this function:

◆ FRandomStream() [3/3]

FRandomStream::FRandomStream ( FName InName)
inline

Creates and initializes a new random stream from the specified name.

Note
If NAME_None is provided, the stream will be seeded using the current time.
Parameters
InNameThe name value from which the stream will be initialized.

Definition at line 51 of file RandomStream.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ FRand()

FORCEINLINE float FRandomStream::FRand ( ) const
inline

Mirrors the random number API in FMath

Returns
Random number.

Definition at line 176 of file RandomStream.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FRandRange()

FORCEINLINE FVector::FReal FRandomStream::FRandRange ( FVector::FReal InMin,
FVector::FReal InMax ) const
inline

Helper function for rand implementations.

Returns
A random number >= Min and <= Max

Definition at line 209 of file RandomStream.h.

◆ GenerateNewSeed()

void FRandomStream::GenerateNewSeed ( )
inline

Generates a new random seed.

Definition at line 105 of file RandomStream.h.

◆ GetCurrentSeed()

int32 FRandomStream::GetCurrentSeed ( ) const
inline

Gets the current seed.

Returns
Current seed.

Definition at line 166 of file RandomStream.h.

◆ GetFraction()

float FRandomStream::GetFraction ( ) const
inline

Returns a random float number in the range [0, 1).

Returns
Random number.

Definition at line 115 of file RandomStream.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetInitialSeed()

int32 FRandomStream::GetInitialSeed ( ) const
inline

Definition at line 97 of file RandomStream.h.

◆ GetUnitVector()

FVector FRandomStream::GetUnitVector ( ) const
inline

Returns a random vector of unit size.

Returns
Random unit vector.

Definition at line 143 of file RandomStream.h.

◆ GetUnsignedInt()

uint32 FRandomStream::GetUnsignedInt ( ) const
inline

Returns a random number between 0 and MAXUINT.

Returns
Random number.

Definition at line 131 of file RandomStream.h.

+ Here is the call graph for this function:

◆ Initialize() [1/2]

void FRandomStream::Initialize ( FName InName)
inline

Initializes this random stream using the specified name.

Note
If NAME_None is provided, the stream will be seeded using the current time.
Parameters
InNameThe name value from which the stream will be initialized.

Definition at line 75 of file RandomStream.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Initialize() [2/2]

void FRandomStream::Initialize ( int32 InSeed)
inline

Initializes this random stream with the specified seed value.

Parameters
InSeedThe seed value.

Definition at line 63 of file RandomStream.h.

+ Here is the caller graph for this function:

◆ MutateSeed()

void FRandomStream::MutateSeed ( ) const
inlineprotected

Mutates the current seed into the next seed.

Definition at line 340 of file RandomStream.h.

+ Here is the caller graph for this function:

◆ RandHelper()

FORCEINLINE int32 FRandomStream::RandHelper ( int32 A) const
inline

Helper function for rand implementations.

Returns
A random number in [0..A)

Definition at line 186 of file RandomStream.h.

+ Here is the caller graph for this function:

◆ RandPointInBox()

FORCEINLINE FVector FRandomStream::RandPointInBox ( const FBox & Box) const
inline

Definition at line 224 of file RandomStream.h.

◆ RandRange()

FORCEINLINE int32 FRandomStream::RandRange ( int32 Min,
int32 Max ) const
inline

Helper function for rand implementations.

Returns
A random number >= Min and <= Max

Definition at line 197 of file RandomStream.h.

+ Here is the call graph for this function:

◆ Reset()

void FRandomStream::Reset ( ) const
inline

Resets this random stream to the initial seed value.

Definition at line 92 of file RandomStream.h.

◆ ToString()

FString FRandomStream::ToString ( ) const
inline

Get a textual representation of the RandomStream.

Returns
Text describing the RandomStream.

Definition at line 330 of file RandomStream.h.

◆ VRand()

FORCEINLINE FVector FRandomStream::VRand ( ) const
inline

Returns a random vector of unit size.

Returns
Random unit vector.

Definition at line 219 of file RandomStream.h.

◆ VRandCone() [1/2]

FORCEINLINE FVector FRandomStream::VRandCone ( FVector const & Dir,
float ConeHalfAngleRad ) const
inline

Returns a random unit vector, uniformly distributed, within the specified cone.

Parameters
DirThe center direction of the cone
ConeHalfAngleRadHalf-angle of cone, in radians.
Returns
Normalized vector within the specified cone.

Definition at line 238 of file RandomStream.h.

+ Here is the call graph for this function:

◆ VRandCone() [2/2]

FORCEINLINE FVector FRandomStream::VRandCone ( FVector const & Dir,
float HorizontalConeHalfAngleRad,
float VerticalConeHalfAngleRad ) const
inline

Returns a random unit vector, uniformly distributed, within the specified cone.

Parameters
DirThe center direction of the cone
HorizontalConeHalfAngleRadHorizontal half-angle of cone, in radians.
VerticalConeHalfAngleRadVertical half-angle of cone, in radians.
Returns
Normalized vector within the specified cone.

Definition at line 283 of file RandomStream.h.

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ Z_Construct_UScriptStruct_FRandomStream_Statics

friend struct Z_Construct_UScriptStruct_FRandomStream_Statics
friend

Definition at line 21 of file RandomStream.h.

Member Data Documentation

◆ InitialSeed

int32 FRandomStream::InitialSeed
private

Definition at line 348 of file RandomStream.h.

◆ Seed

uint32 FRandomStream::Seed
mutableprivate

Definition at line 352 of file RandomStream.h.


The documentation for this struct was generated from the following file: