This commit is contained in:
aozhiwei 2022-12-06 19:22:47 +08:00
parent 88464b5a59
commit 1dbae08b6f
2 changed files with 21 additions and 5 deletions

View File

@ -1,6 +1,5 @@
#include "precompile.h" #include "precompile.h"
#include "behaviac/behaviac.h"
#include "btmgr.h" #include "btmgr.h"
namespace f8 namespace f8
@ -16,6 +15,12 @@ namespace f8
behaviac::Workspace::GetInstance()->Cleanup(); 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) bool BtMgr::BtLoad(behaviac::Agent* agent, const char* relative_path, bool force)
{ {
if (!agent) { if (!agent) {
@ -32,12 +37,20 @@ namespace f8
agent->btsetcurrent(relative_path); agent->btsetcurrent(relative_path);
} }
void BtMgr::BtExec(behaviac::Agent* agent) behaviac::EBTStatus BtMgr::BtExec(behaviac::Agent* agent)
{ {
if (!agent) { if (!agent) {
abort(); 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) void BtMgr::BtDestory(behaviac::Agent* agent)
@ -49,4 +62,3 @@ namespace f8
} }
} }

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "behaviac/behaviac.h"
namespace behaviac namespace behaviac
{ {
class Agent; class Agent;
@ -16,10 +18,12 @@ namespace f8
public: public:
void Init(const std::string& file_path); void Init(const std::string& file_path);
void UnInit(); void UnInit();
void SetLogging(bool logging);
bool BtLoad(behaviac::Agent* agent, const char* relative_path, bool force = false); bool BtLoad(behaviac::Agent* agent, const char* relative_path, bool force = false);
void BtSetCurrent(behaviac::Agent* agent, const char* relative_path); 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); void BtDestory(behaviac::Agent* agent);
}; };
} }