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