Event Bubbling in reverse
I’ve been thinking about an architecture for a game engine (this is something that i do for fun). I’m pretty bully on the whole event-based design for an engine, and have been thinking about event propagation. How would this work in an Object Oriented design?
The idea in my head involves a high level container i’m calling a Room. A Room might contain several Players, Bots, and other game objects. I’d like to be able to easily add behaviour for different “events” that could happen in the Room. An example would be when a new Player enters the Room. A ‘NEWPLAYER’ event would be broadcast to all the objects in the Room. The trick is that objects might have sub-objects themselves. Say a Player in the Room has a wand of auto-attack. This wand listens for a ‘NEWPLAYER’ event, and then takes some kind of action itself. Because the wand is a sub-item of the Player, the Player, when it receives the ‘NEWPLAYER’ event would have to re-broadcast it to all its sub-items. And so on, till all the items in the Room have received the event.
I’m not sure if it would be as easy as adding a function which is the name of the event to an object, which would then get called when that event is passed, or if i’d want something a bit more complex.
I’m also trying to figure out how this can integrate with the Fibranet package, specifically the NanoThreads bits.

Leave a comment