Hello, I’m refactoring a Javascript Game using ECS and I find ecsy really simple and elegant to use (even if it’s experimental).
However, i’m wondering how to pass arguments to System.
For example, i have a CameraSystem which should move the game stage using a followable entity position. How do i pass the ‘stage’ to my CameraSystem ? (I don’t want to make global variable or Singleton i think it hurts the app design)
export class CameraSystem extends System {
execute(delta) {
this.queries.followables.results.forEach(entity => {
// this.stage.pivot.x = ....
});
}
}
CameraSystem.queries = {
followables: {
components: [Position, Followable]
}
}
This one seems to not work : world.registerSystem(CameraSystem, {stage: myStage});
Other bonus questions :
- Is it better to make component extends Component or it does not matter at all ?
- Should i register component into world ? it seems to be useless.
- Is there any plan to fix the VSCode intellisense on ‘this.queries’ that is not known in System ?
Thanks.