It'd be better if UE #StateTree can dispatch events to tasks, instead of letting tasks to interate the event queue themself.

I implemented such a dispatcher. Tasks can register event handlers when entering a state, and unregister them on exit. Received events are first dispatched to tasks, then transitions.