Add Behavior knowledge data debugging

This commit is contained in:
Wojtek Figat
2023-09-14 13:53:19 +02:00
parent 35609c9883
commit f7787a9221
3 changed files with 184 additions and 15 deletions

View File

@@ -203,6 +203,17 @@ bool BehaviorKnowledge::HasGoal(ScriptingTypeHandle type) const
return false;
}
Variant BehaviorKnowledge::GetGoal(ScriptingTypeHandle type)
{
for (const Variant& goal : Goals)
{
const ScriptingTypeHandle goalType = Scripting::FindScriptingType(goal.Type.GetTypeName());
if (goalType == type)
return goal;
}
return Variant::Null;
}
void BehaviorKnowledge::AddGoal(Variant&& goal)
{
int32 i = 0;

View File

@@ -47,7 +47,7 @@ API_CLASS() class FLAXENGINE_API BehaviorKnowledge : public ScriptingObject
/// <summary>
/// List of all active goals of the behaviour (structure or class).
/// </summary>
Array<Variant> Goals;
API_FIELD() Array<Variant> Goals;
public:
/// <summary>
@@ -96,6 +96,13 @@ public:
return HasGoal(T::TypeInitializer);
}
/// <summary>
/// Gets the goal from the knowledge.
/// </summary>
/// <param name="type">The goal type.</param>
/// <returns>The goal value or null if not found.</returns>
API_FUNCTION() Variant GetGoal(ScriptingTypeHandle type);
/// <summary>
/// Adds the goal to the knowledge. If goal of that type already exists then it's value is updated.
/// </summary>