Skip to content

Engine → ECS → entity_handle.h

entity_handle

Syntax

class entity_handle

Constructors

AccessSignatureDescription
publicentity_handle() noexcept = default;A handle to nothing.
publicentity_handle( world &target, entity id) noexcept;
publicentity_handle( const entity_handle &) noexcept = default;

Destructors

AccessSignatureDescription
public~entity_handle() = default;

Variables

AccessNameTypeDefaultDescription
privatemEntityentity{}
privatemWorldworld *nullptr

Functions

Public

add

template <typename ComponentType> [[nodiscard]] core::result<component_ref<ComponentType>> add(
    ComponentType value = {});

Adds a component (world::add) and returns a reference to it.

component

template <typename ComponentType> [[nodiscard]] component_ref<ComponentType> component() const noexcept;

A reference to a component; is_valid() tells whether it exists.

destroy

[[nodiscard]] core::result<void> destroy();

Destroys the entity (world::destroy_entity).

has

template <typename ComponentType> [[nodiscard]] bool has() const noexcept;

True when the entity is alive and holds the component.

id

[[nodiscard]] entity id() const noexcept;

The underlying entity id.

is_alive

[[nodiscard]] bool is_alive() const noexcept;

True while the entity is alive.

owner

[[nodiscard]] world *owner() const noexcept;

The world the handle belongs to, or nullptr.

remove

template <typename ComponentType> [[nodiscard]] core::result<void> remove();

Removes a component (world::remove).

Operator Overloads

Public

operator=

entity_handle &operator=(
    const entity_handle &) noexcept = default;

operator==

[[nodiscard]] bool operator==(
    const entity_handle &other) const noexcept = default;