Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
EngineCore::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 EngineCore::Entity:
Collaboration diagram for EngineCore::Entity:

Public Member Functions

 Entity ()
virtual ~Entity ()
void enableTick (bool enable)
 Enables or disables ticking for this entity.
void tick (double deltaTime) override
 Executes every frame if tick is enabled.
template<typename T, typename... 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>
T * getComponent () const
 Returns the first component of type T found.
template<typename T>
std::vector< T * > getComponents () const
 Returns all components of type T.
void removeComponent (LogicComponent *component)
 Removes a specific component instance.
template<typename T>
bool removeFirstComponent ()
 Removes the first component of type T found.
template<typename T>
bool hasComponent () const
 Checks if a component of type T exists.
bool canTick () const
 Tells you if the entity can execute its tick function.
bool canEverTick () const
 Tells if this entity can ever tick.
Public Member Functions inherited from EngineCore::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::shared_ptr< LogicComponent > > components
 List of all logical components.
entt::entity data = entt::null
bool allowTicking = false

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.

Date
2025-09-17
Author
Konstantin Passig

Definition at line 18 of file Entity.h.

Constructor & Destructor Documentation

◆ Entity()

EngineCore::Entity::Entity ( )

Definition at line 7 of file Entity.cpp.

References allowTicking, data, EngineCore::UuidSingleton::generate(), Ecs::RegistryManager::get(), EngineCore::UuidSingleton::instance(), and uuid.

Referenced by EngineCore::Actor::Actor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~Entity()

EngineCore::Entity::~Entity ( )
virtual

Definition at line 13 of file Entity.cpp.

References canTick(), and enableTick().

Here is the call graph for this function:

Member Function Documentation

◆ addComponent()

template<typename T, typename... Args>
T * EngineCore::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 44 of file Entity.h.

References components, and getComponent().

Referenced by EngineCore::Rat::Rat(), and EngineCore::StaticMeshActor::StaticMeshActor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ canEverTick()

bool EngineCore::Entity::canEverTick ( ) const
nodiscard

Tells if this entity can ever tick.

Returns
true if it can ever tick

Definition at line 44 of file Entity.cpp.

References allowTicking.

◆ canTick()

bool EngineCore::Entity::canTick ( ) const
nodiscard

Tells you if the entity can execute its tick function.

Returns
true if it can tick

Definition at line 35 of file Entity.cpp.

References allowTicking, data, and Ecs::RegistryManager::get().

Referenced by ~Entity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableTick()

void EngineCore::Entity::enableTick ( bool enable)

Enables or disables ticking for this entity.

Parameters
enabledisable or enable ticking

Definition at line 18 of file Entity.cpp.

References data, and Ecs::RegistryManager::get().

Referenced by ~Entity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getComponent()

template<typename T>
T * EngineCore::Entity::getComponent ( ) const
inline

Returns the first component of type T found.

Returns
Pointer to component or nullptr if not found.

Definition at line 73 of file Entity.h.

References components.

Referenced by addComponent(), hasComponent(), and EngineCore::CollisionComponent::registerWithBody().

Here is the caller graph for this function:

◆ getComponents()

template<typename T>
std::vector< T * > EngineCore::Entity::getComponents ( ) const
inline

Returns all components of type T.

Returns
Vector of pointers to components of type T.

Definition at line 88 of file Entity.h.

References components.

Referenced by EngineCore::PhysicsBodyComponent::beginPlay().

Here is the caller graph for this function:

◆ getUUID()

uuids::uuid EngineCore::Entity::getUUID ( ) const
inlineprotected

Getter for the UUID of this entity.

Returns
uuid of this entity
Author
Konstantin Passig
Date
16.12.2025

Definition at line 161 of file Entity.h.

References uuid.

◆ getUuidString()

std::string EngineCore::Entity::getUuidString ( ) const
protected

Getter for the UUID of this entity as a string.

Returns
UUID of this entity as a string
Author
Konstantin Passig
Date
16.12.2025

Definition at line 49 of file Entity.cpp.

References uuid.

◆ hasComponent()

template<typename T>
bool EngineCore::Entity::hasComponent ( ) const
inline

Checks if a component of type T exists.

Returns
true if found.

Definition at line 138 of file Entity.h.

References getComponent().

Here is the call graph for this function:

◆ removeComponent()

void EngineCore::Entity::removeComponent ( LogicComponent * component)
inline

Removes a specific component instance.

Parameters
componentPointer to the component to remove.

Definition at line 103 of file Entity.h.

References components.

◆ removeFirstComponent()

template<typename T>
bool EngineCore::Entity::removeFirstComponent ( )
inline

Removes the first component of type T found.

Returns
true if a component was removed, false otherwise.

Definition at line 119 of file Entity.h.

References components.

◆ tick()

void EngineCore::Entity::tick ( double deltaTime)
overridevirtual

Executes every frame if tick is enabled.

Parameters
deltaTimetime between the last frame and this frame

Reimplemented from EngineCore::ITickable.

Definition at line 31 of file Entity.cpp.

References EngineCore::ITickable::tick().

Referenced by EngineCore::Actor::tick().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ allowTicking

bool EngineCore::Entity::allowTicking = false
protected

Definition at line 179 of file Entity.h.

Referenced by canEverTick(), canTick(), and Entity().

◆ components

std::vector<std::shared_ptr<LogicComponent> > EngineCore::Entity::components
protected

◆ data

entt::entity EngineCore::Entity::data = entt::null
protected

◆ uuid

uuids::uuid EngineCore::Entity::uuid
private

Definition at line 181 of file Entity.h.

Referenced by Entity(), getUUID(), and getUuidString().


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