Raven Engine v0.1
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>
void Add (const T &component)
 Add a component to this entity.
template<typename T>
void Remove (const T &component)
 Remove a component from this entity.
template<typename T>
T * Get ()
 Retrieve a pointer to a component of type T.
template<typename T>
bool Has ()
 Check if this entity has a component of type T.
const UUIDGetID () const
 Get the unique identifier of this entity.
const usize GetNumComponents () const
 Get the number of components 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>
void Raven::Entity::Add ( const T & component)
inline

Add a component to this entity.

Template Parameters
TComponent type.
Parameters
componentThe component instance to add.

◆ Get()

template<typename T>
T * Raven::Entity::Get ( )
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()

const 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 ( )
inline

Check if this entity has a component of type T.

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

◆ 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>
void Raven::Entity::Remove ( const T & component)
inline

Remove a component from this entity.

Template Parameters
TComponent type.
Parameters
componentThe component instance to remove.

◆ operator==

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

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