co_ecs 0.9.0
Cobalt ECS
Loading...
Searching...
No Matches
co_ecs::command_writer Class Reference

This class is responsible for writing commands to a command_buffer. More...

#include <command.hpp>

Public Member Functions

 command_writer (registry &reg)
 Constructs a command_writer with a given registry.
 
auto get_entity (entity ent) -> command_entity_ref
 Retrieves a reference to a command entity.
 
template<component... Args>
auto create (Args &&... args) -> command_entity_ref
 Creates a new entity with the given components.
 
void destroy (entity ent)
 Destroys an existing entity.
 

Detailed Description

This class is responsible for writing commands to a command_buffer.

Example

command_writer cmd{reg};
auto e = cmd.create<position>({/* position data */});
e.set<velocity>({/* velocity data */});
reg.get_entity(e).alive(); // true
reg.get_entity(e).has<position, velocity>(); // true
static void flush(registry &registry)
Flushes all commands in the command buffers to the given registry.
Definition command.hpp:27
This class is responsible for writing commands to a command_buffer.
Definition command.hpp:235
Registry is a container for all our entities and components. Components are stored in continuously in...
Definition registry.hpp:13
constexpr auto create(Components &&... args) -> entity_ref
Creates a new entity and attaches the specified components to it.
Definition registry.hpp:39
constexpr auto get_entity(entity ent) noexcept -> entity_ref
Retrieves a mutable reference to an entity.
Definition registry.hpp:51

Constructor & Destructor Documentation

◆ command_writer()

co_ecs::command_writer::command_writer ( registry & reg)
inline

Constructs a command_writer with a given registry.

Parameters
regReference to a registry object.

Member Function Documentation

◆ create()

template<component... Args>
auto co_ecs::command_writer::create ( Args &&... args) -> command_entity_ref
inline

Creates a new entity with the given components.

Template Parameters
ArgsComponent types to be added to the entity.
Parameters
argsComponents to be added to the entity.
Returns
A reference to the newly created command entity.

◆ destroy()

void co_ecs::command_writer::destroy ( entity ent)
inline

Destroys an existing entity.

Parameters
entThe entity to be destroyed.

◆ get_entity()

auto co_ecs::command_writer::get_entity ( entity ent) -> command_entity_ref
inline

Retrieves a reference to a command entity.

Parameters
entThe entity to retrieve.
Returns
A reference to the command entity.

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