The KnowledgeBase is a node singleton that stores and manages all the knowledge in the game. It rests at res://Singleton/KnowledgeBase.gd.


flow

On ready, the encountered, forgot, and learned topics and handlers are set up.


Knowledge is learned by setting

Also, all objects that inherit from the base request a ref_id at ready.


signals



variables




methods


int designate_ref_id()

increments current_ref_id by one then returns it.


void publish(String topic, ??? data)

If the topic has any active subscriptions, its handlers are prompted to handle the data.


void subscribe(String topic, Object handler)

An entry in topics is made for the topic if needed, then the handler is added to the topic's list.


void unsubscribe(String topic, Object handler)

if the topic has an active subscription, the given handler is erased from the topic's list.


void _on_handler_tree_exited(String topic, Object handler)

During subscribe, the handler is connected to execute this if it exits the tree. It unsubscribes the handler from the topic.