Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to disable a system #5

Closed
getkey opened this issue Nov 2, 2017 · 1 comment
Closed

Ability to disable a system #5

getkey opened this issue Nov 2, 2017 · 1 comment

Comments

@getkey
Copy link

getkey commented Nov 2, 2017

Here is my (hypothetical, not actually implemented) simplified use case: in my game, when you click a button, all my physical entities explode, which results in their positions being modified.
To achieve this, I create an entity whenever I receive the event of the click of the button, with a component that marks that all entities should explode.
I have a system that reacts to this entity. When it's present, it creates an ExplosionSystem which is responsible for updating the physical entities' positions. If it's not present, and the system is known by ECS, it removes it.

This approach has a few shortcomings:

  1. the eligibility of components to the ExplosionSystem is lost when you remove it, which is bad for performance
  2. the ExplosionSystem is not reusable, and is needlessly recreated
  3. the ExplosionSystem can only be added after all the other systems

This is my example, but it can be generalized to any case where an event results into the update of multiple different components.

It seems to me that if you were able to do mySystem.disable() and mySystem.enable(), all those problems would disappear. It would just be a matter of setting a flag on the disabled systems and checking that it's not present when updating the systems.

It's my first time using ECS, so maybe there is a better approach. I heard about it in this video about Entitas.

@getkey
Copy link
Author

getkey commented Nov 8, 2017

See #6.

@getkey getkey closed this as completed Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant