1
This commit is contained in:
parent
507372a550
commit
006154f6af
@ -278,6 +278,12 @@ bool GridService::InView(int a_grid, int b_grid)
|
||||
a_grid + grid_offset_arr_[8] == b_grid;
|
||||
}
|
||||
|
||||
bool GridService::InView(int grid_id, float x, float y)
|
||||
{
|
||||
int b_grid_id = grid_id = x/cell_width_ + (y/cell_width_) * cell_count_per_row_;
|
||||
return InView(grid_id, b_grid_id);
|
||||
}
|
||||
|
||||
void GridService::GetGridList(int grid_id, int offset,
|
||||
std::set<GridCell*>& grid_list)
|
||||
{
|
||||
|
@ -45,6 +45,7 @@ class GridService
|
||||
bool HumanInGridList(Human* hum, std::set<GridCell*>& grid_list);
|
||||
bool EntityInGridList(Room* room, Entity* entity, std::set<GridCell*>& grid_list);
|
||||
bool InView(int a_grid, int b_grid);
|
||||
bool InView(int grid_id, float x, float y);
|
||||
|
||||
private:
|
||||
inline void GetGridList(int grid_id, int offset,
|
||||
|
@ -1323,6 +1323,9 @@ void Human::OnGridListChange(std::set<GridCell*>& old_grid_list,
|
||||
}
|
||||
}
|
||||
}
|
||||
if (IsPlayer() && on_grid_chg) {
|
||||
on_grid_chg(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
||||
|
@ -141,6 +141,8 @@ class Human : public MoveableEntity
|
||||
bool playing_skill = false;
|
||||
xtimer_list* ad_timer_ = nullptr;
|
||||
|
||||
std::function<void(Human*)> on_grid_chg;
|
||||
|
||||
Human();
|
||||
virtual ~Human() override;
|
||||
virtual void Initialize() override;
|
||||
|
@ -1711,6 +1711,8 @@ void Room::NotifyGameStart()
|
||||
pair.second->SendNotifyMsg(msg);
|
||||
if (room_type == RT_NewBrid) {
|
||||
first_newbie = pair.second;
|
||||
} else if (room_type == RT_MidBrid) {
|
||||
pair.second->on_grid_chg = std::bind(&Room::OnHumanGridChg, this, std::placeholders::_1);
|
||||
}
|
||||
}
|
||||
xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 1,
|
||||
@ -2233,3 +2235,18 @@ void Room::ProcDisableHuman()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::OnHumanGridChg(Human* target)
|
||||
{
|
||||
for (auto& pair : human_hash_) {
|
||||
Human* hum = pair.second;
|
||||
if (hum->IsAndroid() &&
|
||||
a8::HasBitFlag(hum->status, HS_Disable) &&
|
||||
!hum->real_dead &&
|
||||
hum->team_uuid.empty() &&
|
||||
grid_service->InView(target->grid_id, hum->GetPos().x, hum->GetPos().y)
|
||||
) {
|
||||
EnableHuman(hum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ private:
|
||||
void CheckAutoDie(Human* hum, int autodie_time, int autodie_distance, int check_times);
|
||||
bool HasPlayerInRound(const a8::Vec2& pos, float rad);
|
||||
void ProcDisableHuman();
|
||||
void OnHumanGridChg(Human* target);
|
||||
|
||||
private:
|
||||
int elapsed_time_ = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user