β¨ Gorgeous Player State (Blueprint & C++)
Short Description
The AGorgeousPlayerState class extends the standard Unreal Engine APlayerState by adding an object variable system, allowing you to store and manage player state-specific data during gameplay.
Long Description
AGorgeousPlayerState enhances the standard Unreal Engine APlayerState by integrating with the Gorgeous Things object variable system. It provides a structured way to store and access player state-specific data through the AdditionalGorgeousData property, which is a map of named object variables. This allows you to maintain player state settings, player data, and other important information that needs to be accessible throughout your game.
π Features
AdditionalGorgeousData
A map of object variables that extends the standard player state with persistent data storage capabilities. This property allows you to store various types of data specific to your player state that need to be accessible during gameplay.
| Property | Type | Description | 
|---|---|---|
AdditionalGorgeousData | 
TMap<FName, UGorgeousObjectVariable*> | 
A map of named object variables that store additional data for the player state. | 
Tip
You can use this property to store various types of data, such as: - Player state settings - Player statistics - Player achievements - Player inventory data - Any other data that needs to be accessible during gameplay
Important
Each entry in the map is associated with a unique name and is represented by an UGorgeousObjectVariable. When new entries are added in the editor, their UniqueIdentifier is automatically updated.
// Accessing data from the AdditionalGorgeousData map
AGorgeousPlayerState* PlayerState = Cast<AGorgeousPlayerState>(GetWorld()->GetFirstPlayerController()->PlayerState);
if (PlayerState)
{
    // Get a specific object variable by name
    UGorgeousObjectVariable* MyData = PlayerState->AdditionalGorgeousData.FindRef(FName("MyDataName"));
    if (MyData)
    {
        // Use the object variable
        // ...
    }
}
π§ Implementation Details
The AGorgeousPlayerState class uses several helper macros to simplify its implementation:
UE_DECLARE_QOF_CLASS_INIT_INVOKE_ADDITIONAL_DATA: Used in theBeginPlayfunction to initialize the additional data.UE_DECLARE_QOF_CLASS_POST_EDIT_CHANGE_PROPERTY: Used to handle property changes in the editor.
These macros are defined in the GorgeousQualityOfLIfeHelperMacros.h file and provide a standardized way to implement common functionality across different classes in the Gorgeous Things ecosystem.
π Integration with Object Variables
The AGorgeousPlayerState class integrates with the Gorgeous Things object variable system, allowing you to store and manage player state-specific data. This integration provides several benefits:
- Persistence: Data stored in object variables persists throughout the game session.
 - Type Safety: Object variables provide type safety and validation for stored data.
 - Serialization: Object variables can be easily serialized for saving and loading.
 - Network Replication: Object variables support network replication for multiplayer games.
 
To use this functionality, you need to:
- Create a custom player state class that inherits from 
AGorgeousPlayerState. - Add object variables to the 
AdditionalGorgeousDatamap in the editor or at runtime. - Access the object variables through the map using their names.