Navigation
API > API/Plugins > API/Plugins/SmartObjectsModule
Inheritance Hierarchy
- UObjectBase
- UObjectBaseUtility
- UObject
- USubsystem
- UWorldSubsystem
- USmartObjectSubsystem
- USmartObjectTestSubsystem
References
| Module | SmartObjectsModule |
| Header | /Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Public/SmartObjectSubsystem.h |
| Include | #include "SmartObjectSubsystem.h" |
Syntax
UCLASS (Config=SmartObjects, defaultconfig, Transient)
class USmartObjectSubsystem : public UWorldSubsystem
Remarks
Subsystem that holds all registered smart object instances and offers the API for spatial queries and reservations.
Variables
| Type | Name | Description | |
|---|---|---|---|
| bool | bAutoInitializeEditorInstances | ||
| bool | bIsPartitionedWorld | Set in OnWorldComponentsUpdated and used to control special logic required to build collections in Editor mode | |
| bool | bRuntimeInitialized | ||
| uint32 | NextFreeUserID | ||
| FOnMainCollectionEvent | OnMainCollectionChanged | ||
| FOnMainCollectionEvent | OnMainCollectionDirtied | ||
| TArray< TObjectPtr< USmartObjectComponent > > | PendingSmartObjectRegistration | Smart objects that attempted to register while no collection was being present | |
| TArray< TWeakObjectPtr< ASmartObjectPersistentCollection > > | RegisteredCollections | ||
| TArray< TObjectPtr< USmartObjectComponent > > | RegisteredSOComponents | List of registered components. | |
| TObjectPtr< ASmartObjectSubsystemRenderingActor > | RenderingActor | ||
| TMap< FSmartObjectHandle, FSmartObjectRuntime > | RuntimeSmartObjects | A map of registered smart object handles to their associated runtime data. | |
| FSmartObjectContainer | SmartObjectContainer | ||
| TObjectPtr< USmartObjectSpacePartition > | SpacePartition | ||
| TSubclassOf< USmartObjectSpacePartition > | SpacePartitionClass | ||
| FSoftClassPath | SpacePartitionClassName | Name of the Space partition class to use. | |
| friend | UWorldPartitionSmartObjectCollectionBuilder |
Constructors
| Type | Name | Description | |
|---|---|---|---|
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AbortAll
(
const FSmartObjectHandle Handle, |
||
| bool | ActivateObjectPreconditions
(
const FWorldConditionContextData& ContextData, |
Activate preconditions on the main object. | |
| bool | ActivateSlotPreconditions
(
FWorldConditionContextData& ContextData, |
Activate preconditions on the specified slot. | |
| FSmartObjectRuntime * | AddCollectionEntryToSimulation
(
const FSmartObjectCollectionEntry& Entry, |
Registers a collection entry to the simulation and creates its associated runtime instance. | |
| FSmartObjectRuntime * | AddComponentToSimulation
(
USmartObjectComponent& SmartObjectComponent, |
Registers a collection entry to the simulation and creates its associated runtime instance. | |
| void | AddContainerToSimulation
(
const FSmartObjectContainer& InSmartObjectContainer |
||
| void | AddSlotData
(
const FSmartObjectClaimHandle& ClaimHandle, |
Adds state data to a slot instance. | |
| void | AddTagToInstance
(
const FSmartObjectHandle Handle, |
Adds a single tag to the smart object instance represented by the provided handle. | |
| void | AddTagToInstance
(
FSmartObjectRuntime& SmartObjectRuntime, |
||
| void | AddTagToSlot
(
const FSmartObjectSlotHandle SlotHandle, |
Adds a single tag to the smart object slot represented by the provided handle. | |
| void | BindComponentToSimulation
(
USmartObjectComponent& SmartObjectComponent |
Binds a smartobject component to an existing instance in the simulation. | |
| void | BindComponentToSimulationInternal
(
USmartObjectComponent& SmartObjectComponent, |
Binds a smartobject component to an existing instance in the simulation and notifies that it has been bound. | |
| void | BindPropertiesFromStruct
(
FWorldConditionContextData& ContextData, |
Binds properties of the context data to property values of the user data struct when they match type and name. | |
| bool | CanBeClaimed
(
const FSmartObjectSlotHandle SlotHandle, |
Checks whether given slot is free and can be claimed (i.e. slot and its parent are both enabled) | |
| void | Removes all runtime data | ||
| FBox | ComputeBounds
(
const UWorld& World |
Compute bounds from the given world | |
| void | CreatePersistentCollectionFromDeprecatedData
(
UWorld& World, |
Special-purpose function used to set up an instance of ASmartObjectPersistentCollection with data from a given instance of ADEPRECATED_SmartObjectCollection | |
| FSmartObjectRuntime * | CreateRuntimeInstance
(
const FSmartObjectHandle Handle, |
Initializes preconditions, adds to the space partition structure using the specified bounds and broadcasts event. | |
| FSmartObjectHandle | CreateSmartObject
(
const USmartObjectDefinition& Definition, |
Creates a new SmartObject runtime instance from an external system. | |
| void | Debugging helper to emulate the stop of the simulation to destroy all runtime data | ||
| uint32 | |||
| uint32 | |||
| const TMap< FSmartObjectHandle, FSmartObjectRuntime > & | |||
| void | Debugging helper to emulate the start of the simulation to create all runtime data | ||
| void | Debugging helpers to add all registered smart objects to the simulation | ||
| void | Debugging helper to remove all registered smart objects from the simulation | ||
| void | DestroyRuntimeInstanceInternal
(
const FSmartObjectHandle Handle, |
Destroy SmartObjectRuntime contents as Handle's representation. | |
| bool | DestroySmartObject
(
FSmartObjectHandle Handle |
Removes the SmartObject runtime data from the simulation, destroys it and unbinds and unregister associated component if any. | |
| bool | EvaluateConditionsForFiltering
(
const FSmartObjectRuntime& SmartObjectRuntime, |
Internal helper for filter methods to build the list of accepted slots by reusing context data and schema as much as possible. | |
| bool | EvaluateObjectConditions
(
const FWorldConditionContextData& ConditionContextData, |
Use the provided context data that is expected to be already filled by calling 'SetupConditionContextCommonData' and evaluates all conditions associated to the specified object. | |
| bool | EvaluateSelectionConditions
(
const FSmartObjectSlotHandle SlotHandle, |
Evaluates conditions of the specified slot and its parent smart object. | |
| bool | EvaluateSlotConditions
(
FWorldConditionContextData& ConditionContextData, |
Use the provided context data that is expected to be already filled by calling 'SetupConditionContextCommonData' and adds the slot related part. | |
| TArray< FSmartObjectRequestResult > | FilterResultsBySelectionConditions
(
const TConstArrayView< FSmartObjectRequestResult >& ResultsToFilter, |
Evaluates conditions of the slot specified by each request result and add to the result array on success. | |
| TArray< FSmartObjectSlotHandle > | FilterSlotsBySelectionConditions
(
const TConstArrayView< FSmartObjectSlotHandle >& SlotsToFilter, |
Evaluates conditions of each slot and add to the result array on success. | |
| bool | FindEntranceLocationForSlot
(
const FSmartObjectSlotHandle SlotHandle, |
Finds entrance location for a specific slot. | |
| bool | FindEntranceLocationInternal
(
const FSmartObjectSlotHandle SlotHandle, |
Finds entrance location for a specific slot. | |
| void | FindMatchingSlotDefinitionIndices
(
const USmartObjectDefinition& Definition, |
Applies filter on provided definition and fills OutValidIndices with indices of all valid slots. | |
| void | FindSlots
(
const FSmartObjectHandle Handle, |
Goes through all defined slots of smart object represented by SmartObjectRuntime and finds the ones matching the filter. | |
| void | FindSlots
(
const FSmartObjectHandle Handle, |
Returns slots of a given smart object matching the filter. | |
| FSmartObjectRequestResult | FindSmartObject
(
const FSmartObjectRequest& Request, |
Spatial lookup for first slot in range respecting request criteria and selection conditions. | |
| FSmartObjectRequestResult | FindSmartObject
(
const FSmartObjectRequest& Request, |
Spatial lookup for first slot in range respecting request criteria and selection conditions. | |
| bool | FindSmartObjects
(
const FSmartObjectRequest& Request, |
Spatial lookup for slot candidates respecting request criteria and selection conditions. | |
| bool | FindSmartObjects
(
const FSmartObjectRequest& Request, |
||
| bool | FindSmartObjects_BP
(
const FSmartObjectRequest& Request, |
Blueprint function for spatial lookup for slot candidates respecting request criteria and selection conditions. | |
| bool | FindSmartObjectsInList
(
const FSmartObjectRequestFilter& Filter, |
Search list of specific actors (often from a physics query) for slot candidates respecting request criteria and selection conditions. | |
| bool | FindSmartObjectsInTargetingRequest
(
const FSmartObjectRequestFilter& Filter, |
Search the results of the given targeting request handle for smart objects that match the request criteria | |
| void | GetAllSlots
(
const FSmartObjectHandle Handle, |
Return all slots of a given smart object. | |
| const USmartObjectBehaviorDefinition * | GetBehaviorDefinition
(
const FSmartObjectRuntime& SmartObjectRuntime, |
||
| const USmartObjectBehaviorDefinition * | GetBehaviorDefinition
(
const FSmartObjectClaimHandle& ClaimHandle, |
Return the behavior definition of a given type from a claimed object. | |
| const DefinitionType * | GetBehaviorDefinition
(
const FSmartObjectRequestResult& RequestResult |
Return the behavior definition of a given type from a claimed object. | |
| const DefinitionType * | GetBehaviorDefinition
(
const FSmartObjectClaimHandle& ClaimHandle |
Return the behavior definition of a given type from a claimed object. | |
| const USmartObjectBehaviorDefinition * | GetBehaviorDefinitionByRequestResult
(
const FSmartObjectRequestResult& RequestResult, |
Return the behavior definition of a given type from a request result. | |
| USmartObjectSubsystem * | GetCurrent
(
const UWorld* World |
||
| FOnSmartObjectEvent * | GetEventDelegate
(
const FSmartObjectHandle SmartObjectHandle |
Returns pointer to the smart object instance event delegate. | |
| const FGameplayTagContainer & | GetInstanceTags
(
const FSmartObjectHandle Handle |
Returns the list of tags associated to the smart object instance represented by the provided handle. | |
| TArrayView< TWeakObjectPtr< ASmartObjectPersistentCollection > > | |||
| FSmartObjectContainer & | |||
| TConstArrayView< TWeakObjectPtr< ASmartObjectPersistentCollection > > | |||
| int32 | GetRegisteredSmartObjectsCompatibleWithCollection
(
const ASmartObjectPersistentCollection& InCollection, |
||
| const FSmartObjectRuntime * | GetRuntimeInstance
(
const FSmartObjectHandle SmartObjectHandle |
Returns the const runtime instance associated to the provided handle | |
| FSmartObjectRuntime * | GetRuntimeInstance
(
const FSmartObjectHandle SmartObjectHandle |
Returns the runtime instance associated to the provided handle | |
| FOnSmartObjectEvent * | GetSlotEventDelegate
(
const FSmartObjectSlotHandle SlotHandle |
Returns pointer to the smart object changed delegate associated to the provided handle. | |
| TOptional< FVector > | GetSlotLocation
(
const FSmartObjectClaimHandle& ClaimHandle |
Returns the position (in world space) of the slot associated to the given claim handle. | |
| TOptional< FVector > | GetSlotLocation
(
const FSmartObjectRequestResult& Result |
Returns the position (in world space) of the slot associated to the given request result. | |
| TOptional< FVector > | GetSlotLocation
(
const FSmartObjectSlotHandle SlotHandle |
Returns the position (in world space) of the slot represented by the provided slot handle. | |
| bool | GetSlotLocation
(
const FSmartObjectClaimHandle& ClaimHandle, |
Returns the position (in world space) of the slot associated to the given claim handle. | |
| ESmartObjectSlotState | GetSlotState
(
const FSmartObjectSlotHandle SlotHandle |
Returns the state of the given Smart Object Slot handle. | |
| const FGameplayTagContainer & | GetSlotTags
(
const FSmartObjectSlotHandle SlotHandle |
Returns the list of tags associated to the smart object slot represented by the provided handle. | |
| TOptional< FTransform > | GetSlotTransform
(
const FSmartObjectClaimHandle& ClaimHandle |
Returns the transform (in world space) of the slot associated to the given claim handle. | |
| TOptional< FTransform > | GetSlotTransform
(
const FSmartObjectRequestResult& Result |
Returns the transform (in world space) of the slot associated to the given request result. | |
| TOptional< FTransform > | GetSlotTransform
(
const FSmartObjectSlotHandle SlotHandle |
Returns the transform (in world space) of the slot represented by the provided slot handle. | |
| bool | GetSlotTransform
(
const FSmartObjectClaimHandle& ClaimHandle, |
Returns the transform (in world space) of the slot associated to the given claim handle. | |
| FTransform | GetSlotTransformChecked
(
const FSmartObjectSlotHandle SlotHandle |
Similarly to GetSlotTransform fetches the transform (in world space) of the indicated slot, but assumes the slot handle is valid and that the EntityManager is known. | |
| bool | GetSlotTransformFromRequestResult
(
const FSmartObjectRequestResult& RequestResult, |
Returns the transform (in world space) of the slot associated to the given RequestResult. | |
| FSmartObjectSlotView | GetSlotView
(
const FSmartObjectSlotHandle SlotHandle |
Creates and returns a view to the data associated to a slot handle. | |
| USmartObjectComponent * | GetSmartObjectComponent
(
const FSmartObjectClaimHandle& ClaimHandle, |
Returns the component associated to the claim handle if still accessible. | |
| USmartObjectComponent * | GetSmartObjectComponentByRequestResult
(
const FSmartObjectRequestResult& Result, |
Returns the component associated to the given request result In some scenarios the component may no longer exist but its smart object data could (e.g. streaming) | |
| const FSmartObjectContainer & | |||
| FSmartObjectRuntime * | GetValidatedMutableRuntime
(
const FSmartObjectHandle Handle, |
||
| FSmartObjectRuntime * | GetValidatedMutableRuntime
(
const FSmartObjectHandle Handle, |
Returns the mutable runtime instance associated to the provided handle Method produces log messages with provided context if provided handle is not set or associated instance can't be found. | |
| bool | GetValidatedMutableRuntimeAndSlot
(
const FSmartObjectSlotHandle SlotHandle, |
||
| bool | GetValidatedMutableRuntimeAndSlot
(
const FSmartObjectSlotHandle SlotHandle, |
Returns the mutable runtime instance associated to the provided handle Method produces log messages with provided context if provided handle is not set or associated instance can't be found. | |
| const FSmartObjectRuntime * | GetValidatedRuntime
(
const FSmartObjectHandle Handle, |
||
| const FSmartObjectRuntime * | GetValidatedRuntime
(
const FSmartObjectHandle Handle, |
Returns the const runtime instance associated to the provided handle. | |
| bool | GetValidatedRuntimeAndSlot
(
const FSmartObjectSlotHandle SlotHandle, |
||
| bool | GetValidatedRuntimeAndSlot
(
const FSmartObjectSlotHandle SlotHandle, |
Returns the const runtime instance associated to the provided handle. | |
| void | Creates all runtime data using main collection | ||
| bool | IsClaimedSmartObjectValid
(
const FSmartObjectClaimHandle& ClaimHandle |
Indicates if the object/slot referred to by the given handle are still accessible in the simulation. | |
| bool | IsEnabled
(
const FSmartObjectHandle Handle |
Returns the enabled state of the smart object represented by the provided handle regardless of the disabled reason. | |
| bool | IsEnabledForReason
(
const FSmartObjectHandle Handle, |
Returns the enabled state of the smart object represented by the provided handle based on a specific reason. | |
| bool | Returns true if this subsystem is running on the server. | ||
| bool | IsSlotValidVerbose
(
const FSmartObjectSlotHandle SlotHandle, |
||
| bool | IsSlotValidVerbose
(
const FSmartObjectSlotHandle SlotHandle, |
Indicates if the handle is set and the slot referred to is still accessible in the simulation. | |
| bool | IsSmartObjectSlotValid
(
const FSmartObjectSlotHandle SlotHandle |
Indicates if the slot referred to by the given handle is still accessible in the simulation. | |
| bool | IsSmartObjectValid
(
const FSmartObjectHandle Handle |
Indicates if the object referred to by the given handle is still accessible in the simulation. | |
| void | Iteratively adds items to registered collections. Expected to be called in World Partitined worlds. | ||
| FSmartObjectClaimHandle | MarkSlotAsClaimed
(
const FSmartObjectSlotHandle SlotHandle, |
Marks a smart object slot as claimed. | |
| FSmartObjectClaimHandle | MarkSlotAsClaimed
(
const FSmartObjectSlotHandle SlotHandle, |
DEPRECATED BLOCK BEGIN | |
| bool | MarkSlotAsFree
(
const FSmartObjectClaimHandle& ClaimHandle |
Marks a claimed or occupied smart object as free. | |
| const USmartObjectBehaviorDefinition * | MarkSlotAsOccupied
(
FSmartObjectRuntime& SmartObjectRuntime, |
||
| const USmartObjectBehaviorDefinition * | MarkSlotAsOccupied
(
const FSmartObjectClaimHandle& ClaimHandle, |
Marks a previously claimed smart object slot as occupied. | |
| const DefinitionType * | MarkSlotAsOccupied
(
const FSmartObjectClaimHandle& ClaimHandle |
Marks a previously claimed smart object slot as occupied. | |
| void | OnSlotChanged
(
const FSmartObjectRuntime& SmartObjectRuntime, |
||
| void | PopulateCollection
(
ASmartObjectPersistentCollection& InCollection |
||
| bool | QueryAllValidatedEntranceLocations
(
const UWorld* World, |
Runs the entrance validation logic for all the slots in the Smart Object definition and returns all validated locations. | |
| void | QueryValidatedSlotEntranceLocationsInternal
(
const UWorld* World, |
Validates entrance locations for a specific slot. | |
| ESmartObjectCollectionRegistrationResult | RegisterCollection
(
ASmartObjectPersistentCollection& InCollection |
||
| void | Make sure that all SmartObjectCollection actors from our associated world are registered. | ||
| void | RegisterSlotInvalidationCallback
(
const FSmartObjectClaimHandle& ClaimHandle, |
Register a callback to be notified if the claimed slot is no longer available and user need to perform cleanup. | |
| bool | RegisterSmartObject
(
USmartObjectComponent& SmartObjectComponent |
Registers a SmartObject components to the runtime simulation. | |
| bool | RegisterSmartObjectActor
(
const AActor& SmartObjectActor |
Registers to the runtime simulation all SmartObject components for a given actor. | |
| bool | RegisterSmartObjectInternal
(
USmartObjectComponent& SmartObjectComponent |
||
| bool | Release
(
const FSmartObjectClaimHandle& ClaimHandle |
||
| bool | RemoveCollectionEntryFromSimulation
(
const FSmartObjectCollectionEntry& Entry |
Finds the runtime instance associated to the collection entry and removes it from the simulation. | |
| void | RemoveComponentFromSimulation
(
USmartObjectComponent& SmartObjectComponent |
Finds the runtime instance associated to the component and removes it from the simulation. | |
| bool | RemoveRuntimeInstanceFromSimulation
(
const FSmartObjectHandle Handle, |
||
| bool | RemoveRuntimeInstanceFromSimulation
(
FSmartObjectRuntime& SmartObjectRuntime, |
Removes a runtime instance from the simulation. | |
| bool | RemoveSmartObject
(
USmartObjectComponent& SmartObjectComponent |
Unregisters the component from the subsystem, unbinds it from the runtime simulation and removes its runtime data. | |
| bool | RemoveSmartObjectActor
(
const AActor& SmartObjectActor |
Removes all data associated to SmartObject components of a given actor from the simulation. | |
| void | RemoveTagFromInstance
(
FSmartObjectRuntime& SmartObjectRuntime, |
||
| void | RemoveTagFromInstance
(
const FSmartObjectHandle Handle, |
Removes a single tag from the smartobject instance represented by the provided handle. | |
| bool | RemoveTagFromSlot
(
const FSmartObjectSlotHandle SlotHandle, |
Removes a single tag from the smart object slot represented by the provided handle. | |
| bool | SendSlotEvent
(
const FSmartObjectSlotHandle SlotHandle, |
Sends event to a Smart Object slot. | |
| bool | SetEnabled
(
const FSmartObjectHandle Handle, |
Enables or disables the entire smart object represented by the provided handle using the default reason (i.e. Gameplay).. | |
| bool | SetEnabledForReason
(
const FSmartObjectHandle Handle, |
Enables or disables the entire smart object represented by the provided handle using the specified reason. | |
| bool | SetSlotEnabled
(
const FSmartObjectSlotHandle SlotHandle, |
Enables or disables the smart object slot represented by the provided handle. | |
| bool | SetSmartObjectActorEnabled
(
const AActor& SmartObjectActor, |
Enables or disables all smart objects associated to the provided actor (multiple components). | |
| void | SetupConditionContextCommonData
(
FWorldConditionContextData& ContextData, |
Fills the provided context data with the smartobject actor and handle associated to 'SmartObjectRuntime' and the subsystem. | |
| bool | TryActivatePreconditions
(
const FSmartObjectRuntime& SmartObjectRuntime |
Activate preconditions on the main object and all its slots. | |
| void | UnbindComponentFromSimulation
(
USmartObjectComponent& SmartObjectComponent |
Unbinds a smartobject component from an existing instance in the simulation. | |
| void | UnbindComponentFromSimulationInternal
(
USmartObjectComponent& SmartObjectComponent, |
Unbinds a smartobject component from the given FSmartObjectRuntime instance. | |
| void | UnregisterCollection
(
ASmartObjectPersistentCollection& InCollection |
||
| void | UnregisterSlotInvalidationCallback
(
const FSmartObjectClaimHandle& ClaimHandle |
Unregisters a callback to be notified if the claimed slot is no longer available and user need to perform cleanup. | |
| bool | UnregisterSmartObject
(
USmartObjectComponent& SmartObjectComponent |
Unregisters the component from the subsystem, unbinds it from the runtime simulation and handles the associated runtime data according to the component registration type (i.e. runtime data associated to components from persistent collections will remain in the simulation). | |
| bool | UnregisterSmartObjectActor
(
const AActor& SmartObjectActor |
Unregisters from the simulation all SmartObject components for a given actor. | |
| bool | UnregisterSmartObjectInternal
(
USmartObjectComponent& SmartObjectComponent, |
||
| bool | UpdateEntranceLocation
(
const FSmartObjectSlotEntranceHandle EntranceHandle, |
Runs the same logic as FindEntranceLocationForSlot() but for a specific entrance location. | |
| bool | UpdateSmartObjectTransform
(
const FSmartObjectHandle Handle, |
Updates the smart object transform. |
Overridden from UWorldSubsystem
| Type | Name | Description | |
|---|---|---|---|
| void | OnWorldBeginPlay
(
UWorld& World |
BeginPlay will push all objects stored in the collection to the runtime simulation and initialize octree using collection bounds. | |
| void | OnWorldComponentsUpdated
(
UWorld& World |
Callback overridden to gather loaded collections, spawn missing one and set the main collection. |
Overridden from USubsystem
| Type | Name | Description | |
|---|---|---|---|
| void | Deinitialize () |
USubsystem BEGIN. | |
| bool | ShouldCreateSubsystem
(
UObject* Outer |
Override to control if the Subsystem should be created at all. |