// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Content/BinaryAsset.h" #include "Engine/Visject/VisjectGraph.h" class BehaviorTreeNode; class BehaviorTreeRootNode; /// /// Behavior Tree graph node. /// class BehaviorTreeGraphNode : public VisjectGraphNode<> { public: // Instance of the graph node. BehaviorTreeNode* Instance = nullptr; ~BehaviorTreeGraphNode(); }; /// /// Behavior Tree graph. /// class BehaviorTreeGraph : public VisjectGraph { public: // Instance of the graph root node. BehaviorTreeRootNode* Root = nullptr; // [VisjectGraph] bool Load(ReadStream* stream, bool loadMeta) override; void Clear() override; bool onNodeLoaded(Node* n) override; }; /// /// Behavior Tree graph executor runtime. /// class BehaviorTreeExecutor : public VisjectExecutor { }; /// /// Behavior Tree asset with AI logic graph. /// /// API_CLASS(NoSpawn, Sealed) class FLAXENGINE_API BehaviorTree : public BinaryAsset { DECLARE_BINARY_ASSET_HEADER(BehaviorTree, 1); public: /// /// The Behavior Tree graph. /// BehaviorTreeGraph Graph; /// /// Tries to load surface graph from the asset. /// /// The surface data or empty if failed to load it. API_FUNCTION() BytesContainer LoadSurface(); #if USE_EDITOR /// /// Updates the graph surface (save new one, discard cached data, reload asset). /// /// Stream with graph data. /// True if cannot save it, otherwise false. API_FUNCTION() bool SaveSurface(const BytesContainer& data); #endif public: // [BinaryAsset] #if USE_EDITOR void GetReferences(Array& output) const override { // Base BinaryAsset::GetReferences(output); Graph.GetReferences(output); } #endif protected: // [BinaryAsset] LoadResult load() override; void unload(bool isReloading) override; AssetChunksFlag getChunksToPreload() const override; };