1
This commit is contained in:
parent
9484b8dc14
commit
b9bfdd4371
@ -37,17 +37,39 @@ behaviac::EBTStatus BaseAgent::DoRunningCb()
|
||||
return status_;
|
||||
}
|
||||
|
||||
behaviac::EBTStatus BaseAgent::StartCoroutine(std::function<behaviac::EBTStatus()> cb)
|
||||
{
|
||||
status_runing_cb_ = std::move(cb);
|
||||
status_ = behaviac::BT_RUNNING;
|
||||
return status_;
|
||||
}
|
||||
|
||||
behaviac::EBTStatus BaseAgent::CoAttackTarget(int target_id)
|
||||
{
|
||||
if (status_ == behaviac::BT_RUNNING) {
|
||||
return DoRunningCb();
|
||||
}
|
||||
status_runing_cb_ =
|
||||
[this] () mutable
|
||||
Entity* entity = GetOwner()->room->GetEntityByUniId(target_id);
|
||||
if (!entity || !entity->IsCreature(GetOwner()->room)) {
|
||||
return behaviac::BT_FAILURE;
|
||||
}
|
||||
CreatureWeakPtr target = ((Creature*)entity)->GetWeakPtrRef();
|
||||
if (target.Get()->dead) {
|
||||
return behaviac::BT_FAILURE;
|
||||
}
|
||||
|
||||
long long frameno = GetOwner()->room->GetFrameNo();
|
||||
long long last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
return StartCoroutine
|
||||
(
|
||||
[this, target, frameno, last_pursuit_frameno] () mutable
|
||||
{
|
||||
return status_;
|
||||
};
|
||||
status_ = behaviac::BT_RUNNING;
|
||||
return status_;
|
||||
if (GetOwner()->room->GetFrameNo() - frameno > SERVER_FRAME_RATE * 10 ||
|
||||
!target.Get() || target.Get()->dead) {
|
||||
return behaviac::BT_SUCCESS;
|
||||
} else {
|
||||
}
|
||||
return behaviac::BT_RUNNING;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public:
|
||||
|
||||
protected:
|
||||
behaviac::EBTStatus DoRunningCb();
|
||||
behaviac::EBTStatus StartCoroutine(std::function<behaviac::EBTStatus()> cb);
|
||||
|
||||
protected:
|
||||
behaviac::EBTStatus status_= behaviac::BT_SUCCESS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user