// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/Types/Variant.h"
#include "Engine/Core/Collections/BitArray.h"
#include "Engine/Scripting/ScriptingObject.h"
class Behavior;
class BehaviorTree;
///
/// Behavior logic component knowledge data container. Contains blackboard values, sensors data and goals storage for Behavior Tree execution.
///
API_CLASS() class FLAXENGINE_API BehaviorKnowledge : public ScriptingObject
{
DECLARE_SCRIPTING_TYPE_WITH_CONSTRUCTOR_IMPL(BehaviorKnowledge, ScriptingObject);
~BehaviorKnowledge();
///
/// Owning Behavior instance (constant).
///
API_FIELD(ReadOnly) Behavior* Behavior = nullptr;
///
/// Used Behavior Tree asset (defines blackboard and memory constraints).
///
API_FIELD(ReadOnly) BehaviorTree* Tree = nullptr;
///
/// Raw memory chunk with all Behavior Tree nodes state.
///
void* Memory = nullptr;
///
/// Array with per-node bit indicating whether node is relevant (active in graph with state created).
///
BitArray<> RelevantNodes;
///
/// Instance of the behaviour blackboard (structure or class).
///
API_FIELD() Variant Blackboard;
///
/// Initializes the knowledge for a certain tree.
///
void InitMemory(BehaviorTree* tree);
///
/// Releases the memory of the knowledge.
///
void FreeMemory();
///
/// Gets the knowledge item value via selector path.
///
///
/// Selector path.
/// Result value (valid only when returned true).
/// True if got value, otherwise false.
API_FUNCTION() bool Get(const StringAnsiView& path, API_PARAM(Out) Variant& value);
///
/// Sets the knowledge item value via selector path.
///
///
/// Selector path.
/// Value to set.
/// True if set value, otherwise false.
API_FUNCTION() bool Set(const StringAnsiView& path, const Variant& value);
};