Description

The Idea behind a "Publish & Subscribe" design pattern is to seperate the invoker of an action from the actor so the invoker doesn't need to care who is going to act or if anyone is going to act at all and the actor doesn't need to care who is going to invoke the action. This can be used for many different systems like updating the GUI, toggling post-processing shaders for visual feedback, controlling an achievement system, changeing states or whatever you like.

Check out the demo on our internet site.

MECHANICS:

A ds map in the controller object stores topics like "Alert" and each topic is linked to a ds list storing the instance ids of all subscribers and the script ids of the action a subscriber needs to perform when a topic is published (like triggering an Alarm sound and visuals).

Any object can subscribe to any topic by telling the controller object.

Any publisher can publish a topic to the controller object wich will then look up all subscribed instances in the list and run their script.

HELP:

Help is inside the scripts folder within the asset explaining the basics and showing a simple example, every script additionally has detailed explanations and comments. The asset also contains a demo.

PERFORMANCE:

Since the invoker needs to iterate through lists of actors it's slower than directly invoking an action. So this pattern is not suitable for using on alot of instances wich need to update every frame.

TESTED ON:

Windows, Windows YYC, Android, Android YYC, HTML5

CREDITS:

This Asset was created after reading an article about the pubsub system by Muse Hill. It's the same concept with different code and more functionality. You can find the article here: http://musehill.tumblr.com/post/86447097309/implementing-the-pubsub-pattern-in-gamemaker

End User Licence Agreement (EULA).

Changes in 1.0.3

fixed a minor bug in debug draw

Version 1.0.3. Published September 24, 2016

Created with GameMaker: Studio v1.4.1757

Age Rating: 4+

Average Rating

Your review

You can only review assets you've bought.


Gravatar

Anonymous 30 July 2018

Works perfectly!


Gravatar

Anonymous 28 January 2018

Package contents

Loading, please wait

What is the issue?

Back to Top