OpenLexocad  28.0
entt::basic_actor Struct Reference

Dedicated to those who aren't confident with the entity-component-system architecture. More...

#include <entt.hpp>

Public Types

using registry_type = basic_registry< Entity >
 Type of registry used internally. More...
 
using entity_type = Entity
 Underlying entity identifier. More...
 

Public Member Functions

 basic_actor () ENTT_NOEXCEPT
 
 basic_actor (registry_type &ref)
 Constructs an actor from a given registry. More...
 
 basic_actor (entity_type entity, registry_type &ref)
 Constructs an actor from a given entity. More...
 
virtual ~basic_actor ()
 Default destructor. More...
 
 basic_actor (basic_actor &&other)
 Move constructor. More...
 
basic_actoroperator= (basic_actor &&other)
 Move assignment operator. More...
 
template<typename Component , typename... Args>
decltype(auto) assign (Args &&... args)
 Assigns the given component to an actor. More...
 
template<typename Component >
void remove ()
 Removes the given component from an actor. More...
 
template<typename... Component>
bool has () const ENTT_NOEXCEPT
 Checks if an actor has the given components. More...
 
template<typename... Component>
decltype(auto) get () const ENTT_NOEXCEPT
 Returns references to the given components for an actor. More...
 
template<typename... Component>
decltype(auto) get () ENTT_NOEXCEPT
 Returns references to the given components for an actor. More...
 
template<typename... Component>
auto try_get () const ENTT_NOEXCEPT
 Returns pointers to the given components for an actor. More...
 
template<typename... Component>
auto try_get () ENTT_NOEXCEPT
 Returns pointers to the given components for an actor. More...
 
const registry_typebackend () const ENTT_NOEXCEPT
 Returns a reference to the underlying registry. More...
 
registry_typebackend () ENTT_NOEXCEPT
 Returns a reference to the underlying registry. More...
 
entity_type entity () const ENTT_NOEXCEPT
 Returns the entity associated with an actor. More...
 
 operator bool () const ENTT_NOEXCEPT
 Checks if an actor refers to a valid entity or not. More...
 

Detailed Description

Dedicated to those who aren't confident with the entity-component-system architecture.

Tiny wrapper around a registry, for all those users that aren't confident with entity-component-system architecture and prefer to iterate objects directly.

Template Parameters
EntityA valid entity type (see entt_traits for more details).

Member Typedef Documentation

◆ entity_type

Underlying entity identifier.

◆ registry_type

Type of registry used internally.

Constructor & Destructor Documentation

◆ basic_actor() [1/4]

entt::basic_actor::basic_actor ( )
inline

◆ basic_actor() [2/4]

entt::basic_actor::basic_actor ( registry_type ref)
inlineexplicit

Constructs an actor from a given registry.

Parameters
refAn instance of the registry class.

◆ basic_actor() [3/4]

entt::basic_actor::basic_actor ( entity_type  entity,
registry_type ref 
)
inlineexplicit

Constructs an actor from a given entity.

Parameters
entityA valid entity identifier.
refAn instance of the registry class.

◆ ~basic_actor()

virtual entt::basic_actor::~basic_actor ( )
inlinevirtual

Default destructor.

◆ basic_actor() [4/4]

entt::basic_actor::basic_actor ( basic_actor &&  other)
inline

Move constructor.

After actor move construction, instances that have been moved from are placed in a valid but unspecified state. It's highly discouraged to continue using them.

Parameters
otherThe instance to move from.

Member Function Documentation

◆ assign()

template<typename Component , typename... Args>
decltype(auto) entt::basic_actor::assign ( Args &&...  args)
inline

Assigns the given component to an actor.

A new instance of the given component is created and initialized with the arguments provided (the component must have a proper constructor or be of aggregate type). Then the component is assigned to the actor.
In case the actor already has a component of the given type, it's replaced with the new one.

Template Parameters
ComponentType of the component to create.
ArgsTypes of arguments to use to construct the component.
Parameters
argsParameters to use to initialize the component.
Returns
A reference to the newly created component.

◆ backend() [1/2]

const registry_type& entt::basic_actor::backend ( ) const
inline

Returns a reference to the underlying registry.

Returns
A reference to the underlying registry.

◆ backend() [2/2]

registry_type& entt::basic_actor::backend ( )
inline

Returns a reference to the underlying registry.

Returns
A reference to the underlying registry.

◆ entity()

entity_type entt::basic_actor::entity ( ) const
inline

Returns the entity associated with an actor.

Returns
The entity associated with the actor.

◆ get() [1/2]

template<typename... Component>
decltype(auto) entt::basic_actor::get ( ) const
inline

Returns references to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
References to the components owned by the actor.

◆ get() [2/2]

template<typename... Component>
decltype(auto) entt::basic_actor::get ( )
inline

Returns references to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
References to the components owned by the actor.

◆ has()

template<typename... Component>
bool entt::basic_actor::has ( ) const
inline

Checks if an actor has the given components.

Template Parameters
ComponentComponents for which to perform the check.
Returns
True if the actor has all the components, false otherwise.

◆ operator bool()

entt::basic_actor::operator bool ( ) const
inlineexplicit

Checks if an actor refers to a valid entity or not.

Returns
True if the actor refers to a valid entity, false otherwise.

◆ operator=()

basic_actor& entt::basic_actor::operator= ( basic_actor &&  other)
inline

Move assignment operator.

After actor move assignment, instances that have been moved from are placed in a valid but unspecified state. It's highly discouraged to continue using them.

Parameters
otherThe instance to move from.
Returns
This actor.

◆ remove()

template<typename Component >
void entt::basic_actor::remove ( )
inline

Removes the given component from an actor.

Template Parameters
ComponentType of the component to remove.

◆ try_get() [1/2]

template<typename... Component>
auto entt::basic_actor::try_get ( ) const
inline

Returns pointers to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
Pointers to the components owned by the actor.

◆ try_get() [2/2]

template<typename... Component>
auto entt::basic_actor::try_get ( )
inline

Returns pointers to the given components for an actor.

Template Parameters
ComponentTypes of components to get.
Returns
Pointers to the components owned by the actor.

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