Skip to content

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

@Discipol

Description

@Discipol

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions