1 #ifndef ENTT_ENTITY_ACTOR_HPP
2 #define ENTT_ENTITY_ACTOR_HPP
7 #include "../config/config.h"
8 #include "registry.hpp"
26 template<
typename Entity>
47 :
entt{other.entt}, reg{other.reg}
68 ENTT_ASSERT(ref.valid(
entity));
90 auto tmp{std::move(other)};
91 std::swap(reg, tmp.reg);
92 std::swap(
entt, tmp.entt);
112 template<
typename Component,
typename... Args>
114 return reg->template assign_or_replace<Component>(
entt, std::forward<Args>(args)...);
121 template<
typename Component>
123 reg->template remove<Component>(
entt);
131 template<
typename... Component>
133 return reg->template
has<Component...>(
entt);
141 template<
typename... Component>
142 decltype(
auto)
get()
const {
143 return std::as_const(*reg).template get<Component...>(
entt);
147 template<
typename... Component>
149 return reg->template
get<Component...>(
entt);
157 template<
typename... Component>
159 return std::as_const(*reg).template try_get<Component...>(
entt);
163 template<
typename... Component>
178 return const_cast<registry_type &>(std::as_const(*this).backend());
193 explicit operator bool()
const {
entity_type create()
Creates a new entity and returns it.
constexpr auto null
Compile-time constant for null entities.
Entity entity_type
Underlying entity identifier.
basic_registry< Entity > registry_type
Type of registry used internally.
bool has() const
Checks if an actor has the given components.
basic_actor(basic_actor &&other) ENTT_NOEXCEPT
Move constructor.
basic_actor & operator=(basic_actor &&other) ENTT_NOEXCEPT
Move assignment operator.
basic_actor(entity_type entity, registry_type &ref) ENTT_NOEXCEPT
Constructs an actor from a given entity.
entity_type entity() const ENTT_NOEXCEPT
Returns the entity associated with an actor.
void destroy(const entity_type entity)
Destroys an entity and lets the registry recycle the identifier.
virtual ~basic_actor()
Default destructor.
basic_actor(registry_type &ref)
Constructs an actor from a given registry.
decltype(auto) assign(Args &&... args)
Assigns the given component to an actor.
const registry_type & backend() const ENTT_NOEXCEPT
Returns a reference to the underlying registry.
decltype(auto) get() const
Returns references to the given components for an actor.
Fast and reliable entity-component system.
auto try_get() const
Returns pointers to the given components for an actor.
void remove()
Removes the given component from an actor.
bool valid(const entity_type entity) const
Checks if an entity identifier refers to a valid entity.
registry_type & backend() ENTT_NOEXCEPT
Returns a reference to the underlying registry.
auto try_get()
Returns pointers to the given components for an actor.
Dedicated to those who aren't confident with the entity-component-system architecture.