ULimenGlobalRandomStreamSubsystem
Overview
The ULimenGlobalRandomStreamSubsystem class is a subsystem in the LimenCore plugin that provides functionality to generate random numbers and fractions. It initializes with a seed based on the current time or a specified seed, and offers methods to retrieve random values within specified ranges. The class ensures thread safety through the use of a critical section.
Properties
Type | Name | Access | Description |
|---|---|---|---|
| GlobalRandomStream | Private | Shared pointer to the global random stream. |
| RandomStreamSection | Private | Critical section for thread-safe access to the random stream. |
Functions
Return Type | Signature | Description |
|---|---|---|
|
| Initializes the subsystem with a seed based on the current time or a specified seed. |
|
| Deinitializes the subsystem. |
|
| Sets the seed for the random stream to the provided value. |
|
| Sets the seed for the random stream using the current time. |
|
| Returns a reference to the global random stream. |
|
| Generates and returns a random float between 0 and 1. |
|
| Returns a random fraction between 0 and 1. |
|
| Generates and returns a random integer within the specified range. |
|
| Generates and returns a random float within the specified range. |
|
| Generates an array of unique random integers within the specified range. |
|
| Generates an array of random integers within the specified range. |
|
| Generates an array of unique random integers within the specified range that satisfy a given condition. |
|
| Generates an array of random integers within the specified range that satisfy a given condition. |
Usage & Implementation Notes
The subsystem ensures thread safety by using a critical section to protect access to the global random stream.
The seed is initialized based on the current time in non-editor builds, ensuring different seeds for each session.
The
GenerateValidRandomUniqueNumbersandGenerateValidRandomNumbersfunctions include a condition check that can be customized through a lambda function.