GMS2 Event Framework
Implement Event-driven Architecture in Game Maker!
Event-driven Architecture is perfect for ensuring that: - Events (significant changes in program state) are checked for only once (as opposed to multiple times from different instances)
In a nutshell, using events ensures that one instance emits an event, and all responsible instances are alerted so they can perform their tasks for that event occurrence.
V1.2 UPDATES - Replaced Event object with ds_map - Added possibility to listen to events emitted from specific instance/object, from lists and maps of instances/objects - Replaced Event Data array which argument list for more natural callback handling - Fixed bugs and optimized data structures
How it works 0. The programmer (you) sets up Event Types in an enum (initEventTypes script) for any kind of event of relevance
One or several instances listen for occurrences of an Event Type (e.g. a mouse click), providing a callback script for the event
An instance emits an event of a specific type, including related data
The EventManager triggers the callback for all listeners for that event
Docs: https://pastebin.com/ySR6v2ZG Usage Example: https://pastebin.com/tCbkmjT5