Add way to get blackboard by type.

This commit is contained in:
2026-05-01 16:27:15 -05:00
parent 0592816ef1
commit 94e529e801
3 changed files with 44 additions and 0 deletions
+9
View File
@@ -58,6 +58,15 @@ public:
return &_knowledge;
}
/// <summary>
/// Gets the blackboard of a given type.
/// </summary>
template<typename T>
FORCE_INLINE T* GetBlackboard()
{
return _knowledge.GetBlackboard<T>();
}
/// <summary>
/// Gets the last behavior tree execution result.
/// </summary>
+13
View File
@@ -124,6 +124,19 @@ public:
RemoveGoal(T::TypeInitializer);
}
/// <summary>
/// Gets the blackboard of a given type.
/// </summary>
template<typename T>
FORCE_INLINE T* GetBlackboard()
{
auto* structure = Blackboard.AsStructure<T>();
if (structure)
return structure;
return Blackboard.AsObject(T::TypeInitializer);
}
public:
/// <summary>
/// Compares two values and returns the comparision result.
+22
View File
@@ -11,6 +11,18 @@ using FlaxEngine.GUI;
namespace FlaxEngine
{
partial class Behavior
{
/// <summary>
/// Gets the blackboard of the given type.
/// </summary>
/// <typeparam name="T"> The blackboard type.</typeparam>
public T GetBlackboard<T>()
{
return Knowledge.GetBlackboard<T>();
}
}
partial class BehaviorKnowledge
{
/// <summary>
@@ -33,6 +45,16 @@ namespace FlaxEngine
{
RemoveGoal(typeof(T));
}
/// <summary>
/// Gets the blackboard of the given type.
/// </summary>
/// <typeparam name="T"> The blackboard type.</typeparam>
[Unmanaged]
public T GetBlackboard<T>()
{
return (T)Blackboard;
}
}
partial class BehaviorTreeRootNode