This commit is contained in:
aozhiwei 2023-04-20 14:09:13 +08:00
parent d530ef29da
commit bf0c5abcc2

View File

@ -92,14 +92,60 @@ void Guide::ProcMoveTargetAndPickup()
NextStep(); NextStep();
return; return;
} }
for (auto& tuple : curr_step_meta_->_params) { auto context = A8_MAKE_ANON_STRUCT_SHARED
owner_->room->CreateLoot( (
std::get<2>(tuple), std::vector<int> loots;
std::get<1>(tuple), );
1,
1 {
); int i = 0;
for (auto& tuple : curr_step_meta_->_params) {
int time = std::get<0>(tuple);
glm::vec3 pos = std::get<1>(tuple);
int equip_id = std::get<2>(tuple);
context->loots.push_back(-1);
owner_->room->xtimer.SetTimeoutEx
(
time / FRAME_RATE_MS,
[this, equip_id, pos, context, i ] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
context->loots[i] = owner_->room->CreateLoot
(
equip_id,
pos,
1,
1
);
}
},
&owner_->xtimer_attacher);
}
} }
owner_->room->xtimer.SetTimeoutEx
(1,
[this, context] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
bool done = true;
for (int loot_uniid : context->loots) {
if (loot_uniid == -1) {
done = false;
break;
}
if (owner_->room->GetEntityByUniId(loot_uniid)) {
done = false;
break;
}
}
if (done) {
NextStep();
}
}
},
&owner_->xtimer_attacher);
} }
void Guide::ProcKillEnemy() void Guide::ProcKillEnemy()
@ -117,7 +163,6 @@ void Guide::ProcUseSkill()
} }
void Guide::NextStep() void Guide::NextStep()
{ {
++curr_step_idx_; ++curr_step_idx_;