Actor Pool Subsystem
- Base:
- UTickableWorldSubsystem
- Type:
- UNDynamicReferencesSubsystem
- Header File:
- NexusDynamicReferences/Public/NDynamicReferencesSubsystem.h
A locator system that maintains a map (ReferenceMap) that organizes actors into predefined categories defined by the ENDynamicReference enumeration.
Getting Actor References​
Accessing referenced AActor can be done with minimal overhead.
- Blueprint
- C++
note
In the above blueprint example, the UNDynamicReferenceComponnet would need to have its Link Phase set to ACLS_InitializeComponent in order to ensure it is registered prior to a hypothetical BeginPlay() event.
Getting Dynamic References
for (TArray<AActor*>& ReferencedActors = UNDynamicReferenceSubsystem::Get(GetWorld())->GetReferences(ENDynamicReference::NDR_Item_L);
AActor*& Actor : ReferencedActors)
{
// Do something with Actor
}
UFunctions​
Add Reference​
/**
* Add a reference by ENDynamicReference to a specified AActor.
* @remark Be careful with the manual add method. If you add it, you must remove it!
* @param InType The desired dynamic reference type to add too.
* @param InActor The AActor to be referenced by the InType.
*/
void AddReference(ENDynamicReference InType, AActor* InActor);
tip
The UNDynamicReferenceComponent automatically manages the registration lifecycle.
Remove Reference​
/**
* Remove a reference by ENDynamicReference to a specified AActor.
* @param InType The desired dynamic reference type to remove from.
* @param InActor The AActor to be have its reference removed by the InType.
*/
void RemoveReference(ENDynamicReference InType, AActor* InActor);
Get References​
/**
* Gets the array of AActors dynamically associated with the provided type.
* @param InType The desired dynamic reference type to access.
* @return An array of AActors.
*/
TArray<AActor*>& GetReferences(const ENDynamicReference InType) { return ReferenceMap[InType]; }