GGAlanSmithee / Entities

efficient and easy-to-use Entity-Component System in JavaScript
http://ggalansmithee.github.io/Entities/
MIT License
4 stars 1 forks source link

Do not bind systems to the entityManager instance #108

Open GGAlanSmithee opened 5 years ago

GGAlanSmithee commented 5 years ago

Since a user can pass any options in the opts param when invoking a system, there is no longer any need to bind the EntityManager instance as the this argument to registered systems.

To achieve the old behavior, a user can simply:

entityManager.registerLogicSystem(key, (entities, { entityManager }) => {
   for (const entity of entities) {
       // do something using the entityManager
   }
})

// later ...

entityManager.onLogic({ entityManager })

This will remove one of the most annoying gotchas in the current API.