Navigation
API > API/Plugins > API/Plugins/InstancedActors
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- UInstancedActorsData
References
| Module | InstancedActors |
| Header | /Engine/Plugins/Runtime/InstancedActors/Source/InstancedActors/Public/InstancedActorsData.h |
| Include | #include "InstancedActorsData.h" |
Syntax
UCLASS (DefaultToInstanced)
class UInstancedActorsData : public UObject
Remarks
Instance data for all instances of a given AActor class. Provides 'stable' referral to instances by index via offline population of InstanceTransforms which is then consistently loaded on both client and server.
Variables
| Type | Name | Description | |
|---|---|---|---|
| TSubclassOf< AActor > | ActorClass | The fully realized actor type for these instances. | |
| friend | AInstancedActorsManager | ||
| FBox | AssetBounds | Editor time cached bounds for AssetClass, used during editor-only instance creation and deletion to expand / contract Bounds | |
| bool: 1 = false | bHasEverInitialized | True if Initialize has ever been called. | |
| FBox | Bounds | Cumulative mesh bounds for all of InstanceTransfroms. | |
| bool: 1 = false | bRemovingInstances | True during RuntimeRemoveInstances to prevent recursion via OnInstancedActorDestroyed. | |
| TArray< TObjectPtr< UInstancedStaticMeshComponent > > | EditorPreviewISMComponents | ISMCs created in GetOrCreateActorInstanceData to match default visualizations ISMComponents for editor only preview of instances. | |
| TArray< FMassEntityHandle > | Entities | Runtime spawned mass instances | |
| FMassEntityTemplateID | EntityTemplateID | The entity template to spawn Mass entities from | |
| uint16 | ID | Identifying integer, unique within outer IAM, used for identifying matching persistence records Incrementally assigned in GetOrCreateActorInstanceData | |
| TArray< FTransform > | InstanceTransforms | Void UInstancedActorsData::AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector) | |
| TBitArray | InstanceVisualizationAllocationFlags | Allocation bit flags for InstanceVisualizations to allow for TSpareArray-like removal of visualization without affecting remaining visualization indices. | |
| TArray< FInstancedActorsVisualizationInfo > | InstanceVisualizations | Sets of ISMCs which instances can swap between to change 'visualization' e.g: 'with berries', 'without berries' | |
| float | LowLODDrawDistance | Distance from where the lowest LOD will be rendered - auto computed from bounding box and screen size data stored in the StaticMesh or can be set via the settings. | |
| float | MaxDrawDistance | Distance from where the object will be culled out - auto computed from bounding box radius or can be set per via the settings. | |
| uint16 | NumInstances | InstanceTransforms.Num() cached in PostLoad so we can restore InstanceTransforms to this size in ResetInstanceData | |
| uint16 | NumValidInstances | InstanceTransforms.Num() - number of invalid transforms Note: This is only valid prior to Entity spawning when InstanceTransforms is also valid, after which, spawned entities may be later removed / culled at runtime, invalidating this number. | |
| FConstSharedStruct | SharedSettings | Compiled settings for these instances, compiled and cached in BeginPlay. | |
| FInstancedActorsTagSet | Tags | Delimiting tag set to group sets of instances. |
Functions
| Type | Name | Description | |
|---|---|---|---|
| FInstancedActorsInstanceHandle | AddInstance
(
const FTransform& Transform, |
Add's an instance of this actor type at Transform | |
| uint8 | AddVisualization
(
const FInstancedActorsVisualizationDesc& VisualizationDesc |
Register additional / alternate VisualizationDesc for instances to switch to, creating ISMC's for each VisualizationDesc.InstancedMeshes | |
| uint8 | AddVisualizationAsync
(
const FInstancedActorsSoftVisualizationDesc& SoftVisualizationDesc |
Register additional / alternate VisualizationDesc for instances to switch to, creating ISMC's for each VisualizationDesc.InstancedMeshes | |
| uint8 | Adds or reuses a previously removed entry in InstanceVisualizations | ||
| void | ApplyInstanceDelta
(
FMassEntityManager& EntityManager, |
Helper function used in ApplyInstanceDeltas to apply a single delta | |
| void | Called on both server and client to apply instance delta changes to mass entities On servers: Called by OnPersistentDataRestored after persistence record has deserialized the delta data On clients: Called by OnRep_InstanceDeltas when new delta data has replicated from the server | ||
| void | ApplyInstanceDeltas
(
TConstArrayView< int32 > InstanceDeltaIndices |
||
| void | ClearReplicatedActor
(
FInstancedActorsInstanceIndex Instance, |
Called in UInstancedActorsComponent::EndPlay on clients to clear / unset the current actor for Instance's mass entity. | |
| void | CreateEntityTemplate
(
const AActor& ExemplarActor |
Called on BeginPlay to create default entity template. | |
| void | Called early in AInstancedActorsManager::EndPlay to reconstruct cooked data state from runtime Mass entities as best we can, then despawn all Mass entities and reset any other runtime instance data | ||
| void | DestroyInstance
(
FInstancedActorsInstanceIndex InstanceToDestroy |
Authority: Permanently destroy InstanceToDestroy by adding it to the persistent DestroyedInstances list and deleting it's Mass entity (deleting any Mass-spawned actors in turn). | |
| void | EjectInstanceActor
(
FInstancedActorsInstanceIndex InstanceToEject, |
Authority: `Eject_ an instance by unlinking it's Actor from Mass, setting the actor to persist itself and then destroying the manager instance. | |
| void | ForEachVisualization
(
TFunctionRef< bool(uint8, const FInstancedActorsVisualizationInfo&)> InFunction, |
Iterates all currently 'allocated' visualizations previously added with AddVisualization or AddVisualizationAsync | |
| EInstancedActorsBulkLOD | GetBulkLOD () |
||
| FString | GetDebugName
(
bool bCompact |
Returns a string useful for identifying this instance data object withing it's owning manager | |
| const FInstancedActorsVisualizationInfo & | Returns the default visualization auto-created in BeginPlay from ActorClass and used by default for all spawned entities in BeginPlay. | ||
| FMassEntityHandle | GetEntity
(
FInstancedActorsInstanceIndex InstanceIndex |
||
| FMassEntityHandle | GetEntityHandleForIndex
(
const FInstancedActorsInstanceIndex Index |
||
| int32 | GetEntityIndexFromCollisionIndex
(
const UInstancedStaticMeshComponent& ISMComponent, |
||
| UInstancedActorsData * | GetInstanceDataForEntity
(
const FMassEntityManager& EntityManager, |
Returns the 'owning' UInstancedActorsData for EntityHandle by checking it's FInstancedActorsFragment (if any) returning nullptr for unknown entities. | |
| int32 | |||
| const FInstancedActorsDeltaList & | |||
| FInstancedActorsInstanceIndex | GetInstanceIndexForEntity
(
const FMassEntityHandle EntityHandle |
||
| AInstancedActorsManager * | GetManager () |
||
| AInstancedActorsManager & | |||
| FMassEntityManager & | |||
| FInstancedActorsDeltaList & | |||
| int32 | Returns the current invalid instance count, if any (i.e: GetNumInstances() - NumValidInstances) | ||
| int32 | Returns the total instance count, including both valid & invalid instances e.g: GetNumFreeInstances() + NumValidInstances Useful for iterating by FInstancedActorsInstanceIndex or allocating same-sized instance data arrays | ||
| const std::remove_const_t< T > & | GetSettings () |
||
| const std::remove_const_t< T > * | |||
| const FInstancedActorsVisualizationInfo * | GetVisualization
(
uint8 VisualizationIndex |
Get runtime visualization info by index for visualizations added with AddVisualization. | |
| const FInstancedActorsVisualizationInfo & | GetVisualizationChecked
(
uint8 VisualizationIndex |
Get runtime visualization info by index for visualizations added with AddVisualization. | |
| bool | Returns true if InstanceTransforms has been consumed to spawn Mass entities. | ||
| void | Initialize () |
Called early in AInstancedActorsManager::InitializeModifyAndSpawnEntities to intitalize Settings, default visualization & Mass entity template. | |
| void | InitializeVisualization
(
uint8 AllocatedVisualizationIndex, |
Creates ISMCs for VisualizationDesc.InstancedMeshes, registers them with Mass and sets FInstancedActorsVisualizationInfo::MassStaticMeshDescIndex with the newly registed ISMC decription index | |
| bool | IsValidInstance
(
const FInstancedActorsInstanceHandle& InstanceHandle |
Returns true if InstanceHandle refers to this instance data and we have current information for an instance at InstanceHandle.InstanceIndex | |
| void | ModifyEntityTemplate
(
FMassEntityTemplateData& ModifiedTemplate, |
||
| void | OnInstancedActorDestroyed
(
AActor& DestroyedActor, |
Called by UInstancedActorsRepresentationActorManagement when a managed actor is destroyed. | |
| bool | OnInstancedActorMoved
(
AActor& MovedActor, |
Called by UInstancedActorsRepresentationActorManagement when a managed actor is moved | |
| void | Called when persistent data has been applied / restored. | ||
| void | OnRep_InstanceDeltas
(
TConstArrayView< int32 > UpdatedInstanceDeltaIndices |
Called by FInstancedActorsDeltaList::PostReplicatedAdd and PostReplicatedChanged on InstanceDelta replication. | |
| void | OnRep_PreRemoveInstanceDeltas
(
TConstArrayView< int32 > RemovedInstanceDeltaIndices |
Called by FInstancedActorsDeltaList::PreReplicatedRemove on InstanceDelta removal replication (just before the actual array element removal) | |
| void | Remove all previously registered instance visualization, deleting all ISMC's. | ||
| bool | RemoveInstance
(
const FInstancedActorsInstanceHandle& InstanceToRemove |
Removes all instance data for InstanceHandle. | |
| void | RemoveInstanceLifecyclePhaseDelta
(
FInstancedActorsInstanceIndex InstanceIndex |
Mz | |
| void | RemoveInstanceLifecyclePhaseTimeElapsedDelta
(
FInstancedActorsInstanceIndex InstanceIndex |
Mz | |
| void | RemoveVisualization
(
uint8 VisualizationIndex |
Remove previously registered instance visualization, deleting all ISMC's. | |
| void | RollbackInstanceDelta
(
FMassEntityManager& EntityManager, |
Helper function used in RollbackInstanceDeltas to rollback a single delta | |
| void | RollbackInstanceDeltas
(
TConstArrayView< int32 > InstanceDeltaIndices |
Called on clients by OnRep_PreRemoveInstanceDeltas to revert instance delta change to mass entities | |
| void | Removes all instances as if they were never present i.e: these removals are not persisted as if made by a player. | ||
| void | RuntimeRemoveInstances
(
TConstArrayView< FInstancedActorsInstanceIndex > RuntimeRemoveInstances |
Removes RuntimeRemoveInstances as if they were never present i.e: these removals are not persisted as if made by a player. | |
| void | SetInstanceCurrentLifecyclePhase
(
FInstancedActorsInstanceIndex InstanceIndex, |
Mz | |
| bool | SetInstanceTransform
(
const FInstancedActorsInstanceHandle& InstanceHandle, |
Set/update the transform for an instance. | |
| void | SetReplicatedActor
(
FInstancedActorsInstanceIndex Instance, |
Called in UInstancedActorsComponent::OnRep_InstanceHandle on clients to set ReplicatedActor as the current actor for Instance's mass entity. | |
| void | SetSharedInstancedActorDataStruct
(
FSharedStruct InSharedStruct |
||
| void | SetSharedSettings
(
const FConstSharedStruct& InSharedSettings |
||
| void | Called in AInstancedActorsManager::InitializeModifyAndSpawnEntities to spawn Mass entities for each instance. | ||
| void | SwitchInstanceVisualization
(
FInstancedActorsInstanceIndex InstanceToSwitch, |
Switches InstanceToSwitch to use the 'visualization' at NewVisualizationIndex, previoulsy added via AddVisualzation. | |
| AActor * | UnlinkActor
(
FInstancedActorsInstanceIndex InstanceToUnlink |
Unlink InstanceToUnlink's Actor (if any) from Mass by clearing the entities reference to it and disconnecting from any subscribed actor signals, essentially 'forgetting' about the actor. | |
| void |
Overridden from UObject
| Type | Name | Description | |
|---|---|---|---|
| void | GetLifetimeReplicatedProps
(
TArray< FLifetimeProperty >& OutLifetimeProps |
Returns properties that are replicated for the lifetime of the actor channel | |
| bool | IsNameStableForNetworking means an object can be referred to its path name (relative to outer) over the network | ||
| void | PostDuplicate
(
EDuplicateMode::Type DuplicateMode |
||
| void | PostLoad () |
Do any object-specific cleanup required immediately after loading an object. |