the Nexus is the brain of the ECS world. It is the object the user will use to interact with everything ECS related within systems.
More...
#include <Imago/ECS/Nexus.hpp>
|
|
| Nexus () |
| | Construct a new Nexus object and instantiates the command buffer.
|
|
| Nexus (const Nexus &)=delete |
|
Nexus & | operator= (const Nexus &)=delete |
|
| Nexus (Nexus &&)=delete |
|
Nexus & | operator= (Nexus &&)=delete |
| Entity | create () |
| | Creates a new Entity.
|
| void | destroy (Entity e) |
| | Destroys an Entity and removes it from every component pool it is in.
|
| bool | is_valid (Entity e) const |
| | Checks whether an Entity is still valid.
|
| template<typename T> |
| void | bind (Entity e, T component) |
| | Binds a component of type T to Entity e.
|
| template<typename T> |
| void | unbind (Entity e) |
| | Unbinds a component of type T from Entity e if possible.
|
| template<typename T> |
| void | patch (Entity e, T component) |
| | Overwrites an Entity's existing component of type T with new component data.
|
| template<typename T> |
| T & | get (Entity e) |
| | Returns a reference to the Entity's component of type T.
|
| template<typename T> |
| T * | try_to_get (Entity e) |
| | Returns a reference to the Entity's component of type T if it has it and nullptr otherwise.
|
| template<typename T> |
| bool | has (Entity e) |
| | Check whether an Entity currently has a component of type T.
|
| template<typename... Components> |
| SurveyHandle< Components... > | survey () |
| | Returns a survey of the specified components.
|
| template<typename... Components> |
| BondHandle< Components... > | bond () |
| | Does one of three things depending on the current state of Bonds already in the Nexus:
|
|
void | flush () |
| | calls _commandBuffer.flush() to call the immediate methods that actually apply the deferred changes that the CommandBuffer is storing
|
the Nexus is the brain of the ECS world. It is the object the user will use to interact with everything ECS related within systems.
It handles:
- creating/destroying entities
- binding/unbinding components
- returning and creating bonds and surveys
◆ bind()
template<typename T>
| void Imago::ECS::Nexus::bind |
( |
Entity | e, |
|
|
T | component ) |
Binds a component of type T to Entity e.
- Bind<T>(e, component) creates or fetches a pool for component type T depending on if it already exists or not.
- Binding a component to an Entity that already has that component will flag a warning and do nothing, replacing component data must be done through Patch<T>()
- This is a structual change so it is automatically routed to the command buffer and the change is actually made in bind_immediate at the end of the current frame.
- Template Parameters
-
| T | The component type to bind. |
- Parameters
-
| e | The entity to bind the component to. |
| component | The actual component data to bind |
◆ bond()
template<typename... Components>
| BondHandle< Components... > Imago::ECS::Nexus::bond |
( |
| ) |
|
Does one of three things depending on the current state of Bonds already in the Nexus:
- Returns a BondHandle (a view of the Bond) if one already exists for the components
- Creates a Bond if possible for those components and returns its BondHandle
- Asserts in debug or std::aborts in release if a Bond cannot be created for those component types
- Template Parameters
-
- Returns
- The BondHandle of bonded components
◆ create()
| Entity Imago::ECS::Nexus::create |
( |
| ) |
|
Creates a new Entity.
- Returns
- The Entity packed uint32_t that was just created
◆ destroy()
| void Imago::ECS::Nexus::destroy |
( |
Entity | e | ) |
|
Destroys an Entity and removes it from every component pool it is in.
This is a structual change so it is automatically routed to the command buffer and the change is actually made in destroy_immediate at the end of the current frame.
- Parameters
-
◆ get()
template<typename T>
| T & Imago::ECS::Nexus::get |
( |
Entity | e | ) |
|
Returns a reference to the Entity's component of type T.
Get<T>(e) assumes e has that component type and should be used only in Surveys/Bonds where the entity is already guaranteed to have that component. See try_to_get<T>(e) for a safer version
- Template Parameters
-
| T | The component type to return |
- Parameters
-
| e | The entity whose component to return |
◆ has()
template<typename T>
| bool Imago::ECS::Nexus::has |
( |
Entity | e | ) |
|
Check whether an Entity currently has a component of type T.
- Template Parameters
-
| T | The component type to check for. |
- Parameters
-
| e | The Entity to check for the component. |
- Returns
- Whether or not the Entity has the component
◆ is_valid()
| bool Imago::ECS::Nexus::is_valid |
( |
Entity | e | ) |
const |
Checks whether an Entity is still valid.
- Parameters
-
- Returns
- whether or not the Entity is valid
◆ patch()
template<typename T>
| void Imago::ECS::Nexus::patch |
( |
Entity | e, |
|
|
T | component ) |
Overwrites an Entity's existing component of type T with new component data.
The Entity must already have this component bound. See Bind<T>() for adding a brand new component
- Template Parameters
-
| T | The component type to patch. |
- Parameters
-
| e | The Entity whose component to patch. |
| component | The actual new component data. |
◆ survey()
template<typename... Components>
Returns a survey of the specified components.
- Template Parameters
-
- Returns
- The SurveyHandle of the queried components
◆ try_to_get()
template<typename T>
| T * Imago::ECS::Nexus::try_to_get |
( |
Entity | e | ) |
|
Returns a reference to the Entity's component of type T if it has it and nullptr otherwise.
- Template Parameters
-
| T | The component type to return |
- Parameters
-
| e | The Entity whose component to return |
- Returns
- Pointer to the component if the Entity has the component
-
nullptr if the Entity does not have the component
◆ unbind()
template<typename T>
| void Imago::ECS::Nexus::unbind |
( |
Entity | e | ) |
|
Unbinds a component of type T from Entity e if possible.
This is a structual change so it is automatically routed to the command buffer and the change is actually made in unbind_immediate at the end of the current frame.
- Template Parameters
-
| T | The component type to unbind. |
- Parameters
-
| e | The entity to unbind the component from. |
The documentation for this class was generated from the following files:
- engine/include/Imago/ECS/Nexus.hpp
- engine/src/ECS/Nexus.cpp