R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::wrapper::Entity Class Reference

High-level entity wrapper providing fluent interface. More...

#include <ECSWorld.hpp>

Collaboration diagram for ecs::wrapper::Entity:
Collaboration graph

Public Member Functions

 Entity (Address address, Registry *registry)
 Construct an Entity wrapper.
 
Address getAddress () const
 Get the entity's address.
 
template<typename T >
Entitywith (const T &component)
 Add/set a component to this entity.
 
template<typename T >
T & get ()
 Get a component from this entity.
 
template<typename T >
const T & get () const
 Get a component from this entity (const version).
 
template<typename T >
bool has () const
 Check if this entity has a specific component.
 
template<typename T >
Entityremove ()
 Remove a component from this entity.
 
bool isValid () const
 Check if this entity is valid.
 
 operator Address () const
 Implicit conversion to Address for compatibility.
 

Private Attributes

Address _address
 
Registry_registry
 

Detailed Description

High-level entity wrapper providing fluent interface.

Provides a clean, chainable API for entity operations. Acts as a handle to an entity in the registry.

Examples
/home/ubuntu/actions-runner/_work/rtype/rtype/server/Scripting/LuaBindings/ComponentBindingHelper.hpp.

Definition at line 33 of file ECSWorld.hpp.

Constructor & Destructor Documentation

◆ Entity()

ecs::wrapper::Entity::Entity ( Address  address,
Registry registry 
)

Construct an Entity wrapper.

Parameters
addressThe entity's address in the registry
registryPointer to the ECS registry

Definition at line 37 of file ECSWorld.cpp.

Member Function Documentation

◆ get() [1/2]

◆ get() [2/2]

template<typename T >
const T & ecs::wrapper::Entity::get ( ) const

Get a component from this entity (const version).

Template Parameters
TComponent type
Returns
const T& Const reference to the component
Exceptions
std::runtime_errorif component doesn't exist

◆ getAddress()

Address ecs::wrapper::Entity::getAddress ( ) const

Get the entity's address.

Returns
Address The entity's unique identifier

Definition at line 39 of file ECSWorld.cpp.

References _address.

Referenced by Server::_serializeEntity(), scripting::bindings::bindEntity(), scripting::bindings::bindServerGame(), ecs::wrapper::ECSWorld::destroyEntity(), and server::GameLogic::spawnPlayer().

◆ has()

◆ isValid()

bool ecs::wrapper::Entity::isValid ( ) const

Check if this entity is valid.

Returns
bool true if entity exists in registry

Definition at line 43 of file ECSWorld.cpp.

References _address, _registry, and ecs::Registry::getSignature().

Referenced by scripting::bindings::bindEntity(), scripting::bindings::bindServerGame(), scripting::bindings::bindWorld(), ecs::wrapper::ECSWorld::destroyEntity(), and scripting::LuaSystemAdapter::update().

Here is the call graph for this function:

◆ operator Address()

ecs::wrapper::Entity::operator Address ( ) const

Implicit conversion to Address for compatibility.

Definition at line 57 of file ECSWorld.cpp.

◆ remove()

template<typename T >
Entity & ecs::wrapper::Entity::remove ( )

Remove a component from this entity.

Template Parameters
TComponent type
Returns
Entity& Reference to this entity for chaining
Examples
/home/ubuntu/actions-runner/_work/rtype/rtype/server/Scripting/LuaBindings/ComponentBindingHelper.hpp.

Referenced by scripting::bindings::ComponentBindingHelper::add(), and scripting::bindings::ComponentBindingHelper::registerComponent().

◆ with()

template<typename T >
Entity & ecs::wrapper::Entity::with ( const T &  component)

Add/set a component to this entity.

Template Parameters
TComponent type
Parameters
componentThe component data
Returns
Entity& Reference to this entity for chaining

Referenced by scripting::bindings::bindServerGame(), and server::GameLogic::spawnPlayer().

Member Data Documentation

◆ _address

Address ecs::wrapper::Entity::_address
private

Definition at line 35 of file ECSWorld.hpp.

Referenced by getAddress(), and isValid().

◆ _registry

Registry* ecs::wrapper::Entity::_registry
private

Definition at line 36 of file ECSWorld.hpp.

Referenced by isValid().


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