EC::Manager must be created with a list of all used Components and all used tags.
+ Note that all components must have a default constructor.
+
Example:
\code{.cpp}
EC::Manager<TypeList<C0, C1, C2>, TypeList<T0, T1>> manager;
\code{.cpp}
struct C0
{
- C0(int a, char b) : a(a), b(b)
+ // constructor is compatible as a default constructor
+ C0(int a = 0, char b = 'b') :
+ a(a), b(b)
{}
int a;
#include <EC/EC.hpp>
struct C0 {
+ C0(int x = 0, int y = 0) :
+ x(x),
+ y(y)
+ {}
+
int x, y;
};
struct C1 {
std::size_t e0 = manager.addEntity();
std::size_t e1 = manager.addEntity();
- manager.addComponent<C0>(e0);
+ manager.addComponent<C0>(e0, 5, 5);
manager.addComponent<C1>(e0);
manager.addComponent<C0>(e1);
manager.addComponent<C1>(e1);
manager.addTag<T0>(e1);
- {
- auto& pos = manager.getEntityData<C0>(e0);
- pos.x = 5;
- pos.y = 5;
- }
-
{
auto& vel = manager.getEntityData<C1>(e0);
vel.vx = 1;