Object in charge of binding ActorDefinitions to spawn functions, as well as keeping the registry of all the actors spawned. More...
#include <ActorDispatcher.h>
Public Types | |
using | SpawnFunctionType = TFunction< FActorSpawnResult(const FTransform &, const FActorDescription &)> |
Public Member Functions | |
void | Bind (FActorDefinition Definition, SpawnFunctionType SpawnFunction) |
Bind a definition to a spawn function. More... | |
void | Bind (ACarlaActorFactory &ActorFactory) |
Bind all the definitions of ActorFactory to its spawn function. More... | |
bool | DestroyActor (FCarlaActor::IdType ActorId) |
Destroys an actor, properly removing it from the registry. More... | |
const TArray< FActorDefinition > & | GetActorDefinitions () const |
const FActorRegistry & | GetActorRegistry () const |
FActorRegistry & | GetActorRegistry () |
void | PutActorToSleep (FCarlaActor::IdType Id, UCarlaEpisode *CarlaEpisode) |
FCarlaActor * | RegisterActor (AActor &Actor, FActorDescription ActorDescription, FActorRegistry::IdType DesiredId=0) |
Register an actor that was not created using "SpawnActor" function but that should be kept in the registry. More... | |
AActor * | ReSpawnActor (const FTransform &Transform, FActorDescription ActorDescription) |
ReSpawns an actor based on ActorDescription at Transform. More... | |
TPair< EActorSpawnResultStatus, FCarlaActor * > | SpawnActor (const FTransform &Transform, FActorDescription ActorDescription, FCarlaActor::IdType DesiredId=0) |
Spawns an actor based on ActorDescription at Transform. More... | |
void | WakeActorUp (FCarlaActor::IdType Id, UCarlaEpisode *CarlaEpisode) |
Private Member Functions | |
void | OnActorDestroyed (AActor *Actor) |
Private Attributes | |
TArray< TSubclassOf< AActor > > | Classes |
TArray< FActorDefinition > | Definitions |
FActorRegistry | Registry |
TArray< SpawnFunctionType > | SpawnFunctions |
Object in charge of binding ActorDefinitions to spawn functions, as well as keeping the registry of all the actors spawned.
Definition at line 24 of file ActorDispatcher.h.
using UActorDispatcher::SpawnFunctionType = TFunction<FActorSpawnResult(const FTransform &, const FActorDescription &)> |
Definition at line 30 of file ActorDispatcher.h.
void UActorDispatcher::Bind | ( | FActorDefinition | Definition, |
SpawnFunctionType | SpawnFunction | ||
) |
Bind a definition to a spawn function.
When SpawnActor is called with a matching description Functor is called.
Definition at line 23 of file ActorDispatcher.cpp.
References UActorBlueprintFunctionLibrary::CheckActorDefinition(), FActorDefinition::Class, Classes, Definitions, FActorDefinition::Id, SpawnFunctions, and FActorDefinition::UId.
Referenced by Bind().
void UActorDispatcher::Bind | ( | ACarlaActorFactory & | ActorFactory | ) |
Bind all the definitions of ActorFactory to its spawn function.
Definition at line 38 of file ActorDispatcher.cpp.
References Bind(), ACarlaActorFactory::GetDefinitions(), and ACarlaActorFactory::SpawnActor().
bool UActorDispatcher::DestroyActor | ( | FCarlaActor::IdType | ActorId | ) |
Destroys an actor, properly removing it from the registry.
Return true if the Actor is destroyed or already marked for destruction, false if indestructible or nullptr.
Definition at line 117 of file ActorDispatcher.cpp.
References FActorRegistry::Deregister(), FActorInfo::Description, FActorRegistry::FindCarlaActor(), FCarlaActor::GetActor(), FCarlaActor::GetActorInfo(), FActorDescription::Id, Registry, and Success.
|
inline |
Definition at line 82 of file ActorDispatcher.h.
|
inline |
Definition at line 87 of file ActorDispatcher.h.
|
inline |
Definition at line 92 of file ActorDispatcher.h.
|
private |
Definition at line 234 of file ActorDispatcher.cpp.
References FActorRegistry::Deregister(), FActorRegistry::FindCarlaActor(), FCarlaActor::GetActorId(), carla::ros2::ROS2::GetInstance(), FCarlaActor::IsActive(), and Registry.
Referenced by RegisterActor().
void UActorDispatcher::PutActorToSleep | ( | FCarlaActor::IdType | Id, |
UCarlaEpisode * | CarlaEpisode | ||
) |
Definition at line 224 of file ActorDispatcher.cpp.
References FActorRegistry::PutActorToSleep(), and Registry.
FCarlaActor * UActorDispatcher::RegisterActor | ( | AActor & | Actor, |
FActorDescription | ActorDescription, | ||
FActorRegistry::IdType | DesiredId = 0 |
||
) |
Register an actor that was not created using "SpawnActor" function but that should be kept in the registry.
Definition at line 162 of file ActorDispatcher.cpp.
References FCarlaActor::GetActorId(), carla::ros2::ROS2::GetInstance(), FActorDescription::Id, OnActorDestroyed(), FActorRegistry::Register(), Registry, and FActorDescription::Variations.
Referenced by UCarlaEpisode::InitializeAtBeginPlay(), and SpawnActor().
AActor * UActorDispatcher::ReSpawnActor | ( | const FTransform & | Transform, |
FActorDescription | ActorDescription | ||
) |
ReSpawns an actor based on ActorDescription at Transform.
To properly despawn an actor created with this function call DestroyActor. Used to respawn dormant actors.
Definition at line 86 of file ActorDispatcher.cpp.
References FActorSpawnResult::Actor, FActorDescription::Class, Classes, FActorDescription::Id, SpawnFunctions, FActorSpawnResult::Status, and FActorDescription::UId.
TPair< EActorSpawnResultStatus, FCarlaActor * > UActorDispatcher::SpawnActor | ( | const FTransform & | Transform, |
FActorDescription | ActorDescription, | ||
FCarlaActor::IdType | DesiredId = 0 |
||
) |
Spawns an actor based on ActorDescription at Transform.
To properly despawn an actor created with this function call DestroyActor.
Definition at line 48 of file ActorDispatcher.cpp.
References FActorSpawnResult::Actor, FActorDescription::Class, Classes, FCarlaActor::GetActor(), FActorDescription::Id, FActorSpawnResult::IsValid(), RegisterActor(), SpawnFunctions, FActorSpawnResult::Status, ATagger::TagActor(), and FActorDescription::UId.
Referenced by UCarlaEpisode::SpawnActorWithInfo().
void UActorDispatcher::WakeActorUp | ( | FCarlaActor::IdType | Id, |
UCarlaEpisode * | CarlaEpisode | ||
) |
Definition at line 229 of file ActorDispatcher.cpp.
References Registry, and FActorRegistry::WakeActorUp().
|
private |
Definition at line 106 of file ActorDispatcher.h.
Referenced by Bind(), ReSpawnActor(), and SpawnActor().
|
private |
Definition at line 102 of file ActorDispatcher.h.
Referenced by Bind().
|
private |
Definition at line 108 of file ActorDispatcher.h.
Referenced by DestroyActor(), OnActorDestroyed(), PutActorToSleep(), RegisterActor(), and WakeActorUp().
|
private |
Definition at line 104 of file ActorDispatcher.h.
Referenced by Bind(), ReSpawnActor(), and SpawnActor().