Implementing the Event Queue pattern in Godot
As you can see, the Event Queue pattern is a powerful tool to have in our hands. We can use it in many systems of a game, both locally and globally. For instance, we can create an event queue singleton to hold events that multiple other classes would process. Or we can create an event queue to handle local events, such as the character’s next animation in a combo.
Note that, ideally, anything can be abstracted as an event. It will depend on your context. This means that we could create something like an Event
class with relevant properties, or be more specific and create a MovementEvent
class that would create objects that represent the character’s movement such as if the character jumped, moved left, moved right, stopped, or grabbed something. You could be even more specific. For instance, in the GrabbedObjectEvent
class, we could store a reference for the object that was grabbed. In these cases, we could create a MovementEventQueue...