1
This commit is contained in:
parent
a953ede096
commit
55f96a8a05
@ -1284,6 +1284,10 @@ int HeroAgent::SearchPickupObj()
|
||||
(
|
||||
[this, &nearest_obj] (Entity* e, bool& stop) mutable
|
||||
{
|
||||
if (abandon_pickup_hash_.find(e->GetUniId()) !=
|
||||
abandon_pickup_hash_.end()) {
|
||||
return;
|
||||
}
|
||||
if (!nearest_obj) {
|
||||
nearest_obj = e;
|
||||
return;
|
||||
@ -1302,6 +1306,10 @@ int HeroAgent::SearchPickupObj()
|
||||
(
|
||||
[this, &nearest_obj] (Creature* e, bool& stop) mutable
|
||||
{
|
||||
if (abandon_pickup_hash_.find(e->GetUniId()) !=
|
||||
abandon_pickup_hash_.end()) {
|
||||
return;
|
||||
}
|
||||
if (!e->IsCar()) {
|
||||
return;
|
||||
}
|
||||
@ -1365,6 +1373,21 @@ bool HeroAgent::PickupObjIsValid()
|
||||
|
||||
void HeroAgent::AbandonPickup(int min_time, int max_time)
|
||||
{
|
||||
if (curr_pickup_obj_.Get()) {
|
||||
int val = a8::RandEx(min_time, max_time);
|
||||
int obj_uniid = curr_pickup_obj_.Get()->GetUniId();
|
||||
abandon_pickup_hash_[obj_uniid]= obj_uniid;
|
||||
owner_->room->xtimer.SetTimeoutWpEx
|
||||
(
|
||||
val / FRAME_RATE_MS,
|
||||
[this, obj_uniid] (int event, const a8::Args* args)
|
||||
{
|
||||
if (a8::TIMER_EXEC_EVENT == event) {
|
||||
abandon_pickup_hash_.erase(obj_uniid);
|
||||
}
|
||||
},
|
||||
&owner_->xtimer_attacher);
|
||||
}
|
||||
curr_pickup_obj_.Reset();
|
||||
}
|
||||
|
||||
@ -1410,8 +1433,12 @@ behaviac::EBTStatus HeroAgent::Pickup()
|
||||
} else {
|
||||
Car* car = curr_pickup_obj_.Get()->AsCar();
|
||||
owner_->AsHuman()->DoGetOn(car->GetUniId());
|
||||
if (owner_->GetCar()) {
|
||||
owner_->GetCar()->SetAttackDir(owner_->GetAttackDir());
|
||||
}
|
||||
}
|
||||
}
|
||||
AbandonPickup(1000 * 30, 1000 * 60);
|
||||
return behaviac::BT_SUCCESS;
|
||||
};
|
||||
return StartCoroutine(co);
|
||||
|
@ -160,4 +160,5 @@ private:
|
||||
int bullet_angle_offset_min_ = 0;
|
||||
int bullet_angle_offset_max_ = 0;
|
||||
long long last_try_search_enemy_frameno_ = 0;
|
||||
std::map<int, int> abandon_pickup_hash_;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user