Attached are the source files for a callback component for the game engine. Basically you can attach an arbitrary number of callbacks to any event which will be called for both checkEvent() and executeEvent().
The callback is:
Code:
typedef bool (*CALLBACK_FUNC)(bool aIsCheckEvent, GameEvent&);
You can also register a factory function of:
Code:
typedef CALLBACK_FUNC (*FACTORY_FUNC)(const char*);
That loadFromXml() can use to get a function ptr from a string in the XML.
The EventRegistry.zip is a few files that add a PITA string to EventID class that's part of modules. If you're okay with just using integral eventIds then you don't need it and can just change the loadFromXml() of the component to translate an int to an EventID.
Basically on construction the event registry mirrors the EventID enum in that it calls a REGISTER_EVENT() macro passing in the EventID and the comment originally attached to it. I'd really like to write a preprocessor that does the work of keeping this guy up to date rather than fussing with maintaining two places.
Warning: only very lightly tested ... but feel free to yell at me for mess-ups.