Jump to content
  • Advertisement
Sign in to follow this  
X Abstract X

Component System Brainstorming

This topic is 3082 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 know there are hundreds of articles and other threads on the topic, I read a lot of them. Some of the stuff described in these readings goes beyond my knowledge so I've been doing a lot of thinking on my own trying to come up with a design that will help me modularize my engine. Right now it's only theory and I want to kind of get advice to see if this is something that can actually work or will there be pitfalls that I haven't thought of.

I'm not looking to create a pure component system, I just want to create a bit of a nicer system for creating game objects.

Basically what I thought I could do is extract the data that I would usually store in a game objects and factor it into "components". For example I could create a position component, a combat component, a renderable component, etc. Then I would write event classes that take in entities and operate on the components to provide the functionality of my game.

Code Example:

Entity a;

PositionEvent posEvent;
posEvent.setPosition(a, Vector3f(0.0f, 0.0f, 0.0f));
posEvent.increasePosition(a, Vector3f(10.0f, 0.0f, 0.0f));

Entity b;

CombatEvent combatEvent;
combatEvent.initiateCombat(a, b);

So, am I crazy, is this design rediculous?

Share this post

Link to post
Share on other sites
It looks nice. This allows you to create any object (as long as it can be composed of available components) at run-time. I also think this design nicely modularizes the code.

What you could also do, if you are dealing with lots and lots of entities, is to make addComponent add the particular component to a single array (vector). Then in the event of iterating over the positions, for example, you'd only iterate over one array. This could speed things up (read up on Data Oriented Programming).

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!