USmartObjectSubsystem

Subsystem that holds all registered smart object instances and offers the API for spatial queries and reservations.

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

SmartObjectsModule

Header

/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Public/SmartObjectSubsystem.h

Include

#include "SmartObjectSubsystem.h"

Syntax

UCLASS(Config=Game)
class USmartObjectSubsystem : public UWorldSubsystem

Remarks

Subsystem that holds all registered smart object instances and offers the API for spatial queries and reservations.

Variables

Name Description

Protected variable

bool

 

bInitialCollectionAddedToSimulation

Flag to indicate that all entries from the baked collection are registered and new registrations will be considered runtime entries (i.e. no persistence)

Protected variable UProperty

ASmartObjectCol...

 

MainCollection

Protected variable

UE::SmartObject...

 

NextFreeUserID

Public variable

FOnMainCollecti...

 

OnMainCollectionChanged

Protected variable UProperty Transient

TArray< USmartO...

 

RegisteredSOComponents

List of registered used to rebuild collection on demand

Protected variable

TArray< FSmartO...

 

RuntimeCreatedEntries

Keep track of Ids associated to objects entirely created at runtime (i.e. not part of the initial collection)

Protected variable

TMap< FSmartObj...

 

RuntimeSmartObjects

Protected variable

FSmartObjectOct...

 

SmartObjectOctree

Constructors

Name Description

Public function

USmartObjectSubsystem()

Functions

Name Description

Protected function

void

 

AbortAll

(
    FSmartObjectRuntime& SmartObjectRu...
)

Protected function

void

 

AddToSimulation

(
    const FSmartObjectID ID,
    const USmartObjectDefinition& Defi...,
    const FTransform& Transform,
    const FBox& Bounds
)

Protected function

void

 

AddToSimulation

(
    const FSmartObjectCollectionEntry&...,
    const USmartObjectDefinition& Defi...
)

Protected function

void

 

AddToSimulation

(
    const USmartObjectComponent&
)

Public function

FSmartObject...

 

Claim

(
    FSmartObjectID ID,
    const FSmartObjectRequestFilter& F...
)

Public function UFunction BlueprintCallable, Category

FSmartObject...

 

Claim

(
    const FSmartObjectRequestResult& R...
)

Claim smart object from a valid request result.

Protected function Const

void

 

ComputeBounds

(
    const UWorld& World,
    ASmartObjectCollection& Collection
)

Compute bounds from given world and store result in provided collection

Public function Const

uint32

 

DebugGetNumRegisteredComponents()

Public function Const

uint32

 

DebugGetNumRuntimeObjects()

Public function Const

const TMap< ...

 

DebugGetRuntimeObjects()

Public function

void

 

DebugRegisterAllSmartObjects()

Debugging helpers to add all registered smart objects to the simulation

Public function

void

 

DebugUnregisterAllSmartObjects()

Debugging helper to remove all registered smart objects from the simulation

Public function Const

FSmartObject...

 

FindSlot

(
    const FSmartObjectID ID,
    const FSmartObjectRequestFilter& F...
)

Goes through all defined slots of a given smart object and finds the first one matching the filter.

Protected function Const

FSmartObject...

 

FindSlot

(
    const FSmartObjectRuntime& SmartOb...,
    const FSmartObjectRequestFilter& F...
)

Goes through all defined slots of smart object represented by SmartObjectRuntime and finds the first one given actor can use.

Public function UFunction BlueprintCallable, Category

FSmartObject...

 

FindSmartObject

(
    const FSmartObjectRequest& Request
)

Spatial lookup

Public function UFunction BlueprintCallable, Category

bool

 

FindSmartObjects

(
    const FSmartObjectRequest& Request,
    TArray< FSmartObjectRequestResult >...
)

Spatial lookup

Public function Static

USmartObject...

 

GetCurrent

(
    const UWorld* World
)

Public function Const

ASmartObject...

 

GetMainCollection()

Protected function

FSmartObject...

 

GetMutableRuntimeSlot

(
    const FSmartObjectClaimHandle& Cla...
)

Public function Const

const FSmart...

 

GetOctree()

Public function Const

TOptional< F...

 

GetSlotLocation

(
    const FSmartObjectRequestResult& R...
)

Returns the position (in world space) of the slot associated to the given request result.

Public function Const UFunction BlueprintCallable, Category

bool

 

GetSlotLocation

(
    const FSmartObjectClaimHandle& Cla...,
    FVector& OutSlotLocation
)

Returns the position (in world space) of the slot associated to the given claim handle.

Public function Const

TOptional< F...

 

GetSlotLocation

(
    const FSmartObjectID SmartObjectID,
    const FSmartObjectSlotIndex SlotInd...
)

Returns the position (in world space) of the slot represented by the provided object id and slot index.

Public function Const

TOptional< F...

 

GetSlotLocation

(
    const FSmartObjectClaimHandle& Cla...
)

Returns the position (in world space) of the slot associated to the given claim handle.

Public function Const UFunction BlueprintCallable, Category

bool

 

GetSlotTransform

(
    const FSmartObjectClaimHandle& Cla...,
    FTransform& OutSlotTransform
)

Returns the transform (in world space) of the slot associated to the given claim handle.

Public function Const

TOptional< F...

 

GetSlotTransform

(
    const FSmartObjectID SmartObjectID,
    const FSmartObjectSlotIndex SlotInd...
)

Returns the transform (in world space) of the slot represented by the provided object id and slot index.

Public function Const

TOptional< F...

 

GetSlotTransform

(
    const FSmartObjectRequestResult& R...
)

Returns the transform (in world space) of the slot associated to the given request result.

Public function Const

TOptional< F...

 

GetSlotTransform

(
    const FSmartObjectClaimHandle& Cla...
)

Returns the transform (in world space) of the slot associated to the given claim handle.

Public function Const UFunction BlueprintCallable, Category

USmartObject...

 

GetSmartObjectComponent

(
    const FSmartObjectClaimHandle& Cla...
)

Returns the component associated to the claim handle if still accessible.

Protected function

void

 

RebuildCollection

(
    ASmartObjectCollection& InCollecti...
)

Public function

ESmartObject...

 

RegisterCollection

(
    ASmartObjectCollection& InCollecti...
)

Protected function

void

 

RegisterCollectionInstances()

Make sure that all SmartObjectCollection actors from our associated world are registered.

Public function

void

 

RegisterSlotInvalidationCallback

(
    const FSmartObjectClaimHandle& Cla...,
    const FOnSlotInvalidated& Callback
)

Register a callback to be notified if the claimed slot is no longer available and user need to perform cleanup.

Public function

bool

 

RegisterSmartObject

(
    USmartObjectComponent& SmartObject...
)

Public function

bool

 

RegisterSmartObjectActor

(
    const AActor& SmartObjectActor
)

Public function UFunction BlueprintCallable, Category

bool

 

Release

(
    const FSmartObjectClaimHandle& Cla...
)

Release claim on a smart object.

Protected function

void

 

RemoveFromSimulation

(
    const FSmartObjectCollectionEntry&...
)

Protected function

void

 

RemoveFromSimulation

(
    const USmartObjectComponent& Smart...
)

Protected function

void

 

RemoveFromSimulation

(
    const FSmartObjectID ID
)

Protected function

void

 

SpawnMissingCollection()

Public function

void

 

UnregisterCollection

(
    ASmartObjectCollection& InCollecti...
)

Public function

void

 

UnregisterSlotInvalidationCallback

(
    const FSmartObjectClaimHandle& Cla...
)

Unregisters a callback to be notified if the claimed slot is no longer available and user need to perform cleanup.

Public function

bool

 

UnregisterSmartObject

(
    USmartObjectComponent& SmartObject...
)

Public function

bool

 

UnregisterSmartObjectActor

(
    const AActor& SmartObjectActor
)

Public function UFunction BlueprintCallable, Category

const USmart...

 

Use

(
    const FSmartObjectClaimHandle& Cla...,
    const TSubclassOf< USmartObjectBeha...
)

Start using a claimed smart object slot.

Public function

const Defini...

 

Use

(
    const FSmartObjectClaimHandle& Cla...
)

Start using a claimed smart object slot.

Protected function

const USmart...

 

Use

(
    FSmartObjectRuntime& SmartObjectRu...,
    const FSmartObjectClaimHandle& Cla...,
    const TSubclassOf< USmartObjectBeha...
)

Overridden from UWorldSubsystem

Name Description

Protected function Virtual

void

 

OnWorldBeginPlay

(
    UWorld& World
)

BeginPlay will push all objects stored in the collection to the runtime simulation and initialize octree using collection bounds.

Protected function Virtual

void

 

OnWorldComponentsUpdated

(
    UWorld& World
)

Callback overriden to gather loaded collections, spawn missing one and set the main collection.