Navigation
API > API/Plugins > API/Plugins/ModularGameplay
GameFrameworkComponentManager
A manager to handle putting components on actors as they come and go. Put in a request to instantiate components of a given class on actors of a given class and they will automatically be made for them as the actors are spawned. Submit delegate handlers to listen for actors of a given class. Those handlers will automatically run when actors of a given class or registered as receivers or game events are sent. Actors must opt-in to this behavior by calling AddReceiver/RemoveReceiver for themselves when they are ready to receive the components and when they want to remove them. Any actors that are in memory when a request is made will automatically get the components, and any in memory when a request is removed will lose the components immediately. Requests are reference counted, so if multiple requests are made for the same actor class and component class, only one component will be added and that component wont be removed until all requests are removed.
| Name | UGameFrameworkComponentManager |
| Type | class |
| Header File | /Engine/Plugins/Runtime/ModularGameplay/Source/ModularGameplay/Public/Components/GameFrameworkComponentManager.h |
| Include Path | #include "Components/GameFrameworkComponentManager.h" |
Syntax
UCLASS (MinimalAPI)
class UGameFrameworkComponentManager : public UGameInstanceSubsystem
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → USubsystem → UGameInstanceSubsystem → UGameFrameworkComponentManager
Structs
| Name | Remarks |
|---|---|
| FActorFeatureData | Information for each registered actor |
| FActorFeatureRegisteredDelegate | Holds the list of feature delegates |
| FActorFeatureState | State for a specific object implementing an actor feature, should this be in a map instead of an array? |
| FComponentRequest | A pair of classes that describe a request. |
| FComponentRequestInfo | A pair holding a receiver class and AdditionFlags |
| FComponentRequestReceiverClassPath | A list of FNames to represent an object path. Used for fast hashing and comparison of paths |
| FExtensionHandlerRegisteredDelegate | Stores a delegate as shared ref to avoid deallocation during execution |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FActorFeatureDelegateList | TArray< TSharedRef< FActorFeatureRegisteredDelegate > > | Always stored as shared refs to avoid being destroyed during execution | Components/GameFrameworkComponentManager.h |
| FExtensionHandlerDelegate | TBaseDelegate_TwoParams< void, AActor *, FName > | Delegate types for extension handlers | Components/GameFrameworkComponentManager.h |
| FExtensionHandlerEvent | TMap< FDelegateHandle, TSharedRef< FExtensionHandlerRegisteredDelegate > > | Using a fake multicast delegate so order can be kept consistent | Components/GameFrameworkComponentManager.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| NAME_ExtensionAdded | FName | A new extension handler was added | Components/GameFrameworkComponentManager.h |
| NAME_ExtensionRemoved | FName | An extension handler was removed by a freed request handle | Components/GameFrameworkComponentManager.h |
| NAME_GameActorReady | FName | Game-specific event indicating an actor is mostly initialized and ready for extension. | Components/GameFrameworkComponentManager.h |
| NAME_ReceiverAdded | FName | The extension system allows registering for arbitrary event callbacks on receiver actors. | Components/GameFrameworkComponentManager.h |
| NAME_ReceiverRemoved | FName | RemoveReceiver was called for a registered class and components were removed, normally called from EndPlay | Components/GameFrameworkComponentManager.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ActorFeatureMap | TMap< FObjectKey, FActorFeatureData > | Actors that were registered as tracking feature state | Components/GameFrameworkComponentManager.h | |
| AllReceivers | TSet< FObjectKey > | Editor-only set to validate that component requests are only being added for actors that call AddReceiver and RemoveReceiver | Components/GameFrameworkComponentManager.h | |
| ClassFeatureChangeDelegates | TMap< FComponentRequestReceiverClassPath, FActorFeatureDelegateList > | Global delegates for any class name | Components/GameFrameworkComponentManager.h | |
| ComponentClassToComponentInstanceMap | TMap< UClass *, TSet< FObjectKey > > | A map of component classes to instances of that component class made by this component manager | Components/GameFrameworkComponentManager.h | |
| CurrentStateChange | int32 | Position in state change queue, INDEX_NONE means not actively handling | Components/GameFrameworkComponentManager.h | |
| InitStateOrder | TArray< FGameplayTag > | List of all registered feature states in order | Components/GameFrameworkComponentManager.h | |
| ReceiverClassToComponentClassMap | TMap< FComponentRequestReceiverClassPath, TSet< FComponentRequestInfo > > | A map of actor classes to component classes & addition flags that should be made for that class. | Components/GameFrameworkComponentManager.h | |
| ReceiverClassToEventMap | TMap< FComponentRequestReceiverClassPath, FExtensionHandlerEvent > | A map of actor classes to delegate handlers that should be executed for actors of that class. | Components/GameFrameworkComponentManager.h | |
| RequestTrackingMap | TMap< FComponentRequest, int32 > | All active component requests. | Components/GameFrameworkComponentManager.h | |
| StateChangeQueue | TArray< TPair< AActor *, FActorFeatureState > > | A queue of state changes to call delegates for, we don't want recursive callbacks | Components/GameFrameworkComponentManager.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TSharedPtr< FComponentRequestHandle > AddComponentRequest
(
const TSoftClassPtr< AActor >& ReceiverClass, |
Adds a request to instantiate components on actors of the given classes. | Components/GameFrameworkComponentManager.h | |
TSharedPtr< FComponentRequestHandle > AddExtensionHandler
(
const TSoftClassPtr< AActor >& ReceiverClass, |
Adds an extension handler to run on actors of the given class. | Components/GameFrameworkComponentManager.h | |
void AddReceiver
(
AActor* Receiver, |
Adds an actor as a receiver for components. | Components/GameFrameworkComponentManager.h |
|
bool ChangeFeatureInitState
(
AActor* Actor, |
Changes the current actor feature state, this will call registered callbacks and return true if anything changed | Components/GameFrameworkComponentManager.h | |
void GetAllFeatureImplementers
(
TArray< UObject* >& OutImplementers, |
Gets all implementing objects for an actor that are at RequiredState or later, other than excluding feature if specified | Components/GameFrameworkComponentManager.h | |
UObject * GetImplementerForFeature
(
AActor* Actor, |
Returns the object implementing specified feature, filtered by required state if not none | Components/GameFrameworkComponentManager.h | |
FGameplayTag GetInitStateForFeature
(
AActor* Actor, |
Returns the earliest state found for the given feature | Components/GameFrameworkComponentManager.h | |
bool HasFeatureReachedInitState
(
AActor* Actor, |
Returns true if feature has reached query state or later | Components/GameFrameworkComponentManager.h | |
bool HaveAllFeaturesReachedInitState
(
AActor* Actor, |
Checks to see if all features of object, other than the excluding feature if specified, have reached a specified state or later | Components/GameFrameworkComponentManager.h | |
bool IsInitStateAfterOrEqual
(
FGameplayTag FeatureState, |
Returns true if FeatureState comes after the second state (or is equal) | Components/GameFrameworkComponentManager.h | |
FDelegateHandle RegisterAndCallForActorInitState
(
AActor* Actor, |
Registers native delegate for feature state change notifications on a specific actor and may call it immediately | Components/GameFrameworkComponentManager.h | |
bool RegisterAndCallForActorInitState
(
AActor* Actor, |
Registers blueprint delegate for feature state change notifications on a specific actor and may call it immediately | Components/GameFrameworkComponentManager.h |
|
bool RegisterAndCallForClassInitState
(
TSoftClassPtr< AActor > ActorClass, |
Registers blueprint delegate for feature state change notifications on a class of actors and may call it immediately | Components/GameFrameworkComponentManager.h |
|
FDelegateHandle RegisterAndCallForClassInitState
(
const TSoftClassPtr< AActor >& ActorClass, |
Registers native delegate for feature state change notifications on a class of actors and may call it immediately | Components/GameFrameworkComponentManager.h | |
| Registers an implementer for a given feature, this will create a feature if required and set the implementer object but will not change the current state | Components/GameFrameworkComponentManager.h | ||
void RegisterInitState
(
FGameplayTag NewState, |
The init state system can be used by components to coordinate their initialization using game-specific states specified as gameplay tags IGameFrameworkInitStateInterface provides a simple implementation that can be inherted by components Adds a new global actor feature state, either before or after an existing one. | Components/GameFrameworkComponentManager.h | |
void RemoveActorFeatureData
(
AActor* Actor |
Removes an actor and all of it's state information | Components/GameFrameworkComponentManager.h | |
| Removes an implementing object and any feature states it implements | Components/GameFrameworkComponentManager.h | ||
void RemoveReceiver
(
AActor* Receiver |
Removes an actor as a receiver for components. | Components/GameFrameworkComponentManager.h |
|
| Sends an arbitrary extension event that can be listened for by other systems | Components/GameFrameworkComponentManager.h |
|
|
bool UnregisterActorInitStateDelegate
(
AActor* Actor, |
Removes a registered delegate bound to a specific actor | Components/GameFrameworkComponentManager.h | |
bool UnregisterActorInitStateDelegate
(
AActor* Actor, |
Removes a registered delegate bound to a specific actor | Components/GameFrameworkComponentManager.h |
|
bool UnregisterClassInitStateDelegate
(
const TSoftClassPtr< AActor >& ActorClass, |
Removes a registered delegate bound to a class | Components/GameFrameworkComponentManager.h | |
bool UnregisterClassInitStateDelegate
(
TSoftClassPtr< AActor > ActorClass, |
Removes a registered delegate bound to a class | Components/GameFrameworkComponentManager.h |
|
Overridden from USubsystem
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void Deinitialize() |
Components/GameFrameworkComponentManager.h | ||
virtual void Initialize
(
FSubsystemCollectionBase& Collection |
Components/GameFrameworkComponentManager.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static void AddGameFrameworkComponentReceiver
(
AActor* Receiver, |
Adds an actor as a receiver for components (automatically finding the manager for the actor's game instance). | Components/GameFrameworkComponentManager.h | |
static void AddReferencedObjects
(
UObject* InThis, |
Components/GameFrameworkComponentManager.h | ||
static void DumpGameFrameworkComponentManagers() |
Components/GameFrameworkComponentManager.h | ||
static UGameFrameworkComponentManager * GetForActor
(
const AActor* Actor, |
Utility to get this manager from an actor, will return null if actor is null or not in a world | Components/GameFrameworkComponentManager.h | |
static void RemoveGameFrameworkComponentReceiver
(
AActor* Receiver |
Removes an actor as a receiver for components (automatically finding the manager for the actor's game instance). | Components/GameFrameworkComponentManager.h | |
| Sends an arbitrary extension event that can be listened for by other systems | Components/GameFrameworkComponentManager.h |