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

A component with multiple contexts +events, only make event listeners for 1 context #1071

Open
Discipol opened this issue Jul 8, 2023 · 0 comments

Comments

@Discipol
Copy link

Discipol commented Jul 8, 2023

The problem is that the interfaces for listeners need to mention the type of the entity/context, and if you have two contexts, you would basically create the same class twice(or more), but each copy would have a different SOMETHINGEntity

Example"

[App, Game] //Two contexts
[Event(EventType.Any)]
public sealed CheeseComponent : IComponent {}

Proposition 1:
If more than 1 context, create them as IAnyAppCheeseAddedListener + IAnyGameCheeseAddedListener
Autocomplete will make it very easy to adapt. You could also make this change for 1 context, to put that context name in there always.

Proposition 2:
IAnyCheeseAddedListener< T > where T : Entity
We can't limit it to AppEntity / GameEntity as far as I know as "where T" does not allow A-or-B.
The method that implements the interface would use T

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

No branches or pull requests

1 participant