MonkeyModdingTroop / MonkeyLoader

A convenience and extendability focused mod loader using NuGet packages.
https://monkeymoddingtroop.github.io/MonkeyLoader/index.html
GNU Lesser General Public License v3.0
11 stars 3 forks source link

Support basetypes for the event system #8

Closed Banane9 closed 2 months ago

Banane9 commented 2 months ago

In some cases, one might want to use inheritance to make specific versions of a broader event. When one only cares about the broader event, it should be possible to subscribe to that, rather than having to subscribe to each specific event manually (and being out of luck if any are added).

Currently, events are only passed to exact matches, but their hierarchy could be checked too. For this purpose, the first thought might be an extra property for events - however polymorphism makes that impossible, as only the concrete type's value will be used. Rather, reflection would be the only way to do it, so an attribute should be added to each event base class type that should be useable on its own.

Going up an concrete event's type hierarchy, the check to pass it to handlers would then be: