This commit is contained in:
aozhiwei 2023-06-21 23:14:00 +08:00
parent ab8db13131
commit e5f524d1c8
4 changed files with 11 additions and 20 deletions

View File

@ -16,12 +16,6 @@
#include "mt/Robot.h"
template<typename T>
static auto SpToWp(std::shared_ptr<T> sp)
{
return std::weak_ptr<T>(sp);
}
AndroidAgent::AndroidAgent():BaseAgent()
{
@ -67,7 +61,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomWalk()
GetOwner()->GetTrigger()->AddListener
(
kAttacked,
[context_wp = SpToWp(context)] (const a8::Args& args)
[context_wp = a8::SpToWp(context)] (const a8::Args& args)
{
if (!context_wp.expired()) {
auto context = context_wp.lock();

View File

@ -19,12 +19,6 @@
#include "mt/Hero.h"
#include "mt/Param.h"
template<typename T>
static auto SpToWp(std::shared_ptr<T> sp)
{
return std::weak_ptr<T>(sp);
}
void DumpBt(BaseAgent* agent)
{
static std::string last_bt_name;
@ -264,7 +258,7 @@ behaviac::EBTStatus BaseAgent::DoIdle(int min_time, int max_time)
GetOwner()->GetTrigger()->AddListener
(
kAttacked,
[context_wp = SpToWp(context)] (const a8::Args& args)
[context_wp = a8::SpToWp(context)] (const a8::Args& args)
{
if (!context_wp.expired()) {
auto context = context_wp.lock();

View File

@ -18,6 +18,15 @@ context->owner = owner; \
return context; \
}(GetOwner()->GetWeakPtrRef(), this)
namespace a8
{
template<typename T>
static auto SpToWp(std::shared_ptr<T> sp)
{
return std::weak_ptr<T>(sp);
}
}
struct BtCoroutine;
class Creature;
class BaseAgent : public behaviac::Agent

View File

@ -18,12 +18,6 @@
#include "mt/Map.h"
#include "mt/Hero.h"
template<typename T>
static auto SpToWp(std::shared_ptr<T> sp)
{
return std::weak_ptr<T>(sp);
}
HeroAgent::HeroAgent():BaseAgent()
{