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

Reactive Components #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Reactive Components #14

wants to merge 1 commit into from

Conversation

louisponet
Copy link
Owner

@louisponet louisponet commented Oct 27, 2021

This is a trial at integrating some kind of reactivity into the current ECS framework.

As discussed in #11 there are a couple of ways to implement this. For now I've chosen to go for the change tracking component idea. I.e. upon any mutating operation performed, the flag changed will be put to true. In combination with the in_components function that Systems can define, upon calling update_reactive(ledger), all changed components will be found, and the systems which have them as in_components will be updated in the same order as they were specified in the ledger.
This will be done recursively so that any updates will flow through the systems pipeline (if I didn't make mistakes).

Couple further thoughts:

  • As discussed before, this would mean that a change to a single entity will trigger the system to process the entire component. The question is whether this does not fly in the face of the cases when Reactivity is useful such as plotting, when relatively little amount of entities are changed.
  • It would be possible to extend this with an entity buffer that tracks which Entities have actually been changed, which could then be used in the "reactive" system through @changed_entities. I think this would be an elegant and flexible way to solve the Reactivity, while still being true to the ECS philosophy (system acting on components rather than single entities).

Pinging @ffreyer for some more input on this. Let me know what you think!

Cheers

@ffreyer
Copy link
Contributor

ffreyer commented Nov 1, 2021

I haven't really touched an ECS for about half a year so I don't have any useful thoughts on this.

Iirc the problem I originally wanted to solve is dealing with multiple input types. Makie sort of has two versions of this. For example color can be a hex-string, symbol, HSV, RGB, RGBA, etc but also vectors of that. I think the point of grouped components, for me, was dealing with single values vs per-instance values. The point of this was to normalize a bunch of input types into one and to avoid doing unnecessary work.

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

Successfully merging this pull request may close these issues.

2 participants