Implementing my Entity System. Questions about some problems I have found.
- by Notbad
Hi!,
Well during this week I have deciding about implementation of my entity system. It is a big topic so it has been difficult to take one option from the whole. This has been my decision:
1) I don't have an entity class it is just an id.
2) I have systems that contain a list of components (the list is homegenous, I mean, RenderSystem will just have RenderComponents).
3) Compones will be just data.
4) There would be some kind of "entity prototypes" in a manager or something from we will create entity instances.Ideally they will define the type of components it has and initialization data.
5) Prototype code to create an entity (this is from the top of my head):
int id=World::getInstance()->createEntity("entity template");
6) This will notify all systems that a new entity has been created, and if the entity needs a component that the system handles it will add it to the entity.
Ok, this are the ideas. Let's see if some can help with the problems:
1) The main problem is this templates that are sent to the systems in creation process to populate the entity with needed components. What would you use, an OR(ed) int?, a list of strings?.
2) How to do initialization for components when the entity has been created? How to store this in the template? I have thought about having a function in the template that is virtual and after entity is created an populated, gets the components and sets initialization values.
3) Don't you think this is a lot of work for just an entity creation?.
Sorry for the long post, I have tried to expose my ideas and finding in order other could have a start beside exposing my problems.
Thanks in advance,
Notbad.