1
\$\begingroup\$

I have been developing a game engine. I was wondering what I should use for a component system. I've read up on entity component systems, but what other alternatives are there? The idea of searching through a "master list" of all entities in the entire game world seems inefficient and slow. I need the most efficient one possible (3D and 2D, if that matters). Using object oriented programming (C++)

\$\endgroup\$

closed as off-topic by ashes999, bummzack, Vaillancourt, Sean Middleditch, Josh Jan 4 '16 at 16:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about "how to get started," "what to learn next," or "which technology to use" are discussion-oriented questions which involve answers that are either based on opinion, or which are all equally valid. Those kinds of questions are outside the scope of this site. Visit our help center for more information." – Josh
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 5
    \$\begingroup\$ "The idea of searching through a "master list" of all entities in the entire game world seems inefficient and slow." -- So you ran a profiling tool and measured and made sure it actually was slow before asking this question, right? \$\endgroup\$ – Sean Middleditch Dec 31 '15 at 23:50
  • \$\begingroup\$ People like you ruin StackExchange. You want to say that it is not inefficient? Say it. After all, Game engine architecture is your "passion." If you have nothing else to contribute to my question, then keep it quiet and don't waste my time. \$\endgroup\$ – Java Man Tea Man Jan 1 '16 at 2:08
  • 3
    \$\begingroup\$ @JavaManTeaMan Why so angry? He suggests you to measure and test your question with profiling before asking. That is the only real way to understand if it is inefficient or not. \$\endgroup\$ – S. Tarık Çetin Jan 1 '16 at 12:48
  • \$\begingroup\$ @JavaManTeaMan Also Without knowing how many entities will you have and what kind of game are we talking about its impossible to tell. Still component systems can be really fast if implemented properly due to cache efficiency. \$\endgroup\$ – akaltar Jan 1 '16 at 15:15
  • \$\begingroup\$ @JavaManTeaMan: yeah, I honestly have no idea if it's inefficient for your use case because you didn't explain anything about what you're doing; just that your common sense told you that it "seems" slow. What's inefficient about it? You have very large numbers of entities? You have a large game world and only need to iterate through a subset of relevant entities at any given time? Your implementation of an ECS is sub-par and less efficient than it could be? Why is it inefficient for you? \$\endgroup\$ – Sean Middleditch Jan 1 '16 at 19:09
4
\$\begingroup\$

You will end with up keeping a list/array/database/dictionary/hastable (etc.) of all objects you have somehow, divided into chunks or not. That is the only way to track and store changes in your game on runtime.

But there is a choice you can make; which one do you care about: memory or CPU? If you care about memory, you should go with single master-list. If you care about CPU, you should go with divided lists like chunks/tagging/layering etc..

But please note that, if your game don't get big enough, these optimizations will be barely noticable for both developers and players.

\$\endgroup\$
4
\$\begingroup\$

Build a system where objects can be in multiple lists at once and build lists according to processing categories along with the master list.

This way you can run through the list that suits your purpose.

\$\endgroup\$
3
\$\begingroup\$

Divide your world up into chunks. Store a linked list of entities in each chunk. When an entity moves out of a chunk, move it from one list to another.

This allows you to pick out which chunks of entities to send to the player and which to unload more efficiently.

Linked lists are especially good for this because adding/removing elements is fast, as well as them being dynamic.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.