Open 3D Engine (O3DE), the successor to Lumberyard, is now available in Developer Preview. Download O3DE or visit the AWS Game Tech blog to learn more. |
Base class for all components. More...
Inherited by AzToolsFramework::Components::EditorComponentBase .
Public Member Functions |
|
AZ_RTTI ( AZ::Component , "{EDFCB2CF-F75D-43BE-B26B-F35821B29247}") | |
Adds run-time type information to the component.
More...
|
|
Component () | |
Initializes a component's internals.
More...
|
|
virtual | ~Component () |
Destroys a component.
More...
|
|
Entity * | GetEntity () const |
Returns a pointer to the entity.
More...
|
|
EntityId | GetEntityId () const |
Returns the entity ID if the component is attached to an entity.
More...
|
|
ComponentId | GetId () const |
Returns the component ID, which is valid only when the component is attached to an entity.
More...
|
|
void | SetId (const ComponentId &id) |
Sets the component ID.
More...
|
|
Protected Member Functions |
|
virtual void | Init () |
Initializes a component's resources.
More...
|
|
virtual void | Activate ()=0 |
Puts the component into an active state.
More...
|
|
virtual void | Deactivate ()=0 |
Deactivates the component.
More...
|
|
void | SetEntity ( Entity *entity) |
Sets the current entity.
More...
|
|
Static Protected Member Functions |
|
static void | ReflectInternal ( ReflectContext *reflection) |
Reflects the
Component
class.
More...
|
|
Protected Attributes |
|
Entity * | m_entity |
Reference to the entity that owns the component. The value is null if the component is not attached to an entity.
More...
|
|
ComponentId | m_id |
A component ID that is unique for an entity. This component ID is not unique across all entities.
More...
|
|
Friends |
|
class | Entity |
Detailed Description
Base class for all components.
Constructor & Destructor Documentation
◆ Component()
AZ::Component::Component | ( | ) |
Initializes a component's internals.
A component's constructor should initialize the component's variables only. Because the component is not active yet, it should not connect to message buses, send messages, and so on. Similarly, the component's constructor should not attempt to cache pointers or data from other components on the same entity because those components can be added or removed at any moment. To process and initialize all resources that make a component ready to operate, use Init() .
◆ ~Component()
|
virtual |
Destroys a component.
The system always calls a component's Deactivate() function before destroying it.
Member Function Documentation
◆ Activate()
|
protected pure virtual |
Puts the component into an active state.
The system calls this function once during activation of each entity that owns the component. You must override this function. The system calls a component's Activate() function only if all services and components that the component depends on are present and active. Use GetProvidedServices and GetDependentServices to specify these dependencies.
Implemented in AzToolsFramework::Components::EditorComponentBase .
◆ AZ_RTTI()
AZ::Component::AZ_RTTI | ( | AZ::Component | , |
"{EDFCB2CF-F75D-43BE-B26B-F35821B29247}" | |||
) |
Adds run-time type information to the component.
◆ Deactivate()
|
protected pure virtual |
Deactivates the component.
The system calls this function when the owning entity is being deactivated. You must override this function. As a best practice, ensure that this function returns the component to a minimal footprint. The order of deactivation is the reverse of activation, so your component is deactivated before the components it depends on.
The system always calls the component's Deactivate() function before destroying the component. However, deactivation is not always followed by the destruction of the component. An entity and its components can be deactivated and reactivated without being destroyed. Ensure that your Deactivate() implementation can handle this scenario.
Implemented in AzToolsFramework::Components::EditorComponentBase .
◆ GetEntity()
|
inline |
Returns a pointer to the entity.
If the component is not attached to any entity, this function returns a null pointer. In that case, the component is in the default state (not activated). However, except in the case of tools, you typically should not use this function. It is a best practice to access other components through EBuses instead of accessing them directly. For more information, see the Programmer's Guide to Entities and Components in the Lumberyard User Guide.
- Returns
- A pointer to the entity. If the component is not attached to any entity, the return value is a null pointer.
◆ GetEntityId()
EntityId AZ::Component::GetEntityId | ( | ) | const |
Returns the entity ID if the component is attached to an entity.
If the component is not attached to any entity, this function asserts. As a safeguard, make sure that GetEntity() !=nullptr.
- Returns
- The ID of the entity that contains the component.
◆ GetId()
|
inline |
Returns the component ID, which is valid only when the component is attached to an entity.
If the component is not attached to any entity, the return value is 0. As a safeguard, make sure that GetEntity() !=nullptr.
- Returns
- The ID of the component. If the component is attached to any entity, the return value is 0.
◆ Init()
|
inline protected virtual |
Initializes a component's resources.
(Optional) Override this function to initialize resources that the component needs. The system calls this function once for each entity that owns the component. Although the Init() function initializes the component, the component is not active until the system calls the component's Activate() function. We recommend that you minimize the component's CPU and memory overhead when the component is inactive.
Reimplemented in AzToolsFramework::Components::EditorComponentBase .
◆ ReflectInternal()
|
static protected |
Reflects the Component class.
This function is called by the entity.
- Parameters
-
reflection The reflection context.
◆ SetEntity()
|
protected |
Sets the current entity.
This function is called by the entity.
- Parameters
-
entity The current entity.
◆ SetId()
|
inline |
Sets the component ID.
This function is for internal use only.
- Parameters
-
id The ID to assign to the component.
Friends And Related Function Documentation
◆ Entity
|
friend |
Member Data Documentation
◆ m_entity
|
protected |
Reference to the entity that owns the component. The value is null if the component is not attached to an entity.
◆ m_id
|
protected |
A component ID that is unique for an entity. This component ID is not unique across all entities.
The documentation for this class was generated from the following file:
- C:/lumberyard-root/dev/Code/Framework/AzCore/AzCore/Component/ Component.h