1
This commit is contained in:
parent
439ac933e0
commit
46cc7088a5
@ -52,6 +52,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomWalk()
|
|||||||
CreatureWeakPtr last_attacker;
|
CreatureWeakPtr last_attacker;
|
||||||
long long last_attacked_frameno = 0;
|
long long last_attacked_frameno = 0;
|
||||||
std::weak_ptr<EventHandlerPtr> handler;
|
std::weak_ptr<EventHandlerPtr> handler;
|
||||||
|
std::vector<std::shared_ptr<BtEvent>> events;
|
||||||
);
|
);
|
||||||
|
|
||||||
context->owner = GetOwner()->GetWeakPtrRef();
|
context->owner = GetOwner()->GetWeakPtrRef();
|
||||||
|
@ -16,14 +16,26 @@
|
|||||||
#include "mt/Hero.h"
|
#include "mt/Hero.h"
|
||||||
#include "mt/Param.h"
|
#include "mt/Param.h"
|
||||||
|
|
||||||
|
std::shared_ptr<BtEvent> BtEvent::Create(int event_id,
|
||||||
|
a8::Args event_params,
|
||||||
|
std::function<bool()> has_event_cb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return std::make_shared<BtEvent>(
|
||||||
|
event_id,
|
||||||
|
event_params,
|
||||||
|
has_event_cb
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void BtEvent::FireEvent(BaseAgent* agent)
|
void BtEvent::FireEvent(BaseAgent* agent)
|
||||||
{
|
{
|
||||||
switch (event_id) {
|
switch (event_id_) {
|
||||||
case kBetOnAttack:
|
case kBetOnAttack:
|
||||||
{
|
{
|
||||||
agent->FireEvent("OnAttacked",
|
agent->FireEvent("OnAttacked",
|
||||||
event_params.at(0).GetInt(),
|
event_params_.Get<int>(0),
|
||||||
event_params.at(1).GetInt64());
|
event_params_.Get<long long>(1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kBetOnCrazeMode:
|
case kBetOnCrazeMode:
|
||||||
|
@ -28,13 +28,29 @@ enum BtEventType_e
|
|||||||
};
|
};
|
||||||
|
|
||||||
class BaseAgent;
|
class BaseAgent;
|
||||||
struct BtEvent
|
class BtEvent
|
||||||
{
|
{
|
||||||
int event_id = 0;
|
public:
|
||||||
std::vector<a8::XValue> event_params;
|
int GetEventId() const { return event_id_; }
|
||||||
std::function<bool()> has_event_cb;
|
const a8::Args& GetParams() const { return event_params_; }
|
||||||
|
bool HasEvent() const { return has_event_cb_(); }
|
||||||
|
|
||||||
void FireEvent(BaseAgent* agent);
|
void FireEvent(BaseAgent* agent);
|
||||||
|
|
||||||
|
static std::shared_ptr<BtEvent> Create(int event_id,
|
||||||
|
a8::Args event_params,
|
||||||
|
std::function<bool()> has_event_cb
|
||||||
|
);
|
||||||
|
|
||||||
|
BtEvent(int event_id,
|
||||||
|
a8::Args event_params,
|
||||||
|
std::function<bool()> has_event_cb):
|
||||||
|
event_id_(event_id), event_params_(event_params), has_event_cb_(has_event_cb) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int event_id_ = 0;
|
||||||
|
a8::Args event_params_;
|
||||||
|
std::function<bool()> has_event_cb_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Creature;
|
class Creature;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user