jdoleary / Spellmasons

https://store.steampowered.com/app/1618380/Spellmasons/
Other
0 stars 1 forks source link

Refactor events #828

Closed jdoleary closed 1 week ago

jdoleary commented 1 week ago

ref: Collect all events in a single array

This removes several footguns that occurred when
adding a new type of event.
Much less boilerplate now that all events are handled in
the same array and since it always has to check the eventSource
in order to invoke the function it is okay that different
event types are stored in the same array.

One potential (I think unrealized) problem with this approach
is if some modifier needs to selectively remove one event type
but not another - however this can now just be done with
different event ids. And I don't think this currently happens in the
codebase so I don't see it as a problem.

This commit paves the way for Runes which will be very event heavy
and will add lots of new event source types.
jdoleary commented 1 week ago

This lays the groundwork for #820

SoulMuncher commented 1 week ago

I can't think of any places where we do or would selectively remove one event type of a given id and since the event source is already checked, it makes sense to put it all of the events into one array. This looks good to me.