Last weekend, I spent several hours writing a basic entity component model, in JavaScript. I was largely referencing the Ash Actionscript game engine. I successfully worked out how the systems, components, nodes, and entities all link up, but one thing that eludes me is how to implement the "watcher" that checks the entities for their components, creates nodes for them, adds those nodes to the various systems automatically, and watches for any changes in the components on an entity. I was a bit confused by the way it works, in Ash, and all of the posts and tutorials on the subject that I have read seem to forgo the details of that part of the implementation.
Right now, I currently have the following:
- Entity, which is assigned components.
- Engine, which keeps a track of the systems and entities.
- Node, which contains references to the components in an entity that we want the system to modify (I am currently creating these, manually, and adding it to the system).
- Component, which contains the data to be modified by the system.
- System, which operates on the nodes, which in turn change the data in the entity.
- I also have various other classes, dedicated to holding lists of the various objects.
How do I go about creating the "Watcher" component?