How do you pass arguments to System

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.

OK I found a problem in World.d.ts that’s why i cannot registerSystem with attributes without intelisense errors :
registerSystem<T extends System>(System:SystemConstructor<T>): this;

it’s a shame because the functionality is here :slight_smile: in the World.js :
registerSystem(System, attributes) {
this.systemManager.registerSystem(System, attributes);
return this;
}

So it works, but intellisense in VSCode with ecsy is bad currently.

I made a PR to fix this problem.