# 12 Class Blackboard

This example shows you how to use a class Blackboard.

These files can be found in the /Examples/\[example] and /Blackboards/Examples folders.

## ClassBlackboard.cs

```csharp
﻿using System;
using CrashKonijn.RabbitBlackboard.Contracts;

namespace CrashKonijn.BlackboardPro.Blackboards.Examples
{
    // Make sure the class is serializable so it can show in the editor
    [Serializable]
    public partial class ClassBlackboard : IBlackboard
    {
        private int health = 50;
        private static bool isLowHealth(Signals.Health health) => health.Value < 50;
    }
}

```

## ClassBehaviour.cs

```csharp
﻿using CrashKonijn.BlackboardPro.Blackboards.Examples;
using CrashKonijn.RabbitBlackboard.Contracts;
using UnityEngine;

namespace CrashKonijn.BlackboardPro.Examples._12_blackboard_class
{
    public class ClassBehaviour : MonoBehaviour
    {
        // You can manage your own instance of classes that implement IBlackboard.
        [SerializeField]
        private ClassBlackboard blackboard = new();

        /* Simple hack to show a button in the editor */
        [Header("Removes 10 health.")]
        [Button(nameof(DoDamage))]
        public string doDamageButton;

        /* Simple hack to show a button in the editor */
        [Header("Adds 10 health")]
        [Button(nameof(Heal))]
        public string healButton;

        private void OnEnable()
        {
            this.blackboard.IsLowHealthSignal.OnValueChanged.AddListener(this.OnLowHealthChanged);
            this.blackboard.HealthSignal.OnValueChanged.AddListener(this.OnStartPlayerHealthChanged);
        }

        private void OnDisable()
        {
            this.blackboard.IsLowHealthSignal.OnValueChanged.RemoveListener(this.OnLowHealthChanged);
            this.blackboard.HealthSignal.OnValueChanged.RemoveListener(this.OnStartPlayerHealthChanged);
        }

        private void OnLowHealthChanged(bool value)
        {
            Debug.Log($"Is low health changed to {value}");
        }

        private void OnStartPlayerHealthChanged(int value)
        {
            Debug.Log($"Start player health changed to {value}");
        }

        public void Heal()
        {
            this.blackboard.Health += 10;
        }

        public void DoDamage()
        {
            this.blackboard.Health -= 10;
        }
    }
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blackboard.crashkonijn.com/examples/12_class_blackboard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
