From 1dbae08b6f5d9e4df8325f5170a2355953ff4db8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 6 Dec 2022 19:22:47 +0800 Subject: [PATCH] 1 --- cpp/btmgr.cc | 20 ++++++++++++++++---- cpp/btmgr.h | 6 +++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/cpp/btmgr.cc b/cpp/btmgr.cc index e3d8603..08b55de 100644 --- a/cpp/btmgr.cc +++ b/cpp/btmgr.cc @@ -1,6 +1,5 @@ #include "precompile.h" -#include "behaviac/behaviac.h" #include "btmgr.h" namespace f8 @@ -16,6 +15,12 @@ namespace f8 behaviac::Workspace::GetInstance()->Cleanup(); } + void BtMgr::SetLogging(bool logging) + { + behaviac::Config::SetLogging(logging); + behaviac::Config::SetLoggingFlush(true); + } + bool BtMgr::BtLoad(behaviac::Agent* agent, const char* relative_path, bool force) { if (!agent) { @@ -32,12 +37,20 @@ namespace f8 agent->btsetcurrent(relative_path); } - void BtMgr::BtExec(behaviac::Agent* agent) + behaviac::EBTStatus BtMgr::BtExec(behaviac::Agent* agent) { if (!agent) { abort(); } - agent->btexec(); + return agent->btexec(); + } + + behaviac::BehaviorTreeTask* BtMgr::BtGetCurrent(behaviac::Agent* agent) + { + if (!agent) { + abort(); + } + return agent->btgetcurrent(); } void BtMgr::BtDestory(behaviac::Agent* agent) @@ -49,4 +62,3 @@ namespace f8 } } - diff --git a/cpp/btmgr.h b/cpp/btmgr.h index 410ce88..868d37b 100644 --- a/cpp/btmgr.h +++ b/cpp/btmgr.h @@ -1,5 +1,7 @@ #pragma once +#include "behaviac/behaviac.h" + namespace behaviac { class Agent; @@ -16,10 +18,12 @@ namespace f8 public: void Init(const std::string& file_path); void UnInit(); + void SetLogging(bool logging); bool BtLoad(behaviac::Agent* agent, const char* relative_path, bool force = false); void BtSetCurrent(behaviac::Agent* agent, const char* relative_path); - void BtExec(behaviac::Agent* agent); + behaviac::EBTStatus BtExec(behaviac::Agent* agent); + behaviac::BehaviorTreeTask* BtGetCurrent(behaviac::Agent* agent); void BtDestory(behaviac::Agent* agent); }; }