Let me start of by just saying hello to everyone. Hello.
I hope this is the correct board for this kind of post. I have been reading for a while but just recently decided to actually become active and was hoping that somebody would be help to help me with an issue I just ran into.
My question is this: When using a GameObject-Component design with a game engine, what is the best way to have data to describe the game objects, but can be accessed from multiple components? Should this even be needed, or does it indicate some deeper design flaw?
Now for some more detail...
I am currently changing up an engine and moving it away from an ugly Entity based setup for in game characters and such. I want to get everything working nicely using GameObject and components (the engine is in C++). I have already changed it to use GameObject and Components, but I am worried about performance issues.
Data about my GameObjects are currently held in various maps with name/value pairs. For example, a value could be added to a game using a method such as AddInteger(string name, int value). Values are then stored in a map for values of that particular type (int, char, string, etc.). Values can later be read back into integers using methods like ReadInteger(string name, int default), where default is the value returned if name is not found in the map.
For those of you who are familiar with Android, you may recognize this approach as being the same used in Android's SharedPreferences. http://developer.android.com/reference/android/content/SharedPreferences.html
This approach seems great on paper as values like velocity can be stored in one place and components for collision and physics and other can all access it. The components are also not punished for trying to reference a nonexistant value and can control what they default to after a failed read. Note, some values can be hardcoded into GameObject (such as a Transform for position) but I would like to avoid that as much as possible.
My concern is that when there are many GameObjects being updated at once, the time needed for lookups from the maps will be nontrivial. Does anybody have any advice to offer about this or any suggestions? I haven't tested it yet, I plan to tomorrow, but I am worried it will get slow.