|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
The entity class is the base class of everything which is attached to a scene. If it is part of a scene it is an entity. More...
#include <Entity.h>
Public Member Functions | |
| Entity () | |
| Creates an entity in the constructed lifecycle state. | |
| ~Entity () override | |
| Destroys the entity and owned logic components. | |
| void | enableTick (bool enable) |
| Enables or disables ticking for this entity. | |
| void | setTickPriority (int32_t priority) |
| Sets the tick ordering priority for this entity. | |
| int32_t | getTickPriority () const |
| Returns the tick ordering priority for this entity. | |
| void | tick (double deltaTime) override |
| Executes every frame if tick is enabled. | |
| void | destroy () |
| Tells the scene to destroy this Entity. | |
| void | destroyImmediate () |
| Destroys this entity immediately through its owning container. | |
| EntityContainer * | getOwningContainer () const |
| Returns the container that owns this entity. | |
| bool | isPendingDestroy () const |
| Returns whether this entity has been queued for destruction. | |
| bool | isPlaying () const |
| Returns whether this entity has begun play and has not ended play. | |
| template<typename T, typename... Args> requires std::is_base_of_v<Components::Logic, T> && std::is_constructible_v<T, Args...> | |
| T * | addComponent (Args &&... args) |
| Adds a component to the entity. Checks for uniqueness if the component defines 'static constexpr bool IsUnique = true;'. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| T * | getComponent () const |
| Returns the first component of type T found. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| std::vector< T * > | getComponents () const |
| Returns all components of type T. | |
| void | removeComponent (Components::Logic *component) |
| Removes a specific component instance. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| bool | removeFirstComponent () |
| Removes the first component of type T found. | |
| template<typename T> requires std::is_base_of_v<Components::Logic, T> | |
| bool | hasComponent () const |
| Checks if a component of type T exists. | |
| const std::vector< std::unique_ptr< Components::Logic > > & | getAllComponents () const |
| Gets all components on this entity. | |
| bool | canTick () const |
| Tells you if the entity can execute its tick function. | |
| bool | canEverTick () const |
| Tells if this entity can ever tick. | |
| entt::entity | getEcsEntity () const |
| Gets the ECS entity handle for this Entity. | |
| Public Member Functions inherited from Engine::Core::ITickable | |
| virtual | ~ITickable ()=default |
| Destroys a tickable object. | |
| virtual void | preTick () |
| Function which executes immediately before the execution of ITickable::preTick() | |
| virtual void | postTick () |
| Function which executes immediately after the execution of ITickable::postTick() | |
Protected Member Functions | |
| virtual void | onEngineBeginPlay () |
| Hook called when the engine begins play for this entity. | |
| virtual void | onEngineEndPlay () |
| Hook called when the engine ends play for this entity. | |
| virtual void | onEngineDestroyed () |
| Hook called when the entity is being destroyed by the engine lifecycle. | |
Protected Attributes | |
| std::vector< std::unique_ptr< Components::Logic > > | components_ |
| List of all logical components. | |
| entt::entity | data_ = entt::null |
| ECS entity handle associated with this entity. | |
| bool | allowTicking_ = false |
| Whether ticking is currently enabled. | |
| int32_t | tickPriority_ = 0 |
| Priority used to order entity ticks. | |
Private Types | |
| enum class | LifecycleState { Constructed , Playing , PendingDestroy , Destroying , Destroyed } |
Private Member Functions | |
| void | engineBeginPlay () |
| void | engineEndPlay () |
| bool | isDestroyingOrDestroyed () const |
Private Attributes | |
| EntityContainer * | owningContainer_ = nullptr |
| LifecycleState | lifecycleState_ = LifecycleState::Constructed |
The entity class is the base class of everything which is attached to a scene. If it is part of a scene it is an entity.
|
strongprivate |
| Engine::Entities::Entity::Entity | ( | ) |
Creates an entity in the constructed lifecycle state.
|
override |
Destroys the entity and owned logic components.
|
inline |
Adds a component to the entity. Checks for uniqueness if the component defines 'static constexpr bool IsUnique = true;'.
| T | The type of component to add (must derive from LogicComponent). |
| Args | Arguments to forward to the component constructor. |
Definition at line 88 of file Entity.h.
References components_, getComponent(), and isPlaying().
Referenced by Engine::Entities::Actor::addComponent(), Engine::Entities::Actor::addComponentWithSceneEntityFirstNodeRest(), and Engine::Entities::Actor::~Actor().
|
nodiscard |
Tells if this entity can ever tick.
|
nodiscard |
Tells you if the entity can execute its tick function.
| void Engine::Entities::Entity::destroy | ( | ) |
Tells the scene to destroy this Entity.
| void Engine::Entities::Entity::destroyImmediate | ( | ) |
Destroys this entity immediately through its owning container.
| void Engine::Entities::Entity::enableTick | ( | bool | enable | ) |
Enables or disables ticking for this entity.
| enable | disable or enable ticking |
|
private |
|
private |
|
inlinenodiscard |
Gets all components on this entity.
Definition at line 189 of file Entity.h.
References components_.
|
inline |
Returns the first component of type T found.
Definition at line 116 of file Entity.h.
References components_.
Referenced by addComponent(), and hasComponent().
|
inline |
Returns all components of type T.
Definition at line 131 of file Entity.h.
References components_.
|
inlinenodiscard |
|
nodiscard |
Returns the container that owns this entity.
References EntityContainer.
|
inlinenodiscard |
Returns the tick ordering priority for this entity.
Definition at line 45 of file Entity.h.
References tickPriority_.
|
inline |
Checks if a component of type T exists.
Definition at line 181 of file Entity.h.
References getComponent().
|
nodiscardprivate |
|
nodiscard |
Returns whether this entity has been queued for destruction.
|
nodiscard |
Returns whether this entity has begun play and has not ended play.
Referenced by addComponent().
|
protectedvirtual |
Hook called when the engine begins play for this entity.
Reimplemented in Engine::Entities::Actor.
|
protectedvirtual |
Hook called when the entity is being destroyed by the engine lifecycle.
Reimplemented in Engine::Entities::Actor.
|
protectedvirtual |
Hook called when the engine ends play for this entity.
Reimplemented in Engine::Entities::Actor.
|
inline |
Removes a specific component instance.
| component | Pointer to the component to remove. |
Definition at line 145 of file Entity.h.
References components_.
|
inline |
Removes the first component of type T found.
Definition at line 162 of file Entity.h.
References components_.
| void Engine::Entities::Entity::setTickPriority | ( | int32_t | priority | ) |
Sets the tick ordering priority for this entity.
| priority | Tick priority value. |
|
overridevirtual |
Executes every frame if tick is enabled.
| deltaTime | time between the last frame and this frame |
Reimplemented from Engine::Core::ITickable.
|
protected |
|
protected |
List of all logical components.
Definition at line 215 of file Entity.h.
Referenced by addComponent(), getAllComponents(), getComponent(), getComponents(), removeComponent(), and removeFirstComponent().
|
protected |
ECS entity handle associated with this entity.
Definition at line 217 of file Entity.h.
Referenced by Engine::Entities::Actor::addComponent(), Engine::Entities::Actor::addComponentWithSceneEntityFirstNodeRest(), and getEcsEntity().
|
private |
|
private |
|
protected |
Priority used to order entity ticks.
Definition at line 220 of file Entity.h.
Referenced by getTickPriority().