Open 3D Engine AzFramework API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzFramework::BehaviorEntity Class Reference

#include <BehaviorEntity.h>

Public Member Functions

 AZ_RTTI (BehaviorEntity, "{41CC88A4-FE07-48E6-943D-998DE68AFF5C}")
 
 AZ_CLASS_ALLOCATOR (BehaviorEntity, AZ::SystemAllocator)
 
 BehaviorEntity ()=default
 
 BehaviorEntity (AZ::EntityId entityId)
 
 BehaviorEntity (AZ::Entity *entity)
 
AZStd::string GetName () const
 
void SetName (const char *name)
 
AZ::EntityId GetId () const
 
EntityContextId GetOwningContextId () const
 
bool IsValid () const
 
bool Exists () const
 
bool IsActivated () const
 
void Activate ()
 
void Deactivate ()
 
BehaviorComponentId CreateComponent (const AZ::TypeId &componentTypeId, const AZ::ComponentConfig *componentConfig=nullptr)
 
bool DestroyComponent (BehaviorComponentId componentId)
 
AZStd::vector< BehaviorComponentIdGetComponents () const
 
BehaviorComponentId FindComponentOfType (const AZ::TypeId &componentTypeId) const
 
AZStd::vector< BehaviorComponentIdFindAllComponentsOfType (const AZ::TypeId &componentTypeId) const
 
AZ::TypeId GetComponentType (BehaviorComponentId componentId) const
 
AZStd::string GetComponentName (BehaviorComponentId componentId) const
 
bool SetComponentConfiguration (BehaviorComponentId componentId, const AZ::ComponentConfig &componentConfig)
 
bool GetComponentConfiguration (BehaviorComponentId componentId, AZ::ComponentConfig &outComponentConfig) const
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 

Detailed Description

A wrapper around calls to AZ::Entity, for use within the BehaviorContext. It is always safe to call functions on this class even if the entity it represents has been deleted from memory.

Constructor & Destructor Documentation

◆ BehaviorEntity() [1/3]

AzFramework::BehaviorEntity::BehaviorEntity ( )
default

Constructs an invalid BehaviorEntity. Any methods called on this instance will have no effect.

◆ BehaviorEntity() [2/3]

AzFramework::BehaviorEntity::BehaviorEntity ( AZ::EntityId  entityId)
explicit

Constructs a BehaviorEntity with the given entity ID.

Parameters
entityIdThe ID of the entity.

◆ BehaviorEntity() [3/3]

AzFramework::BehaviorEntity::BehaviorEntity ( AZ::Entity *  entity)
explicit

Constructs a BehaviorEntity with the ID of the provided entity.

Parameters
entityEntity that this BehaviorEntity will represent. If nullptr is provided then an invalid BehaviorEntity is constructed.

Member Function Documentation

◆ Activate()

void AzFramework::BehaviorEntity::Activate ( )

◆ CreateComponent()

BehaviorComponentId AzFramework::BehaviorEntity::CreateComponent ( const AZ::TypeId &  componentTypeId,
const AZ::ComponentConfig *  componentConfig = nullptr 
)

Creates a component and attaches it to the entity. You cannot add a component to an entity when the entity is activated.

Parameters
componentTypeIdType ID of component to create. For example, pass TransformComponentTypeId to create a TransformComponent.
componentConfig(Optional) A configuration to apply to the new component. The configuration class must be of the appropriate type for this component. For example, use a TransformConfig with a TransformComponent.
Returns
Returns the ID of the new component. If the component could not be created then AZ::InvalidEntityId is returned.

◆ Deactivate()

void AzFramework::BehaviorEntity::Deactivate ( )

◆ DestroyComponent()

bool AzFramework::BehaviorEntity::DestroyComponent ( BehaviorComponentId  componentId)

Removes the component from the entity and destroys it. You cannot destroy a component while the entity is activated.

Parameters
componentIdID of the component to destroy.
Returns
True if the component was destroyed. Otherwise, false.

◆ Exists()

bool AzFramework::BehaviorEntity::Exists ( ) const

Check whether the entity exists in memory. Note that an entity which exists may or may not be activated.

Returns
true if the entity exists in memory.

◆ FindAllComponentsOfType()

AZStd::vector< BehaviorComponentId > AzFramework::BehaviorEntity::FindAllComponentsOfType ( const AZ::TypeId &  componentTypeId) const

Gets all components of a specified type registered with the entity.

Parameters
componentTypeIdThe type of component to find.
Returns
A vector with the IDs of all components of a specified type registered with the entity.

◆ FindComponentOfType()

BehaviorComponentId AzFramework::BehaviorEntity::FindComponentOfType ( const AZ::TypeId &  componentTypeId) const

Finds the first component of the requested component type.

Parameters
componentTypeIdThe type of component to find.
Returns
The ID of the first component of the requested type. Returns invalid component ID if a component of the requested type cannot be found.

◆ GetComponentConfiguration()

bool AzFramework::BehaviorEntity::GetComponentConfiguration ( BehaviorComponentId  componentId,
AZ::ComponentConfig &  outComponentConfig 
) const

Get a component's configuration.

Parameters
componentIdThe ID of the component to query.
outComponentConfig[out]The component will copy its properties into this configuration class. The configuration class must be of the appropriate type for this component. For example, use a TransformConfig with a TransformComponent.
Returns
True if the configuration was successfully copied from the component. Returns false if the component was not found, or the component was not compatible with the provided configuration class.

◆ GetComponentName()

AZStd::string AzFramework::BehaviorEntity::GetComponentName ( BehaviorComponentId  componentId) const

Get the name of a specific component on the entity.

Parameters
componentIdthe ID of the component to query.
Returns
The name of the component.

◆ GetComponents()

AZStd::vector< BehaviorComponentId > AzFramework::BehaviorEntity::GetComponents ( ) const

Gets all components registered with the entity.

Returns
A vector with the IDs of all components registered with the entity.

◆ GetComponentType()

AZ::TypeId AzFramework::BehaviorEntity::GetComponentType ( BehaviorComponentId  componentId) const

Get the type of a specific component on the entity.

Parameters
componentIdThe ID of the component to query.
Returns
The type of the specified component. Returns an invalid type ID if the component is not found.

◆ GetId()

AZ::EntityId AzFramework::BehaviorEntity::GetId ( ) const
inline

◆ GetName()

AZStd::string AzFramework::BehaviorEntity::GetName ( ) const

◆ GetOwningContextId()

EntityContextId AzFramework::BehaviorEntity::GetOwningContextId ( ) const

Gets the ID of the entity context that the entity belongs to.

Returns
The ID of the entity context that the entity belongs to.

◆ IsActivated()

bool AzFramework::BehaviorEntity::IsActivated ( ) const

Check whether the entity is activated.

Returns
Returns true if the entity is activated. Otherwise, false.

◆ IsValid()

bool AzFramework::BehaviorEntity::IsValid ( ) const
inline

Check whether this instance has a valid entity ID. Note that a valid entity ID does not indicate whether the entity it represents currently exists in memory.

Returns
Returns true if the entity ID is valid. Otherwise, false.

◆ SetComponentConfiguration()

bool AzFramework::BehaviorEntity::SetComponentConfiguration ( BehaviorComponentId  componentId,
const AZ::ComponentConfig &  componentConfig 
)

Set the component's configuration. You cannot configure a component while the entity is activated.

Parameters
componentIdThe ID of the component to configure.
componentConfigThe component will set its properties based on this configuration. The configuration class must be of the appropriate type for this component. For example, use a TransformConfig with a TransformComponent.
Returns
True if the configuration was successfully copied to the component. Returns false if the component was not found, or the component was not compatible with the provided configuration class.

◆ SetName()

void AzFramework::BehaviorEntity::SetName ( const char *  name)


The documentation for this class was generated from the following file: