|
libecs-cpp 2.1.0
Entity Component System library in C++
|
Base class for the data attached to an entity. More...
#include <Component.hpp>
Public Member Functions | |
| Component ()=default | |
| Creates a component with an empty Type and EntityHandle. | |
| Component (const nlohmann::json &) | |
| Creates a component from a configuration, which the base class does not read. | |
| virtual nlohmann::json | Export () const =0 |
| Describes the component as JSON; every subclass implements it. | |
| virtual | ~Component ()=default |
| Destroys the component. | |
Public Attributes | |
| std::string | Type |
| The type name the component is stored and looked up under, for example "PositionComponent". | |
| std::string | EntityHandle |
| The handle of the entity the component is attached to. | |
Base class for the data attached to an entity.
A subclass sets Type in its constructor and implements Export(). A component has no handle of its own: it is addressed by its entity (EntityHandle) and its type name (Type). Attach it with Entity::Component() and look it up with Entity::ComponentGet() or Container::ComponentGet().
Thread: container thread only. A component lives in its container's tables, so it must be used and changed from the thread that drives the container (see Container).
|
default |
Creates a component with an empty Type and EntityHandle.
|
inline |
Creates a component from a configuration, which the base class does not read.
A subclass reads from it whatever it needs. The constructor is not explicit, so a component that forwards its configuration to the base compiles.
|
virtualdefault |
Destroys the component.
|
pure virtual |
Describes the component as JSON; every subclass implements it.
| std::string ecs::Component::EntityHandle |
The handle of the entity the component is attached to.
Entity::Component() sets it; Container::Component() reads it.
| std::string ecs::Component::Type |
The type name the component is stored and looked up under, for example "PositionComponent".
A subclass sets it in its constructor. A component with an empty Type is rejected when it is attached.