71 lines
1.7 KiB
C++
71 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "precompile.h"
|
|
|
|
#include "behaviac/behaviac.h"
|
|
#include "behaviac_customized_types.h"
|
|
|
|
struct BtCoroutine
|
|
{
|
|
std::any context;
|
|
const char* name = nullptr;
|
|
std::function<behaviac::EBTStatus()> runing_cb;
|
|
std::function<void(bool, bool&)> event_cb;
|
|
long long sleep_end_frameno = 0;
|
|
int sleep_time = 0;
|
|
|
|
BtCoroutine(std::any context, const char* name)
|
|
{
|
|
this->context = context;
|
|
this->name = name;
|
|
}
|
|
};
|
|
|
|
class Creature;
|
|
class BaseAgent : public behaviac::Agent
|
|
{
|
|
public:
|
|
BaseAgent();
|
|
|
|
virtual ~BaseAgent();
|
|
|
|
BEHAVIAC_DECLARE_AGENTTYPE(BaseAgent, behaviac::Agent)
|
|
|
|
void Exec();
|
|
|
|
bool IsGameOver();
|
|
bool HasTarget(float range);
|
|
bool HasBuffEffect(int buff_effect);
|
|
float GetAttackRange();
|
|
void SetBulletTraceMode(bool mode);
|
|
bool CanUseSkill(int skill_id);
|
|
int GetUseableSkill(Creature* target);
|
|
|
|
behaviac::EBTStatus CoAttackTarget(int target_id);
|
|
behaviac::EBTStatus DoIdle(int min_time, int max_time);
|
|
behaviac::EBTStatus DoUseSkill(int skill_id);
|
|
|
|
public:
|
|
void SetOwner(Creature* owner) { owner_ = owner; };
|
|
Creature* GetOwner() { return owner_; };
|
|
|
|
protected:
|
|
behaviac::EBTStatus DoRunningCb();
|
|
behaviac::EBTStatus StartCoroutine(std::shared_ptr<BtCoroutine> coroutine);
|
|
bool InternalUseSkill(int skill_id, CreatureWeakPtr target, int& wait_time);
|
|
void Sleep(int time);
|
|
|
|
protected:
|
|
bool bullet_trace_mode_ = false;
|
|
#ifdef DEBUG
|
|
behaviac::EBTStatus last_status_ = behaviac::BT_INVALID;
|
|
long long status_frameno_ = 0;
|
|
const char* status_name_ = nullptr;
|
|
#endif
|
|
behaviac::EBTStatus status_= behaviac::BT_SUCCESS;
|
|
|
|
private:
|
|
Creature* owner_ = nullptr;
|
|
std::shared_ptr<BtCoroutine> coroutine_;
|
|
};
|