Derived Component States

Hi,

I try to understand (hybrid) ECS and are looking for some best practices. I have some base components, which are used very often, but I am thinking about derived components as well

Selection (IsSelected: boolean) => Selected + Unselected
Focus (IsFocused: boolean) => Focused + Unfocused
Fraction (Fraction: int) => Player + Enemy

It would help to prefilter some components in my systems.

How do you handle it? Can you share some best practices.

You may create Selected, Unselected, Focused, Unfocused, Player and Enemy components. This way you will be able to sort out and filter the entities by these components easily. If you wanna filter out those entities that have either Focused or Unfocused component, you can also add Focus component just to group those

Thanks for the answer. Sometimes I also have to check it in my loop, therefore I would also need the Selection component with the boolean.

Therefore I am asking how you guys handle it.

Same works for Selection. An entity could have Selection + Selected or Selection + Unselected components, and you could find them either way