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

Add event subscription #16

Open
jamesaorson opened this issue Aug 2, 2020 · 2 comments
Open

Add event subscription #16

jamesaorson opened this issue Aug 2, 2020 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@jamesaorson
Copy link
Contributor

Events should do more than just execute a function associated with them. Events also should inform relevant parts of the game engine of what just occurred.

The event system should simply post events out for the rest of the engine to pick up.

Example: The Render2dSystem would subscribe to ComponentAdded and ComponentRemoved events for SpriteComponents and TextComponents to know how to manage the actual creation and deletion of these Components.

@jamesaorson jamesaorson added enhancement New feature or request help wanted Extra attention is needed labels Aug 2, 2020
@RogueMacro
Copy link
Contributor

Suggestion: We could have some virtual methods in the base entity class that gets called when components are added, modified, or removed. Elsewhere, layers would receive and handle these events.

@jamesaorson
Copy link
Contributor Author

Suggestion: We could have some virtual methods in the base entity class that gets called when components are added, modified, or removed. Elsewhere, layers would receive and handle these events.

Depends on how we want to treat the entity class. In ECS, generally you want the entity to be as minimal as possible. Literally in most cases, an entity is strictly an ID. No other data or logic associated with it.

We could go down this route of giving the entity class some logic. I did this in Komodo, and I was able to manage the object lifetimes safely and easily. If we have the EventDispatcher calling these virtual methods on the proper entity, then that could totally work!

We may not need specifically a "subscription" event model then if we go all in on defining events and letting the dispatch handle them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants