Blackboard Event

v4.0

Blackboard Events

To receive updates from a Blackboard Note or a Blackboard Event, a script must implement IFollowBlackboard, or inherit from BlackboardFollower.

Blackboard Events have four values. "Topic", "GameUid", and "Status" are strings, and there is also an Object obj.

Note that the strings do not have to be specifically what they are named. You can use these values creatively however you'd like to pass data between objects.

Events are great ways to pass data to any object in your project which is looking for them. Objects which follow the Blackboard can choose whether to handle the event based on the Topic, GameUid, and Status passed through the event.

public string topic; // May often be used to describe the gameUid -- i.e. "ItemObject" or "Stat" or something else you've created
public string gameUid; // Unique in-game identifier of the obj
public string status; // Describes the event that has occurred to the topic
public object obj; // The object itself

Any script can add a BlackboardEvent to the blackboard, and all those who follow the blackboard will then get a notification of the event. Once an event has been sent, it is removed from the blackboard.

// Add an event to the Blackboard, with no object. All values can be null or empty.
blackboard.AddEvent(topic, gameUid, status, null);

// An example of receiving an event from the Blackboard
public override void ReceiveEvent(BlackboardEvent blackboardEvent)
{
     // We only care about events we are handling, often defined by the string values in the event.
     if (blackboardEvent.topic != topic
          || blackboardEvent.gameUid != gameUid
          || blackboardEvent.status != status)
     return;

     DoSomethingWith(blackboardEvent);
}

Last updated