Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Entities::Entity Class Reference

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>

Inheritance diagram for Engine::Entities::Entity:
Collaboration diagram for Engine::Entities::Entity:

Public Member Functions

 Entity ()
 ~Entity () override
void enableTick (bool enable)
 Enables or disables ticking for this entity.
void setTickPriority (int32_t priority)
int32_t getTickPriority () const
void tick (double deltaTime) override
 Executes every frame if tick is enabled.
template<typename T, typename... Args>
requires std::is_base_of_v<Components::Logic, T>
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
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

uuids::uuid getUUID () const
 Getter for the UUID of this entity.
std::string getUuidString () const
 Getter for the UUID of this entity as a string.

Protected Attributes

std::vector< std::unique_ptr< Components::Logic > > components_
 List of all logical components.
entt::entity data_ = entt::null
bool allowTicking_ = false
int32_t tickPriority_ = 0

Private Attributes

uuids::uuid uuid_

Detailed Description

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.

Definition at line 16 of file Entity.h.

Constructor & Destructor Documentation

◆ Entity()

Engine::Entities::Entity::Entity ( )

◆ ~Entity()

Engine::Entities::Entity::~Entity ( )
override

Member Function Documentation

◆ addComponent()

template<typename T, typename... Args>
requires std::is_base_of_v<Components::Logic, T>
T * Engine::Entities::Entity::addComponent ( Args &&... args)
inline

Adds a component to the entity. Checks for uniqueness if the component defines 'static constexpr bool IsUnique = true;'.

Template Parameters
TThe type of component to add (must derive from LogicComponent).
ArgsArguments to forward to the component constructor.
Returns
Pointer to the added (or existing unique) component.

Definition at line 45 of file Entity.h.

References components_, and getComponent().

Here is the call graph for this function:

◆ canEverTick()

bool Engine::Entities::Entity::canEverTick ( ) const
nodiscard

Tells if this entity can ever tick.

Returns
true if it can ever tick

◆ canTick()

bool Engine::Entities::Entity::canTick ( ) const
nodiscard

Tells you if the entity can execute its tick function.

Returns
true if it can tick

◆ enableTick()

void Engine::Entities::Entity::enableTick ( bool enable)

Enables or disables ticking for this entity.

Parameters
enabledisable or enable ticking

◆ getAllComponents()

const std::vector< std::unique_ptr< Components::Logic > > & Engine::Entities::Entity::getAllComponents ( ) const
inlinenodiscard

Gets all components on this entity.

Returns
Read-only reference to the component list.

Definition at line 148 of file Entity.h.

References components_.

◆ getComponent()

template<typename T>
requires std::is_base_of_v<Components::Logic, T>
T * Engine::Entities::Entity::getComponent ( ) const
inline

Returns the first component of type T found.

Returns
Pointer to component or nullptr if not found.

Definition at line 75 of file Entity.h.

References components_.

Referenced by addComponent(), and hasComponent().

Here is the caller graph for this function:

◆ getComponents()

template<typename T>
requires std::is_base_of_v<Components::Logic, T>
std::vector< T * > Engine::Entities::Entity::getComponents ( ) const
inline

Returns all components of type T.

Returns
Vector of pointers to components of type T.

Definition at line 90 of file Entity.h.

References components_.

◆ getEcsEntity()

entt::entity Engine::Entities::Entity::getEcsEntity ( ) const
inlinenodiscard

Gets the ECS entity handle for this Entity.

Returns
The entt::entity handle.

Definition at line 168 of file Entity.h.

References data_.

◆ getTickPriority()

int32_t Engine::Entities::Entity::getTickPriority ( ) const
inlinenodiscard

Definition at line 28 of file Entity.h.

References tickPriority_.

◆ getUUID()

uuids::uuid Engine::Entities::Entity::getUUID ( ) const
inlineprotected

Getter for the UUID of this entity.

Returns
uuid of this entity

Definition at line 175 of file Entity.h.

References uuid_.

◆ getUuidString()

std::string Engine::Entities::Entity::getUuidString ( ) const
protected

Getter for the UUID of this entity as a string.

Returns
UUID of this entity as a string

◆ hasComponent()

template<typename T>
requires std::is_base_of_v<Components::Logic, T>
bool Engine::Entities::Entity::hasComponent ( ) const
inline

Checks if a component of type T exists.

Returns
true if found.

Definition at line 140 of file Entity.h.

References getComponent().

Here is the call graph for this function:

◆ removeComponent()

void Engine::Entities::Entity::removeComponent ( Components::Logic * component)
inline

Removes a specific component instance.

Parameters
componentPointer to the component to remove.

Definition at line 104 of file Entity.h.

References components_.

◆ removeFirstComponent()

template<typename T>
requires std::is_base_of_v<Components::Logic, T>
bool Engine::Entities::Entity::removeFirstComponent ( )
inline

Removes the first component of type T found.

Returns
true if a component was removed, false otherwise.

Definition at line 121 of file Entity.h.

References components_.

◆ setTickPriority()

void Engine::Entities::Entity::setTickPriority ( int32_t priority)

◆ tick()

void Engine::Entities::Entity::tick ( double deltaTime)
overridevirtual

Executes every frame if tick is enabled.

Parameters
deltaTimetime between the last frame and this frame

Reimplemented from Engine::Core::ITickable.

Member Data Documentation

◆ allowTicking_

bool Engine::Entities::Entity::allowTicking_ = false
protected

Definition at line 190 of file Entity.h.

◆ components_

std::vector<std::unique_ptr<Components::Logic> > Engine::Entities::Entity::components_
protected

List of all logical components.

Definition at line 186 of file Entity.h.

Referenced by addComponent(), getAllComponents(), getComponent(), getComponents(), removeComponent(), and removeFirstComponent().

◆ data_

entt::entity Engine::Entities::Entity::data_ = entt::null
protected

Definition at line 188 of file Entity.h.

Referenced by getEcsEntity().

◆ tickPriority_

int32_t Engine::Entities::Entity::tickPriority_ = 0
protected

Definition at line 191 of file Entity.h.

Referenced by getTickPriority().

◆ uuid_

uuids::uuid Engine::Entities::Entity::uuid_
private

Definition at line 193 of file Entity.h.

Referenced by getUUID().


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Entity/Entity.h