Class Entity#

Class Documentation#

class Entity#

Entity class.

Public Functions

constexpr Entity() noexcept = default#

Constructor. Creates an empty Entity.

constexpr Entity(entt::entity handle, Scene *scene) noexcept#

Constructor. Creates a new Entity.

Parameters:
  • handle – Handle to entt::entity.

  • sceneScene which the new Entity is associated with.

constexpr Entity(const Entity&) = default#

Copy constructor.

constexpr Entity &operator=(const Entity&) = default#

Copy assignment operator.

constexpr Entity(Entity&&) noexcept = default#

Move constructor.

constexpr Entity &operator=(Entity&&) noexcept = default#

Move assignment operator.

constexpr ~Entity() = default#

Destructor.

template<typename T, typename ...Args>
inline T &AddComponent(Args&&... args)#

Add component T to the entity.

Note

If entity already has component then the existing component is returned instead.

Template Parameters:

T – Type of component to add.

Parameters:

args – Arguments to forward to the component.

Returns:

N Added component.

template<typename T, typename ...Args>
inline T &AddOrReplaceComponent(Args&&... args)#

Add a new or replace an existing component.

Template Parameters:

T – Type of component to add or replace.

Parameters:

args – Arguments to forward to the component.

Returns:

Added or replaced component.

template<typename T>
inline T &GetComponent() const#

Retrieve component T from entity.

Warning

Behaviour is undefined if entity doesnt have the requested component.

Template Parameters:

T – Type of component.

Returns:

Requested component.

template<typename T>
inline bool HasComponent() const#

Query if entity contains the component T.

Template Parameters:

T – Type of component.

Returns:

True if entity contains component T, false otherwise.

template<typename T>
inline void RemoveComponent()#

Remove component T from entity.

Template Parameters:

T – Type of component.

const Utils::UID &GetUID() const#

Retrieve the unique identifier of the entity.

Returns:

Unique identifier of the entity.

const std::string &GetName() const#

Retrieve the name of the entity.

Returns:

Name of the entity.

constexpr operator bool() const noexcept#

Retrieve whether the entity is valid or null.

Returns:

True if entity is valid, false if the entity is null.

constexpr operator entt::entity() const noexcept#

Retrieve the underlying entt entity.

Returns:

Underlying entt entity.

constexpr bool operator==(const Entity &other) const noexcept = default#
constexpr bool operator!=(const Entity &other) const noexcept = default#