Question

In the last days I have found the componed based entity system. I think i understand and know how it works, but if I try to implement it, I get a lot of problems. Here a diagram with the most Problems: http://s7.directupload.net/file/d/3327/pzy7kanj_jpg.htm And I wonder me, can I add the same component twice to an entity, or should I dont allow this? If no, how I can add multiple sprites to an Entity? And if a make a CollisionComponent or a Physik Component, the Physik and the MoveComponent must communicate, right ? I hope anyone can me help.

Here I have made another diagram, from Ideas: http://s1.directupload.net/images/130725/5p83qysu.jpg

Was it helpful?

Solution

Ok there seem to be a lot of related questions between this post and the diagrams you linked to. The answer to these questions are 'it depends.' and I am guessing you would like some guidance on the subject of CBSEs rather than one line answers to all of your questions. Rather than try and regurgitate the discussion based on similar queries I will post some links here that should get you thinking more about these issues.

First there is the ES wiki. This wiki is still in its infancy, but it holds some great discussion on entity systems.

Next, there some really productive discussion over at gamedev stack exchange (maybe this question should be moved there as well). First take a look at this question, it's a good starting point because it explains why there are no clear trends in ES design (when that answer was written) and from what I've seen it still holds true today. Then there is an absolutely amazing answer given by Byte56 that explains the basics of the system-component approach extremely well, and is well worth reading even if you think you've already got a handle on it. Next there is a helpful series of questions asked by Yannbane. These questions address some of the finer points in more detail. Here are all three questions. Also, there are some questions on how to integrate input and Game States.

Finally, you should check out some open source entity systems that have had a lot of attention such as Artemis written in Java (There seems to be a server issue right now for that link but this article is a good intro, and there are c# and c++ repositories available, so you can dig into some code). There is also ash written in AS3.

Now I feel I must answer one of your questions directly:

And if a make a CollisionComponent or a Physik Component, the Physik and the MoveComponent must communicate, right ?

From the diagrams you linked to you seem to be using the systems-based approach (similar to artemis). From my reading I believe that this is one area that has been generally agreed on by the community: in the system approach the idea is to centralize the component logic so that (aside from a few simple methods as mentioned in the answer to Yannabe's second question) the component is little more than a data container. So if your components are stored in entities then your systems are required to sift through all of your entities. The systems that require more than one component should be asking each entity for all the components it needs to do its work. If it doesn't find all of those components the system should move on. So based on what you have decided so far the answer is no, components should not be communicating with eachother.

Anyway, good luck on this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top