Object-Oriented Entity-Component-System Design
Where ECS gets muddy for me is when you have systems working on entities with multiple types of components at once.<p>* physics - position component + physics component<p>* rendering - position component + animation component<p>* etc..<p>How do we now store these components? How do we create &#x2F; access aggregates efficiently?<p>If we have two arrays then there is lots of hopping around:<p><pre><code>    PositionComponent[] 
    PhysicsComponent[]
</code></pre>
Maybe we need some kind of grouping class?<p><pre><code>    struct EntityData {
      PositionComponent position; &#x2F;&#x2F; Null if not a position entity
      PhysicsComponent physics; &#x2F;&#x2F; Null if not a physics entity
    }
</code></pre>
Interfaces have their issues too, but at least it&#x27;s fairly clear what to do:<p><pre><code>    class BouncyBall : IHasPosition, IHasPhysics {
      IPosition getPosition() {
        &#x2F;&#x2F; ...
      }

      IPhysics getPhysics() {
        &#x2F;&#x2F; ...
      }
    }
</code></pre>
Anyone solved this before?