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
@@ -58,6 +58,15 @@ public:
return &_knowledge; return &_knowledge;
} }
/// <summary>
/// Gets the blackboard of a given type.
/// </summary>
template<typename T>
FORCE_INLINE T* GetBlackboard()
{
return _knowledge.GetBlackboard<T>();
}
/// <summary> /// <summary>
/// Gets the last behavior tree execution result. /// Gets the last behavior tree execution result.
/// </summary> /// </summary>
+12
View File
@@ -124,6 +124,18 @@ public:
RemoveGoal(T::TypeInitializer); 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: public:
/// <summary> /// <summary>
/// Compares two values and returns the comparision result. /// Compares two values and returns the comparision result.
+22
View File
@@ -11,6 +11,18 @@ using FlaxEngine.GUI;
namespace FlaxEngine 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 partial class BehaviorKnowledge
{ {
/// <summary> /// <summary>
@@ -33,6 +45,16 @@ namespace FlaxEngine
{ {
RemoveGoal(typeof(T)); 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 partial class BehaviorTreeRootNode