From 0ebf7c239224107d13add3783dad5f12fef9a0ef Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 25 Oct 2021 20:23:18 +0800 Subject: [PATCH] 1 --- server/gameserver/roomobstacle.cc | 43 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/server/gameserver/roomobstacle.cc b/server/gameserver/roomobstacle.cc index 0619121..1e79d25 100644 --- a/server/gameserver/roomobstacle.cc +++ b/server/gameserver/roomobstacle.cc @@ -690,24 +690,8 @@ void RoomObstacle::InstallPreExplostionSummonTimer() int base_time = 0; pos_list = std::make_shared>(); 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; { - 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(); }