Limen Framework 0.1 Help

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

FRandomStreamPtr

GlobalRandomStream

Private

Shared pointer to the global random stream.

FCriticalSection

RandomStreamSection

Private

Critical section for thread-safe access to the random stream.

Functions

Return Type

Signature

Description

void

Initialize(FSubsystemCollectionBase& Collection)

Initializes the subsystem with a seed based on the current time or a specified seed.

void

Deinitialize()

Deinitializes the subsystem.

void

SetSeed(const int32 Seed)

Sets the seed for the random stream to the provided value.

void

SetSeedWithCurrentTime()

Sets the seed for the random stream using the current time.

FRandomStreamRef

GetGlobalRandomStream()

Returns a reference to the global random stream.

float

RandomFloat()

Generates and returns a random float between 0 and 1.

float

GetFraction()

Returns a random fraction between 0 and 1.

int32

RandomIntRange(const int32 RangeStart, const int32 RangeEnd)

Generates and returns a random integer within the specified range.

float

RandomFloatRange(const float RangeStart, const float RangeEnd)

Generates and returns a random float within the specified range.

TArray<int32>

GenerateRandomUniqueNumbers(const int32 RangeStart, const int32 RangeEnd, const int32 Count)

Generates an array of unique random integers within the specified range.

TArray<int32>

GenerateRandomNumbers(const int32 RangeStart, const int32 RangeEnd, const int32 Count)

Generates an array of random integers within the specified range.

TArray<int32>

GenerateValidRandomUniqueNumbers(const int32 RangeStart, const int32 RangeEnd, const int32 Count, const TFunction<bool(const int32)>& IsNumberValid = [] (const int32) { return true; })

Generates an array of unique random integers within the specified range that satisfy a given condition.

TArray<int32>

GenerateValidRandomNumbers(const int32 RangeStart, const int32 RangeEnd, const int32 Count, const TFunction<bool(const int32)>& IsNumberValid = [] (const int32) { return true; })

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 GenerateValidRandomUniqueNumbers and GenerateValidRandomNumbers functions include a condition check that can be customized through a lambda function.

22 May 2026