Component based Entity System

Hi everyone.

Lastly i have been reading articles about component based entity system checking what other people have already done and experienced.

While the main logic (if i did not misunderstand) is creating component classes which are inheriting an abstract base component class. Also entity classes inheriting the abstract Entity class and the components' classes they need.

But some people recommends that instead of creating entities with inheritance, they advice creating an entity manager class which creates, adds and removes components and such without using inheritance. They say this way is much cleaner and easy to use.

What do you think about the advice? Thinking it will written in C++, would it be more efficient and easy?
Last edited on
But some people recommends that instead of creating entities with inheritance, they advice creating an entity manager class which creates, adds and removes components and such without using inheritance.
This is a well discussed issue. Using UML speak, what you call inheritance is called generalization, and what you call without using inheritance is called aggregation.

I suggest you search "generalization vs aggregation" to see what has been said before.
Thanks @kbw. I will start searching right away.
I researched a lot and i got a question.

It seems what i am going to use is composition but isn't both inheriting and adding it via function to an entity is called "composition". Since both does not owns components(you do not destroy component class when neither you removed inheritance nor removed added component).

My question was which method of adding a component to choose? Inheritance or via Entity manager is better?

Sorry if i misunderstood anything and thanks for the answer in advance.
but isn't both inheriting and adding it via function to an entity is called "composition"
No, that's generalization.

My question was which method of adding a component to choose? Inheritance or via Entity manager is better?
That's s different question.

My view is always do the simplest and most obvious thing. Only add complexity on demand.

If you need a manager, use one; if you don't, don't.
Well, thanks for the answer @kbw. It seems even a three hours research did not help me much.

Though i do not fully understand which is called what, however i started to understand how to implement one and i guess i will choose to make an Entity Manager.
Last edited on
Topic archived. No new replies allowed.