Merge branch 'Tryibion-blackboard-utils'

This commit is contained in:
2026-05-12 18:25:03 +02:00
3 changed files with 43 additions and 0 deletions
+9
View File
@@ -57,6 +57,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.
+12
View File
@@ -124,6 +124,18 @@ 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 Cast<T>((ScriptingObject*)Blackboard);
}
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