13 Blackboard References

This example shows you how to reference another blackboard from a blackboard.

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

SourceBlackboard.cs

using CrashKonijn.Blackboard.Contracts;
using UnityEngine;

namespace CrashKonijn.BlackboardPro.Blackboards.Examples
{
    public partial class SourceBlackboard : BlackboardBehaviour
    {
        private int lowHealth = 50;
    }
}

ReferenceBlackboard.cs

using CrashKonijn.Blackboard.Contracts;
using CrashKonijn.BlackboardPro.Blackboards.Tests;

namespace CrashKonijn.BlackboardPro.Blackboards.Examples
{
    public partial class ReferenceBlackboard : BlackboardBehaviour
    {
        private SourceBlackboard _sourceBlackboard;
        
        private int health;
        
        private static bool isLowHealth(SourceBlackboard.Signals.LowHealth lowHealth, Signals.Health health) => health.Value < lowHealth.Value;
    }
}

DoubleReferenceBlackboard.cs

using CrashKonijn.Blackboard.Contracts;

namespace CrashKonijn.BlackboardPro.Blackboards.Examples
{
    public partial class DoubleReferenceBlackboard : BlackboardBehaviour
    {
        private ReferenceBlackboard referenceBlackboard;
        
        private static bool isAlive(ReferenceBlackboard.Signals.Health health) => health.Value > 0;
        private static bool isHighHealth(ReferenceBlackboard.Signals.Health health, SourceBlackboard.Signals.LowHealth lowHealth) => health.Value > lowHealth.Value;
    }
}

Last updated