Slight change to unit tests, docs
Unit test now creates Component with Manager::addComponent.
This commit is contained in:
parent
a28a68cc65
commit
aa05522772
2 changed files with 11 additions and 8 deletions
|
@ -253,6 +253,8 @@ namespace EC
|
|||
|
||||
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;
|
||||
|
@ -349,7 +351,9 @@ namespace EC
|
|||
\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;
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
#include <EC/EC.hpp>
|
||||
|
||||
struct C0 {
|
||||
C0(int x = 0, int y = 0) :
|
||||
x(x),
|
||||
y(y)
|
||||
{}
|
||||
|
||||
int x, y;
|
||||
};
|
||||
struct C1 {
|
||||
|
@ -60,19 +65,13 @@ TEST(EC, Manager)
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue