To receive updates from a Blackboard Note or a Blackboard Event, a script must implement IFollowBlackboard, or inherit from BlackboardFollower.
Blackboard Notes contain a "Topic" and "Subject", both strings, which are similar to the key in a Dictionary key/value pair. They also contain a selection of data types, including Game Module types like GameItemObject or GameStat.
The Blackboard module allows other objects to follow it, and receive a notification whenever a BlackboardNote is added or updated, and when a BlackboardEvent is sent. Followers should check to see if the topic and subject are what they are looking for, and if so, handle the new data.
// BlackboardNote.cspublicstring name; // Mostly useful for the inspectorpublicstring topic; // The broad topic. Examples could be "Kills" or "Dungeon Doors"publicstring subject; // The specific subject. Such as "Goblins" or "Crypt" publicobject value;// General typespublicfloat valueFloat; publicint valueInt;publicstring valueString; publicbool valueBool;publicGameObject valueGameObject;// Game Module typespublicGameStat valueGameStat;publicGameItemObject valueGameItemObject;publicGameItemAttribute valueGameItemAttribute;publicGameCondition valueGameCondition;publicGameQuest valueGameQuest;publicGameLootBox valueGameLootBox;// Game ListspublicGameStatList valueGameStatList;publicGameItemObjectList valueGameItemObjectList;publicGameConditionList valueGameConditionList;publicGameQuestList valueGameQuestList;
You can Add() Blackboard Notes, though it may be more ideal to Update() the note in most cases, as this will automtically add the note if it does not yet exist.
// Update a note value, or add it if it doesn't existblackboard.UpdateNote("Party","Distance Travelled", DistanceTravelled,true,true);// Update a note without sending a notification to followersblackboard.UpdateNote("Party","Distance Travelled", DistanceTravelled,true,false);// Get a note from the Blackboardblackboard.TryGet(topic, subject,outBlackboardNote note);Debug.Log($"The int value is {note.valueInt}.");// Example of receiving a change from the blackboardpublicoverridevoidReceiveChange(BlackboardNote blackboardNote){ // We only care about our topic / subjectif (blackboardNote.topic!= topicWeCareAbout ||blackboardNote.subject!= subjectWeCareAbout) return;DoSomethingWith(blackboardNote);}