79 lines
2.0 KiB
C++
79 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include "precompile.h"
|
|
|
|
#include "behaviac/behaviac.h"
|
|
#include "behaviac_customized_types.h"
|
|
|
|
#include "btcoroutine.h"
|
|
#include "btcontext.h"
|
|
|
|
#define PRE_ENTER_COROUTINE() \
|
|
const int co_id = 1000 + __LINE__; \
|
|
{ \
|
|
behaviac::EBTStatus status; \
|
|
if (PreEnterCoroutine(co_id, status)) { \
|
|
return status; \
|
|
} \
|
|
}
|
|
|
|
#define PRE_ENTER_COROUTINE_EX(ID) \
|
|
const int co_id = ID; \
|
|
{ \
|
|
behaviac::EBTStatus status; \
|
|
if (PreEnterCoroutine(co_id, status)) { \
|
|
return status; \
|
|
} \
|
|
}
|
|
|
|
#define MAKE_BTCONTEXT(...) \
|
|
[] (BaseAgent* agent) \
|
|
{ \
|
|
class Context : public BtContext \
|
|
{public: \
|
|
__VA_ARGS__; \
|
|
long long frameno = 0; \
|
|
}; \
|
|
auto context = std::make_shared<Context>(); \
|
|
context->frameno = agent->GetRoom()->GetFrameNo(); \
|
|
return context; \
|
|
}(this)
|
|
|
|
class Room;
|
|
class BtCoroutine;
|
|
class BaseAgent : public behaviac::Agent
|
|
{
|
|
public:
|
|
BaseAgent();
|
|
|
|
virtual ~BaseAgent();
|
|
|
|
BEHAVIAC_DECLARE_AGENTTYPE(BaseAgent, behaviac::Agent)
|
|
|
|
void Exec();
|
|
|
|
bool IsGameOver();
|
|
int GetTickCount();
|
|
int RandRange(int min_val, int max_val);
|
|
float RandRangeAsFloat(float min_val, float max_val);
|
|
int Rand();
|
|
bool IsChiJiMode();
|
|
bool IsMobaMode();
|
|
int Test(int p1);
|
|
int DeltaTime(int time);
|
|
void AbortCoroutine(int co_id);
|
|
|
|
virtual Room* GetRoom() = 0;
|
|
behaviac::EBTStatus CoTest1(int time);
|
|
behaviac::EBTStatus CoTest(int time);
|
|
|
|
protected:
|
|
bool PreEnterCoroutine(int co_id, behaviac::EBTStatus& status);
|
|
behaviac::EBTStatus StartCoroutine(std::shared_ptr<BtCoroutine> co);
|
|
void CheckCoroutineEvent();
|
|
|
|
protected:
|
|
std::map<int, std::shared_ptr<BtCoroutine>> coroutines_hash_;
|
|
list_head coroutines_list_;
|
|
};
|