sschmid / Entitas

Entitas is a super fast Entity Component System (ECS) Framework specifically made for C# and Unity
MIT License
7.03k stars 1.11k forks source link

Struct vs Class Components #1000

Closed mororo250 closed 1 year ago

mororo250 commented 2 years ago

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?

sschmid commented 2 years ago

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 commented 1 year ago

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

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