#1071·Entitas

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

Author: DiscipolCreated Jul 8, 2023Updated Jul 9, 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