Raven Engine v0.1
A modern 3D Game Engine
Loading...
Searching...
No Matches
Raven::Entity Class Reference

Lightweight wrapper for manipulating a single entity within the ECS. More...

#include <Entity.h>

Public Member Functions

 Entity (Registry &ecs)
 Construct a new Entity instance with a fresh UUID.
 Entity (Registry &ecs, const UUID &id)
 Constructs an Entity with an ID.
 Entity (const Entity &other)
 Copy constructor for Entity.
Entityoperator= (const Entity &other)
 Copy assignment operator.
template<typename T>
bool Add (const T &component) const
 Add a component to this entity.
template<typename T>
bool Remove () const
 Remove a component from this entity.
bool RemoveAllComponents () const
 Remove all components from this entity.
template<typename T>
T * Get () const
 Retrieve a pointer to a component of type T.
template<typename T>
bool Has () const
 Check if this entity has a component of type T.
const UUIDGetID () const
 Get the unique identifier of this entity.
usize GetNumComponents () const
 Get the number of components attached to this entity.
bool HasComponents () const
 Check if any components are attached to this entity.

Friends

bool operator== (const Entity &lhs, const Entity &rhs)

Detailed Description

Lightweight wrapper for manipulating a single entity within the ECS.

Provides an interface to operate on an entity by delegating actions to the underlying Registry, such as adding, removing, checking, or retrieving components.

Constructor & Destructor Documentation

◆ Entity() [1/3]

Raven::Entity::Entity ( Registry & ecs)
inline

Construct a new Entity instance with a fresh UUID.

Parameters
ecsReference to the registry this entity belongs to.

◆ Entity() [2/3]

Raven::Entity::Entity ( Registry & ecs,
const UUID & id )
inline

Constructs an Entity with an ID.

Parameters
ecsReference to the registry this entity belongs to.
idUUID of the already existing Entity.

◆ Entity() [3/3]

Raven::Entity::Entity ( const Entity & other)
inline

Copy constructor for Entity.

Copies the UUID and the registry pointer. The entity remains tied to the same registry instance. This is a shallow copy — component data is not duplicated.

Member Function Documentation

◆ Add()

template<typename T>
bool Raven::Entity::Add ( const T & component) const
inline

Add a component to this entity.

Template Parameters
TComponent type.
Parameters
componentThe component instance to add.
Returns
True if the Component was added, false otherwise.

◆ Get()

template<typename T>
T * Raven::Entity::Get ( ) const
inline

Retrieve a pointer to a component of type T.

Template Parameters
TComponent type.
Returns
Pointer to the component, or nullptr if not found.

◆ GetID()

const UUID & Raven::Entity::GetID ( ) const
inline

Get the unique identifier of this entity.

Returns
Const reference to UUID.

◆ GetNumComponents()

usize Raven::Entity::GetNumComponents ( ) const
inline

Get the number of components attached to this entity.

Returns
Number of components.

◆ Has()

template<typename T>
bool Raven::Entity::Has ( ) const
inline

Check if this entity has a component of type T.

Template Parameters
TComponent type.
Returns
True if the component exists, false otherwise.

◆ HasComponents()

bool Raven::Entity::HasComponents ( ) const
inline

Check if any components are attached to this entity.

Returns
True if at least one component is attached to this entity, false if empty.

◆ operator=()

Entity & Raven::Entity::operator= ( const Entity & other)
inline

Copy assignment operator.

Performs a shallow copy of the UUID and registry pointer. This does not clone the entity or its components — only the handle is reassigned. Safe as long as the original registry remains valid.

◆ Remove()

template<typename T>
bool Raven::Entity::Remove ( ) const
inline

Remove a component from this entity.

Template Parameters
TComponent type.
Returns
True if the Component was removed, false otherwise.

◆ RemoveAllComponents()

bool Raven::Entity::RemoveAllComponents ( ) const
inline

Remove all components from this entity.

Returns
True if the entity had components to be removed, false otherwise

◆ operator==

bool operator== ( const Entity & lhs,
const Entity & rhs )
friend

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