So that's what I've come up with:
[https://gist.github.com/RSDuck/e6969f0331d3bc9dd4fd6666e2bebad3](https://gist.github.com/RSDuck/e6969f0331d3bc9dd4fd6666e2bebad3)
Example:
testSystem.listen("ui.*.click") do (event: string, args:
openArray[Variant]):
echo "Someone clicked on something"
if event == "ui.player.click":
echo "To be precise, ", args[0].stringVal, " clicked on something"
testSystem.listen("ui.player.*") do (event: string, name: string,
clickedOnId: int):
echo "Player UI event!"
testSystem.fire("ui.player.click", "Luke Skywalker", 12345)
It's pretty much a hybrid between the event system from the game engines Luxe
and Urho3D but I managed to get rid of the need to wrap the arguments into an
wrapper object
I'm worried about it's performance. On my PC the unoptimzed build manages to
fire 320 000 events in 1.5 seconds. So if a game runs with 60 FPS theoretically
only ~3555 events could be fired. Nevertheless it is much faster than Luxes
implementation which uses Regexes and a linear search.