Navigation
API > API/Plugins > API/Plugins/InstancedActors
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- AActor
- APartitionActor
- AInstancedActorsManager
References
| Module | InstancedActors |
| Header | /Engine/Plugins/Runtime/InstancedActors/Source/InstancedActors/Public/InstancedActorsManager.h |
| Include | #include "InstancedActorsManager.h" |
Syntax
UCLASS (Config=Mass)
class AInstancedActorsManager :
public APartitionActor ,
public ISMInstanceManager ,
public IActorInstanceManagerInterface
Remarks
Regional manager of 'instanced actors'.
Uses Mass to provide lightweight and efficient instancing of items in the distance, with server-authoritative actor spawning around players. AInstancedActorsManager's also provide replication and persistence for their managed instances.
Spawned and populated offline by UInstancedActorsSubsystem::InstanceActor. Offline population ensures client & server both load the same stable instance data and can commonly refer to instances by index as such.
Variables
| Type | Name | Description | |
|---|---|---|---|
| bool | bHasSpawnedEntities | True if SpawnEntities has been called to spawn entities. Reset in EndPlay | |
| FBox | InstanceBounds | World space cumulative instance bounds, calculated in BeginPlay | |
| FMassEntityQuery | InstancedActorLocationQuery | ||
| TSubclassOf< UInstancedActorsData > | InstancedActorsDataClass | Class to be spawned to represent individual actor class instances. | |
| TObjectPtr< UInstancedActorsSubsystem > | InstancedActorSubsystem | ||
| TMap< TObjectPtr< UInstancedStaticMeshComponent >, int32 > | ISMComponentToInstanceDataMap | ||
| FInstancedActorsManagerHandle | ManagerHandle | ||
| TSharedPtr< FMassEntityManager > | MassEntityManager | ||
| TArray< TWeakObjectPtr< UInstancedActorsModifierVolumeComponent > > | ModifierVolumes | Modifier volumes added via AddModifierVolume | |
| uint16 | NextInstanceDataID | Incremented in GetOrCreateActorInstanceData to provide IAD's with a stable, unique identifier within this IAM. | |
| TArray< TBitArray<> > | PendingModifierVolumeModifiers | A set of bit flags per volume in ModifierVolumes, matching each modifiers Modifiers list, marking whether the Modifier has yet to run on this manager or not (true = needs running). | |
| TBitArray | PendingModifierVolumes | A bit flag per volume in ModifierVolumes for whether the volume has pending Modifiers to run on this manager i.e if PendingModifierVolumeModifiers[VolumeIndex] has any true flags. | |
| TArray< TObjectPtr< UInstancedActorsData > > | PerActorClassInstanceData | Per-actor-class instance data populated by AddActorInstance | |
| FGuid | SavedActorGuid | Saved Actor Guid. Initialized from the actor name in constructor |
Constructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| FInstancedActorsInstanceHandle | AddActorInstance
(
TSubclassOf< AActor > ActorClass, |
Adds an instance of ActorClass at InstanceTransform location to instance data | |
| void | AddModifierVolume
(
UInstancedActorsModifierVolumeComponent& ModifierVolume |
||
| void | AuditInstances
(
FOutputDevice& Ar, |
Outputs instance metrics to Ar | |
| FBox | CalculateBounds
(
TSubclassOf< AActor > ActorClass |
Helper function to deduce appropriate instanced static mesh bounds for ActorClass | |
| FBox | Calculate cumulative local space instance bounds for all PerActorClassInstanceData | ||
| void | CompactInstances
(
FOutputDevice& Ar |
Called by IA.CompactInstances console command to fully remove FreeList instances | |
| void | CreateISMComponents
(
const FInstancedActorsVisualizationDesc& VisualizationDesc, |
||
| UInstancedActorsData * | CreateNextInstanceActorData
(
TSubclassOf< AActor > ActorClass, |
||
| void | Despawns all entities spawned by individual UInstancedActorsData instances. | ||
| UInstancedActorsData * | FindInstanceDataByID
(
uint16 InstanceDataID |
Searches PerActorClassInstanceData, returning the IAD with matching UInstancedActorsData::ID, if any(nullptr otherwise) | |
| bool | ForEachInstance
(
FInstanceOperationFunc Operation, |
||
| bool | ForEachInstance
(
const TBoundsType& QueryBounds, |
||
| bool | ForEachInstance
(
const FSphere& QueryBounds, |
||
| bool | ForEachInstance
(
const FBox& QueryBounds, |
||
| bool | ForEachInstance
(
FInstanceOperationFunc Operation |
Call InOperation for each valid instance in this manager. | |
| bool | ForEachInstance
(
const TBoundsType& QueryBounds, |
Call InOperation for each valid instance in this manager whose location falls within QueryBounds. | |
| TConstArrayView< TObjectPtr< UInstancedActorsData > > | |||
| FBox | |||
| UInstancedActorsSubsystem * | |||
| UInstancedActorsSubsystem & | |||
| FInstancedActorsManagerHandle | Inlines | ||
| TSharedPtr< FMassEntityManager > | |||
| FMassEntityManager & | |||
| int32 | |||
| UInstancedActorsData & | GetOrCreateActorInstanceData
(
TSubclassOf< AActor > ActorClass, |
Helper function to create and initialize per-actor-class UInstancedActorsData's, optionally further partitioned by InstanceTags | |
| bool | |||
| bool | HasInstancesOfClass
(
const FBox& QueryBounds, |
Checks whether there are any instanced actors within this manager, representing ActorClass or its subclasses inside QueryBounds. | |
| bool | |||
| void | Initializes all PerActorClassInstanceData, applies pre-spawn modifiers, spawns entities then applies post-spawn modifiers. | ||
| UE::InstancedActors::EInsideBoundsTestResult | IsInstanceInsideBounds
(
const FSphere& QueryBounds, |
||
| UE::InstancedActors::EInsideBoundsTestResult | IsInstanceInsideBounds
(
const TBoundsType& QueryBounds, |
Determines whether the actor instance given by InstanceHandle overlaps QueryBounds. | |
| UE::InstancedActors::EInsideBoundsTestResult | IsInstanceInsideBounds
(
const FBox& QueryBounds, |
||
| bool | IsValidInstance
(
const FInstancedActorsInstanceHandle& InstanceHandle |
||
| void | OnAddedToSubsystem
(
UInstancedActorsSubsystem& InInstancedActorSubsystem, |
Adds modifiers already registered with InInstancedActorSubsystem and either calls InitializeModifyAndSpawnEntities to spawn entities immediately, or schedules deferred call by InInstancedActorSubsystem if IA.DeferSpawnEntities is enabled. | |
| void | Called when persistent data has been applied / restored | ||
| void | RegisterInstanceDatasComponents
(
const UInstancedActorsData& InstanceData, |
Registers Components as related to InstanceData for IActorInstanceManagerInterface-related purposes. | |
| bool | RemoveActorInstance
(
const FInstancedActorsInstanceHandle& InstanceToRemove |
Removes all instance data for InstanceHandle. | |
| void | |||
| void | RemoveModifierVolume
(
UInstancedActorsModifierVolumeComponent& ModifierVolume |
||
| void | RequestActorSave
(
AActor* Actor |
Mz | |
| void | Request the persistent data system to re-save this managers persistent data | ||
| void | Removes all instances as if they were never present i.e: these removals are not persisted as if made by a player. | ||
| void | SerializeInstancePersistenceData
(
FStructuredArchive::FRecord Record, |
Called by Serialize for SaveGame archives to save / load IAD persistence data | |
| void | SetGridGuid
(
const FGuid& InGuid |
||
| void | Attempts to run any 'pending' modifiers in ModifierVolumes where are appropriate to run given HasSpawnedEntities Called in BeginPlay prior to, and then again after SpawnEntities. | ||
| void | UnregisterInstanceDatasComponent
(
UInstancedStaticMeshComponent& Component |
Unregisters Component from IActorInstanceManagerInterface-related tracking. | |
| void | UpdateInstanceStats
(
int32 InstanceCount, |
Overridden from APartitionActor
| Type | Name | Description | |
|---|---|---|---|
| uint32 | GetDefaultGridSize
(
UWorld* InWorld |
||
| FGuid | GetGridGuid () |
Overridden from AActor
| Type | Name | Description | |
|---|---|---|---|
| void | BeginPlay () |
Overridable native event for when play begins for this actor. | |
| void | EndPlay
(
const EEndPlayReason::Type EndPlayReason |
Overridable function called whenever this actor is being removed from a level | |
| void | GetStreamingBounds
(
FBox& OutRuntimeBounds, |
Returns the bounding boxes of all components that make up this Actor for loading at runtime and editor. | |
| bool | Indicates whether this actor contributes to the HLOD generation. | ||
| bool | Used to know if actor supports some editor operations. (Delete, Replace) | ||
| void | Used to set the right properties on the editor ISMCs so we can do per-instance selection. |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| void | PostLoad () |
Do any object-specific cleanup required immediately after loading an object. | |
| void | Serialize
(
FStructuredArchive::FRecord Record |
Overridden from IActorInstanceManagerInterface
| Type | Name | Description | |
|---|---|---|---|
| int32 | ConvertCollisionIndexToInstanceIndex
(
int32 InIndex, |
Returns the index used internally by the actor instance manager that is associated with the instance referred to by InIndex used by collision and rendering | |
| AActor * | FindActor
(
const FActorInstanceHandle& Handle |
Returns the actor associated with Handle if one exists. | |
| AActor * | FindOrCreateActor
(
const FActorInstanceHandle& Handle |
Returns the actor associated with Handle. If one does not exist the system is expected to spawn one instantly. | |
| ULevel * | GetLevelForInstance
(
const int32 InstanceIndex |
Returns the ULevel given instance is represented in. Potentially null if InstanceIndex doesn't correspond to an actor. | |
| UClass * | GetRepresentedClass
(
const int32 InstanceIndex |
Returns the specific class InstanceIndex represents. | |
| FTransform | GetTransform
(
const FActorInstanceHandle& Handle |
Returns the transform of the instance specified by Handle. |
Typedefs
| Name | Description |
|---|---|
| FInstancedActorDataPredicateFunc | Predicate taking a UInstancedActorsData and returns true if IAD matches search criteria, false otherwise. |
| FInstanceOperationFunc | Iteration callback for ForEachInstance |