This commit is contained in:
aozhiwei 2021-10-25 20:23:18 +08:00
parent 557395c20d
commit 0ebf7c2392

View File

@ -690,24 +690,8 @@ void RoomObstacle::InstallPreExplostionSummonTimer()
int base_time = 0;
pos_list = std::make_shared<std::vector<a8::Vec2>>();
for (int i = 0; i < total_explosion_times_; ++i) {
for (auto& tuple : meta->preexplosion_summon) {
int time = std::get<0>(tuple);
int obstacle_id = std::get<1>(tuple);
room->xtimer.AddDeadLineTimerAndAttach
(
(base_time + time) / FRAME_RATE_MS,
a8::XParams()
.SetSender(this)
.SetParam1(obstacle_id),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
},
&xtimer_attacher.timer_list_
);
}//end for tuple
{
a8::Vec2 bomb_born_offset = a8::Vec2::UP;
{
bomb_born_offset.Rotate(a8::RandAngle());
bomb_born_offset = bomb_born_offset * a8::RandEx(1, std::max(2, meta->i->explosion_float()));
a8::Vec2 bomb_pos = GetPos() + bomb_born_offset;
@ -717,6 +701,31 @@ void RoomObstacle::InstallPreExplostionSummonTimer()
pos_list->push_back(a8::Vec2());
}
}
for (auto& tuple : meta->preexplosion_summon) {
int time = std::get<0>(tuple);
int obstacle_id = std::get<1>(tuple);
room->xtimer.AddDeadLineTimerAndAttach
(
(base_time + time) / FRAME_RATE_MS,
a8::XParams()
.SetSender(this)
.SetParam1(obstacle_id)
.SetParam2(bomb_born_offset.x)
.SetParam3(bomb_born_offset.y),
[] (const a8::XParams& param)
{
RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData();
obstacle->room->CreateObstacle
(
param.param1,
obstacle->GetPos().x + param.param2.GetDouble(),
obstacle->GetPos().y + param.param3.GetDouble()
);
obstacle->Active();
},
&xtimer_attacher.timer_list_
);
}//end for tuple
}
base_time += meta->i->explosion_interval();
}