I'm working on adding physics to an Entity System and am confused about the systems part of ECS.
For example, in a non-ECS project I might have something like this:
function updatePhysics()
foreach(thisRobot in robots)
thisRobot.move()
foreach(otherRobot in robots)
if(response = thisRobot.isColliding(otherRobot))
thisRobot.resolveCollision(response)
However in the ECS project, I would have a MovementSystem that operates on a PositionComponent and a VelocityComponent as well as a CollisionSystem that operates on a PositionComponent and a ShapeComponent. The result being something like:
MovementSystem
function update()
foreach(entity in entities)
this.move(entity)
CollisionSystem
function update()
foreach(thisEntity in entities)
foreach(otherEntity in entities)
if(response = this.isColliding(thisEntity, otherEntity)
this.resolve(thisEntity, response)
The difference being that in the non-ECS version the movement and collision are interleaved where as in the ECS version they are seperated. Is there a normal pattern to model this behavior in entity systems? I know the whole point of ECS is to get away from inheritance, but perhaps having both MovementSystem and CollisionSystem be part of a more general PhysicsSystem which calls the other systems update functions on a single entitiy rather than each system maintaining their own loops?