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;
|
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,
|
void GridService::GetGridList(int grid_id, int offset,
|
||||||
std::set<GridCell*>& grid_list)
|
std::set<GridCell*>& grid_list)
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,7 @@ class GridService
|
|||||||
bool HumanInGridList(Human* hum, std::set<GridCell*>& grid_list);
|
bool HumanInGridList(Human* hum, std::set<GridCell*>& grid_list);
|
||||||
bool EntityInGridList(Room* room, Entity* entity, 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 a_grid, int b_grid);
|
||||||
|
bool InView(int grid_id, float x, float y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void GetGridList(int grid_id, int offset,
|
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)
|
void Human::FillMFActivePlayerData(cs::MFActivePlayerData* player_data)
|
||||||
|
@ -141,6 +141,8 @@ class Human : public MoveableEntity
|
|||||||
bool playing_skill = false;
|
bool playing_skill = false;
|
||||||
xtimer_list* ad_timer_ = nullptr;
|
xtimer_list* ad_timer_ = nullptr;
|
||||||
|
|
||||||
|
std::function<void(Human*)> on_grid_chg;
|
||||||
|
|
||||||
Human();
|
Human();
|
||||||
virtual ~Human() override;
|
virtual ~Human() override;
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
|
@ -1711,6 +1711,8 @@ void Room::NotifyGameStart()
|
|||||||
pair.second->SendNotifyMsg(msg);
|
pair.second->SendNotifyMsg(msg);
|
||||||
if (room_type == RT_NewBrid) {
|
if (room_type == RT_NewBrid) {
|
||||||
first_newbie = pair.second;
|
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,
|
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);
|
void CheckAutoDie(Human* hum, int autodie_time, int autodie_distance, int check_times);
|
||||||
bool HasPlayerInRound(const a8::Vec2& pos, float rad);
|
bool HasPlayerInRound(const a8::Vec2& pos, float rad);
|
||||||
void ProcDisableHuman();
|
void ProcDisableHuman();
|
||||||
|
void OnHumanGridChg(Human* target);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int elapsed_time_ = 0;
|
int elapsed_time_ = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user