On Friday, 7 February 2014 at 08:09:10 UTC, Mike Parker wrote:
On 2/7/2014 12:14 AM, Paul Freund wrote:
You're example almost works. With the EntityComponentManager
API it
works like this:
auto shipEntities = ecm.query!SpaceShip();
foreach (i, spaceship; taskPool.parallel(shipEntities))
{
auto shipData = spaceship.getComponent!SpaceShip();
shipData.name = format("Ship %i", i);
}
Now that unittests are written, documentation is on its way
and should
be ready in a few days.
Ah, so there's no data-orientation here. It's strictly
entity-centric. Or do you have a way to iterate components
independently of entities?
There will be a way to iterate directly over components.
Component fields will automatically be split into an structure of
arrays.
So let's assume we have:
struct Point {int x; int y; int z; }
@Component struct Translation { int a; Point b; Point c; }
Nitro will store Translation like this, so it is even possible to
iterate over parts of components:
Entity[]
int[] for a
int[] for b.x
int[] for b.y
int[] for b.z
int[] for c.x
int[] for c.y
int[] for c.z
Nitros getComponent functions will return Accessor!Translation,
so if you do this, only int[] for b.x is accessed.
foreach(e; ecs.query!Translation)
{
auto trans = e.getComponent!Translation();
trans.b.x = 0;
}