4 ms·
In my game engine each set of events has its own event dispatcher (for example a model loading event has 6 stages). Its make it much easier to see who events a
by BatFastard 9y ago
In my game engine each set of events has its own event dispatcher (for example a model loading event has 6 stages). Its make it much easier to see who events a class is using, exactly who is using them. Also provides a better sense of encapsulation.
- gravypod 9y agoI agree that it can help with debugging but it puts that other "load" into your brain. Which dispatcher do I want for this event? If you're using C++ or another strongly typed language then it's probably fine because you'll get a compiler/IDE error about your types. If you're using something more "loose" having a central router helps.
- BatFastard 9y agoFor me it does just the opposite. Since each event class has its own dispatcher, the question of which dispatcher disappears. RegionEvent.create( RegionEvent.ADD_MODEL, series, guid, modelData ); The dispatcher is internal to the RegionEvent. The other great thing here is the custom events allow me to pass the type of parameters that are appropriate for this class. which is handled by RegionEvent.addListener( RegionEvent.ADD_MODEL, addModel ); I also use the rule that all event have to be treated as async events. This pattern works great for non real time portions of my engine.
- gravypod 9y agoThat's very nice. I'll have to give this a try in my work. Never thought about that.