Non-pipeline component programming

Paul Freund freund.paul at lvl3.org
Thu Feb 6 07:14:42 PST 2014


On Thursday, 6 February 2014 at 13:47:22 UTC, Meta wrote:
> On Thursday, 6 February 2014 at 05:27:22 UTC, Mike Parker wrote:
>> A cursory look at Nitro suggests they are using an ECS with 
>> DOP. Given that they're providing ranges for iterating the 
>> data, it will fit into D's range-based component pipelines 
>> (std.algorithm and such).
>
> That seems cool. I can only imagine the possibilities...
>
> auto shipComponents = components.filter!(a => 
> a.hasComponent!SpaceShip);
>
> foreach (i, spaceship; taskPool.parallel(shipComponents))
> {
>     spaceship.name = format("Ship %i", i);
> }

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.


More information about the Digitalmars-d mailing list