@@ -121,10 +121,8 @@ class Entity {
121121 template <typename C>
122122 ptr<C> component ();
123123
124- template <typename A>
125- void unpack (ptr<A> &a);
126- template <typename A, typename B, typename ... Args>
127- void unpack (ptr<A> &a, ptr<B> &b, Args && ... args);
124+ template <typename A, typename ... Args>
125+ void unpack (ptr<A> &a, ptr<Args> & ... args);
128126
129127 /* *
130128 * Destroy and invalidate this Entity.
@@ -347,7 +345,7 @@ class EntityManager : entityx::help::NonCopyable, public enable_shared_from_this
347345 }
348346
349347 template <typename A, typename B, typename ... Args>
350- View &unpack_to (ptr<A> &a, ptr<B> &b, Args & & ... args) {
348+ View &unpack_to (ptr<A> &a, ptr<B> &b, ptr< Args> & ... args) {
351349 unpack_to<A>(a);
352350 return unpack_to<B, Args ...>(b, args ...);
353351 }
@@ -515,27 +513,17 @@ class EntityManager : entityx::help::NonCopyable, public enable_shared_from_this
515513 }
516514
517515 /* *
518- * Find Entities that have all of the specified Components.
516+ * Find Entities that have all of the specified Components and assign them
517+ * to the given parameters.
519518 */
520519 template <typename C, typename ... Components>
521- View entities_with_components (ptr<C> &c, Components & & ... args) {
520+ View entities_with_components (ptr<C> &c, ptr< Components> & ... args) {
522521 auto mask = component_mask (c, args ...);
523522 return
524523 View (shared_from_this (), View::ComponentMaskPredicate (entity_component_mask_, mask))
525524 .unpack_to (c, args ...);
526525 }
527526
528- /* *
529- * Unpack components directly into pointers.
530- *
531- * Components missing from the entity will be set to nullptr.
532- *
533- * Useful for fast bulk iterations.
534- *
535- * ptr<Position> p;
536- * ptr<Direction> d;
537- * unpack<Position, Direction>(e, p, d);
538- */
539527 template <typename A>
540528 void unpack (Entity::Id id, ptr<A> &a) {
541529 a = component<A>(id);
@@ -552,10 +540,10 @@ class EntityManager : entityx::help::NonCopyable, public enable_shared_from_this
552540 * ptr<Direction> d;
553541 * unpack<Position, Direction>(e, p, d);
554542 */
555- template <typename A, typename B, typename ... Args>
556- void unpack (Entity::Id id, ptr<A> &a, ptr<B> &b, Args & & ... args) {
557- unpack <A>(id, a );
558- unpack<B, Args ...>(id, b , args ...);
543+ template <typename A, typename ... Args>
544+ void unpack (Entity::Id id, ptr<A> &a, ptr<Args> & ... args) {
545+ a = component <A>(id);
546+ unpack<Args ...>(id, args ...);
559547 }
560548
561549 /* *
@@ -582,7 +570,7 @@ class EntityManager : entityx::help::NonCopyable, public enable_shared_from_this
582570 }
583571
584572 template <typename C1, typename C2, typename ... Components>
585- ComponentMask component_mask (const ptr<C1> &c1, const ptr<C2> &c2, Components & & ... args) {
573+ ComponentMask component_mask (const ptr<C1> &c1, const ptr<C2> &c2, ptr< Components> & ... args) {
586574 return component_mask<C1>(c1) | component_mask<C2, Components ...>(c2, args...);
587575 }
588576
@@ -649,16 +637,10 @@ ptr<C> Entity::component() {
649637 return manager_.lock ()->component <C>(id_);
650638}
651639
652- template <typename A>
653- void Entity::unpack (ptr<A> &a) {
654- assert (valid ());
655- manager_.lock ()->unpack (id_, a);
656- }
657-
658- template <typename A, typename B, typename ... Args>
659- void Entity::unpack (ptr<A> &a, ptr<B> &b, Args && ... args) {
640+ template <typename A, typename ... Args>
641+ void Entity::unpack (ptr<A> &a, ptr<Args> & ... args) {
660642 assert (valid ());
661- manager_.lock ()->unpack (id_, a, b, args ...);
643+ manager_.lock ()->unpack (id_, a, args ...);
662644}
663645
664646} // namespace entityx
0 commit comments