I've recently finished implementing a component-entity system (or COM) which is working well. My goal with this new system was primarily to encourage code/component reuse and speed up development of my games.
The problem I'm tackling now is how to maintain the decoupling of components (both sibling components and cousin/other-object components). C++ has been my primary method of development for four years now, so when I tried the Blender Game Engine for the last two games I've made, I noticed some things I wanted to implement into my own engine. The "message" actuator was particularly appealing. The ability to send simple text messages or variables to any object (or to all objects/groups) made interaction between objects simple, yet not extremely limited. I'd like to implement something similar in my own engine, at the component->object<-component, and component->group of objects<-all components in group.
How should I go about doing this in the best way (judging in order of importance: versatility, simplicity of use, performance)? I've thought about using a static array and storing global flags/variables (such as position) at an object level so that all components can get or set the variables safely. This solution doesn't allow easy/readable indexing, events (only stores data), and is difficult to get right with the dynamic nature of CES/COM objects.
Game Coding Complete suggested using a polymorphism-based "event manager" consisting of events (which contain any data and must inherit from a base class) and event listeners (which are called when an event is heard and must inherit from a base class; these also must cast events to their true types). I want to avoid that much complexity in order to make coding for it easier and less time-consuming, but the functionality is there.
How would you recommend implementing such a system?
Edited by makuto, 14 July 2013 - 07:37 PM.