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 |
|---|---|---|---|
| GeneratedMap | Private | A strong pointer to the generated map. |
| GeneratedMapParameters | Private | A weak pointer to the parameters used for generating the map. |
| GeneratedMapId | Private | The unique identifier for the generated map. |
| OnAlgorithmFinished | Private | A delegate that is called when the algorithm finishes. |
| MapGenerationThread | Private | A thread used to run the map generation process. |
Functions
Return Type | Signature | Description |
|---|---|---|
|
| Overrides UObject's BeginDestroy method to clean up resources before destruction. |
|
| Creates a map asynchronously and calls the provided callback when finished. |
|
| Synchronously creates a map and returns it immediately. |
|
| Creates a map synchronously and casts the result to the specified type. |
| Pure virtual function that must be implemented by derived classes to specify the class of the generated map. | |
| Pure virtual function that must be implemented by derived classes to perform the actual map generation. | |
|
| Initializes the algorithm and checks for validity of parameters. Returns true if initialization is successful. |
|
| Runs the map generation on a separate thread. This method should not be called directly; it is invoked by the thread system. |
|
| Stops the current map generation process, if any. Currently does nothing. |
|
| 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
CreateMapmethods provide both asynchronous and synchronous ways to create maps.The
Initmethod checks for the validity of the generated map ID and parameters before proceeding with initialization.The
Runmethod is invoked by the thread system and should not be called directly.The
Exitmethod cleans up resources and calls the completion delegate when the algorithm finishes.