Why can't I get a ComponentGroup/a subset of entities from EntityManager? (Out of ComponentSystem)

In the code where it is still not ECS I would like to get all the entities with some component like [Inject] can do. And then probably dispose them because I see EntityManager.DestroyEntity has one overload which takes a component group.

  • The problem is GetComponentGroup, the only way I found to create one, is the member method of ComponentSystem. What can I do outside of it? What’s left is only EntityManager.GetAllEntities

  • The temporary solution right now is I have that code remember all the Entity it spawn and destroy them using those remembered ID. But this is unwieldly and my true intent is to “just destroy all the things with a certain component” and not having to remember.

You could expose an API through the ComponentSystem, but generally i would recommend just moving the code that deals with ComponentGroup into ComponentSystem.

1 Like