ALimenBaseHUD
Overview
ALimenBaseHUD is a custom HUD class designed to manage various UI widgets within the game. It inherits from AHUD and provides functionality to show, hide, and update widgets based on player controller and pawn interactions. The class also includes methods for initializing and destroying widgets, as well as handling forced HUD states.
Properties
Type | Name | Access | Description |
|---|---|---|---|
| bAreWidgetsInitialized | Private | A bit flag indicating whether the widgets have been initialized. |
| bForceHideHud | Private | A bit flag indicating whether the HUD should be forced to hide. |
| WidgetList | Protected | A list of weak pointers to all managed widgets. |
Functions
Return Type | Signature | Description |
|---|---|---|
| ShowHUD() | Shows the active widget if it is valid. |
| HideHUD() | Hides the active widget if it is valid. |
| ForceHUDState(const bool bForce) | Sets the forced HUD state. |
| GetForcedHudState() const | Returns the current forced HUD state. |
| ShowActiveWidget() | Shows the currently active widget. |
| HideActiveWidget() | Hides the currently active widget. |
| GetActiveWidget() const | Returns a pointer to the currently active widget. |
| GetWidgetList() const | Returns an array of weak pointers to all managed widgets. |
| EndPlay(const EEndPlayReason::Type EndPlayReason) | Cleans up and destroys all widgets when the HUD is destroyed. |
| DestroyWidgets() | Placeholder for destroying all widgets. Currently does nothing. |
| InitializeWidgets() | Placeholder for initializing all widgets. Currently does nothing. |
| HudInitialized(APlayerController* PlayerController) | Called after the HUD has been initialized with a player controller. |
| UpdateWidgets(APlayerController* PlayerController, APawn* Pawn) | Updates the state of the HUD based on the player controller and pawn. |
| CanSwitchWidgetVisibility(UWidget* InWidget) const | Determines if a widget can be shown or hidden based on the forced HUD state. |
| ShowWidget_Internal(ULimenWidget* Widget) | Internal method to show a widget, ensuring it is valid and not already showing. |
| HideWidget_Internal(ULimenWidget* Widget) | Internal method to hide a widget, ensuring it is valid and currently showing. |
| AddWidgetToList(ULimenWidget* InWidget) | Adds a widget to the internal list of managed widgets. |
| RemoveWidgetFormList(ULimenWidget* InWidget) | Removes a widget from the internal list of managed widgets. |
Usage & Implementation Notes
Threading Constraints: This class is designed to be used within the Unreal Engine's game thread.
Replication Requirements: None.
Memory Lifetime Management: Widgets are managed using weak pointers, ensuring that they can be safely destroyed without causing memory leaks.
Initialization Dependencies: The
UpdateWidgetsmethod should be called with a valid player controller and pawn to properly initialize the HUD.