Entitas icon indicating copy to clipboard operation
Entitas copied to clipboard

Struct vs Class Components

Open mororo250 opened this issue 3 years ago • 1 comments

Hi, started using entitas and I am loving it.

I have some questions, though.

Are there any performance differences to declare a component as a struct or as a class? If I have a component that is part of different contexts. Does entitas store it continually? Something like:

readonly IGroup<GameEntity> Group1 = _context.game.GetGroup(GameMatcher.Position2D);
readonly IGroup<InputEntity> Group2 = _contexts.input.GetGroup(InputMatcher.Position2D);

Also, do we have something like a multi group? A group with entities of different contexts?

mororo250 avatar Jun 23 '22 17:06 mororo250

Hi @mororo250 In Entitas use classes for components. Components are pooled and reused.

Groups are restricted to 1 context type only. Maybe a MultiReactiveSystem can help you, not sure what your use-case is

sschmid avatar Jul 06 '22 12:07 sschmid

@mororo250 btw, very happy to hear that you like it :D

Will close, feel free to reopen, if there's anything else

sschmid avatar Aug 25 '22 21:08 sschmid