添加延迟刷

This commit is contained in:
aozhiwei 2020-05-25 15:13:32 +08:00
parent 4372d054fb
commit 12d906f9f3
2 changed files with 60 additions and 3 deletions

View File

@ -18,6 +18,7 @@ enum HumanStatus
{
HS_AlreadyLordMode = 1,
HS_Disable = 2,
HS_NewBieNpc = 3,
HS_End
};

View File

@ -1744,7 +1744,7 @@ void Room::DisableHuman(Human* target)
void Room::ShuaNewBieAndroid(Human* target)
{
#ifdef DEBUG
#ifdef DEBUG
a8::UdpLog::Instance()->Debug("ShuaNewBieAndroid %s %s",
{
target->account_id,
@ -1765,12 +1765,41 @@ void Room::ShuaNewBieAndroid(Human* target)
}
}
hum->SetPos(pos);
a8::SetBitFlag(hum->status, HS_NewBieNpc);
EnableHuman(hum);
break;
}
}
ShuaAndroidTimerFunc();
DieAndroidTimerFunc();
{
int shua_time = a8::RandEx(
MetaMgr::Instance()->level0room_shua_robot_min_time,
MetaMgr::Instance()->level0room_shua_robot_max_time
);
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * (shua_time),
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->ShuaAndroidTimerFunc();
},
&xtimer_attacher_.timer_list_);
}
{
int die_time = a8::RandEx(
MetaMgr::Instance()->level0room_die_robot_min_time,
MetaMgr::Instance()->level0room_die_robot_max_time
);
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * (die_time),
a8::XParams()
.SetSender(this),
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->DieAndroidTimerFunc();
},
&xtimer_attacher_.timer_list_);
}
}
void Room::ShuaAndroidTimerFunc()
@ -1876,10 +1905,37 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num)
shua_num
});
#endif
Human* target = nullptr;
for (auto& pair : accountid_hash_) {
if (!pair.second->real_dead) {
target = pair.second;
break;
}
}
if (!target) {
return;
}
int refreshed_num = 0;
for (auto& pair : human_hash_) {
if (pair.second->entity_subtype == EST_Android &&
a8::HasBitFlag(pair.second->status, HS_Disable)) {
Android* hum = (Android*)pair.second;
a8::Vec2 pos = target->GetPos();
pos.x -= MetaMgr::Instance()->newbie_first_robot_distance;
if (grid_service->BroderOverFlow(pos.x, pos.y)) {
a8::Vec2 pos = target->GetPos();
pos.x += MetaMgr::Instance()->newbie_first_robot_distance;
if (grid_service->BroderOverFlow(pos.x, pos.y)) {
break;
}
}
hum->SetPos(pos);
a8::SetBitFlag(hum->status, HS_NewBieNpc);
EnableHuman(hum);
++refreshed_num;
if (refreshed_num >= shua_num) {
break;
}
}
}
}