Jump to content
  • Advertisement
Sign in to follow this  
GenuineXP

(More) Component Based Design Questions

This topic is 4096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I made an earlier post asking about component based design schemes and found a lot of answers in the replies and additional links. I'm still a little unclear with a few things, however. I've been able to hash up what seems to be a reasonable working system, but I wanted to try and take it a step further from a small maze game example to a more advanced project I've been planning. One thing I'm unsure about is how generic components ought to be. At first, I thought components would completely eliminate the rigidity of just about any design, but it occurs to me now that the rigidity of a typical glob object hierarchy is simply moved into the component hierarchy. This is still good, because while components may be limited and somewhat specific, you can still construct entities from data on the fly as well as mix, match, and configure components to add very new and different objects. So, how specific should components get? Say I want to have some sort of spaceships in my game. Spaceships have a hull and shielding system. To eliminate the need of tons of minimal entities, I'd like to be able to construct such a ship from one entity (rather than creating a spaceship entity, a hull entity, a shielding entity, etc.). How would I go about designing said components? Should I actually create some sort of spaceship component? A hull component and shielding component, perhaps? Just how closely should the components model the game? My guess at the moment is that components tend to be tightly bound to the design of the game. This makes sense after all, otherwise the entire design would be generic and development would come crashing down when specific behavior is needed (and it always is, of course). In the (small) tutorials and articles I've found on the net, the authors were indeed very generic, and I think this may be misleading. I get the feeling that in application components can't remain as generic as position, movement, physics, collision, and scripting, though those are all very viable families of components. Any comments are appreciated. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
You'll eventually realize that component model is inadequate, and why these type of frameworks use "Component/Container" term to describe the architecture.

Such frameworks define a component through a set of properties and operations. Independent of that, there is a containment hierarchy.

Through different needs, the containment hierarchy can be fixed, or generated on the fly, static or dynamic, it might have rules on what may be placed where, and so on...

This type of problems was studied for enterprise-grade software due to their low coupling. The relations between components are generally abstracted through policies or contracts and components themself tend to be somewhat self-sufficient pieces of code that are executed by application servers.

The components mentioned in relation to games are just a very small piece of such approach.

Share this post


Link to post
Share on other sites
So you're saying that one entity class may not be enough for storing components? Is this usually the case?

In my spaceship example, would it be a better design choice to create a hierarchy of container classes (entities) where one is a spaceship (or more generic cousin) rather than creating very spaceship specific components?

If an entity hierarchy is needed, I suppose the data used to create objects would have to specify some sort of base type (the container) that offers a particular type of functionality. One advantage I could see with this is finer control over what components can go where. On the other hand, this obscures the purity of a truly component based model where any and all entities are nothing more than the sum of their parts (no entity is specialized in any way outside the scope of its components).

Again, should my components reflect the game they implement very strongly, or should I instead create a hierarchy of containers (entities)?

Thanks for the reply! To be honest, I find quite a bit of this stuff very interesting but also very confusing!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!