Limen Framework 0.1 Help

ULimenMapAlgorithm

Overview

ULimenMapAlgorithm is a UObject and FRunnable that handles the asynchronous generation of procedural maps. It uses a separate thread to perform the map generation, ensuring that the main game thread remains responsive. The class provides methods to create maps and handle the completion of the generation process through callbacks.

Properties

Type

Name

Access

Description

TStrongObjectPtr<[ULimenProceduralMap](LimenProceduralMap.md)>

GeneratedMap

Private

A strong pointer to the generated map.

TWeakObjectPtr<const [UProceduralMapParameters](ProceduralMapParameters.md)>

GeneratedMapParameters

Private

A weak pointer to the parameters used for generating the map.

FGuid

GeneratedMapId

Private

The unique identifier for the generated map.

FAlgorithmFinish*

OnAlgorithmFinished

Private

A delegate that is called when the algorithm finishes.

TUniquePtr<FRunnableThread>

MapGenerationThread

Private

A thread used to run the map generation process.

Functions

Return Type

Signature

Description

void

BeginDestroy()

Overrides UObject's BeginDestroy method to clean up resources before destruction.

void

CreateMap(const FGuid& MapId, const [UProceduralMapParameters](ProceduralMapParameters.md)* MapParameters, FAlgorithmFinish& FinishCallback)

Creates a map asynchronously and calls the provided callback when finished.

ULimenProceduralMap*

CreateMap(const FGuid& MapId, const [UProceduralMapParameters](ProceduralMapParameters.md)* MapParameters)

Synchronously creates a map and returns it immediately.

template<typename T>

T* CreateMap(const FGuid& MapId, const [UProceduralMapParameters](ProceduralMapParameters.md)* MapParameters)

Creates a map synchronously and casts the result to the specified type.

virtual TSubclassOf<[ULimenProceduralMap](LimenProceduralMap.md)> GetGeneratedMapClass() const

Pure virtual function that must be implemented by derived classes to specify the class of the generated map.

virtual void GenerateMap(const [UProceduralMapParameters](ProceduralMapParameters.md)* MapParameters, [ULimenProceduralMap](LimenProceduralMap.md)* OutGeneratedMap)

Pure virtual function that must be implemented by derived classes to perform the actual map generation.

bool

Init()

Initializes the algorithm and checks for validity of parameters. Returns true if initialization is successful.

uint32

Run()

Runs the map generation on a separate thread. This method should not be called directly; it is invoked by the thread system.

void

Stop()

Stops the current map generation process, if any. Currently does nothing.

void

Exit()

Cleans up resources and calls the completion delegate when the algorithm finishes.

Usage & Implementation Notes

  • The class uses a separate thread (MapGenerationThread) to perform map generation, ensuring that the main game thread remains responsive.

  • The CreateMap methods provide both asynchronous and synchronous ways to create maps.

  • The Init method checks for the validity of the generated map ID and parameters before proceeding with initialization.

  • The Run method is invoked by the thread system and should not be called directly.

  • The Exit method cleans up resources and calls the completion delegate when the algorithm finishes.

22 May 2026