Am I doing this right: using context to add systems #1031
-
Hello,
Everything is working as expected, so it is all good. I just want to make sure that adding system to registry through the context is a valid solution, or if there is another more appropriate way. thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think this is a matter of tastes. In my case, all systems are plain free functions. No need to register them anywhere. bool my_scene::update(const renderer &renderer) {
imgui_system(registry);
rmlui_context->Update();
// ....
scene_system(renderer, registry, owner());
return true;
} However, this isn't the first time I've heard of systems being registered with the registry. So I guees it works too. |
Beta Was this translation helpful? Give feedback.
-
It all comes down to what you want to accomplish. Do you want to be able add and remove systems at runtime? Then this approach will not suffice. You might want to consider a separate class that manages systems polymorphically (*) Are all systems known at compile time? Your approach might work, but is there any benefit to doing this over just declaring your systems on the stack and executing them in the correct order? Another aspect you might want to think about is whether your want all your systems to be freely accessible from inside any individual system, because that's essentially what you are doing. My generalized advice would be that the chance is high that doing this is ill-advised. But you might have a strong case for it. (*) the polymorphic approach might look something like this:
Systems would be an object that lives separate from your registry. |
Beta Was this translation helpful? Give feedback.
I think this is a matter of tastes. In my case, all systems are plain free functions. No need to register them anywhere.
The update function of a scene looks like this:
However, this isn't the first time I've heard of systems being registered with the registry. So I guees it works too.
I strongly prefer to flip the problem on its head because I want each scene to be able to choose to have one, ten, or a hundred registries as well as none at all and just work without a registry (for example, imagine a credit…