rename Touch Traverse

This commit is contained in:
aozhiwei 2021-05-25 13:17:19 +08:00
parent ccfac5455b
commit 57e999aea9
25 changed files with 135 additions and 135 deletions

View File

@ -306,7 +306,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic()
target = hum->last_human_target;
} else {
if (rand() % 100 < 70) {
hum->room->TouchPlayerList
hum->room->TraversePlayerList
(
a8::XParams(),
[hum, &target] (Player* player, a8::XParams& param)
@ -323,7 +323,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic()
}
});
} else {
hum->room->TouchHumanList
hum->room->TraverseHumanList
(
a8::XParams(),
[hum, &target] (Human* huma, a8::XParams& param)
@ -718,7 +718,7 @@ Creature* AndroidNewAI::GetTarget()
}
Creature* target = nullptr;
myself->TouchProperTargets
myself->TraverseProperTargets
(
[myself, &target] (Creature* hum, bool& stop)
{

View File

@ -59,7 +59,7 @@ void Bullet::ProcBomb()
{
self_collider_->rad = gun_meta->i->explosion_range();
std::set<Entity*> objects;
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, &objects] (Human* hum, bool& stop)
{
@ -75,7 +75,7 @@ void Bullet::ProcBomb()
}
}
});
TouchAllLayerEntityList
TraverseAllLayerEntityList
(
[this, &objects] (Entity* entity, bool& stop)
{
@ -232,7 +232,7 @@ float Bullet::GetAtk()
void Bullet::Check(float distance)
{
std::set<Entity*> objects;
room->grid_service->TouchCreatures
room->grid_service->TraverseCreatures
(room->GetRoomIdx(),
GetGridList(),
[this, &objects] (Creature* c, bool& stop)

View File

@ -318,7 +318,7 @@ void Car::Explosion(int team_id)
return;
}
std::set<Creature*> objects;
TouchProperTargets
TraverseProperTargets
(
[this, &objects, team_id] (Creature* c, bool& stop)
{

View File

@ -1119,7 +1119,7 @@ bool Creature::IsEnemy(Creature* target)
}
}
void Creature::TouchProperTargets(std::function<void (Creature*, bool&)> func)
void Creature::TraverseProperTargets(std::function<void (Creature*, bool&)> func)
{
auto callback =
[this, func] (Creature* c, bool& stop)
@ -1128,7 +1128,7 @@ void Creature::TouchProperTargets(std::function<void (Creature*, bool&)> func)
func(c, stop);
}
};
room->grid_service->TouchCreatures(room->GetRoomIdx(),
room->grid_service->TraverseCreatures(room->GetRoomIdx(),
GetGridList(),
callback);
}
@ -1732,7 +1732,7 @@ float Creature::GetMaxHP()
void Creature::GetHitEnemys(std::set<Creature*>& enemys)
{
room->grid_service->TouchCreatures
room->grid_service->TraverseCreatures
(room->GetRoomIdx(),
GetGridList(),
[this, &enemys] (Creature* c, bool& stop)

View File

@ -124,7 +124,7 @@ class Creature : public MoveableEntity
int GetActionType() { return action_type; }
int GetActionTargetId() { return action_target_id; }
void TouchProperTargets(std::function<void (Creature*, bool&)> func);
void TraverseProperTargets(std::function<void (Creature*, bool&)> func);
CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; };
void Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance);

View File

@ -95,7 +95,7 @@ void Entity::BroadcastFullState(Room* room)
{
std::set<GridCell*> tmp_grids;
room->grid_service->GetAllCells(room, grid_id_, tmp_grids);
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
tmp_grids,
@ -108,7 +108,7 @@ void Entity::BroadcastFullState(Room* room)
void Entity::BroadcastDeleteState(Room* room)
{
#if 0
room->TouchHumanList
room->TraverseHumanList
(
a8::XParams(),
[this] (Human* hum, a8::XParams& param) -> bool
@ -119,7 +119,7 @@ void Entity::BroadcastDeleteState(Room* room)
#else
std::set<GridCell*> tmp_grids;
room->grid_service->GetAllCells(room, grid_id_, tmp_grids);
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
tmp_grids,
@ -133,7 +133,7 @@ void Entity::BroadcastDeleteState(Room* room)
void Entity::RemoveFromAroundPlayers(Room* room)
{
#if 1
room->TouchHumanList
room->TraverseHumanList
(
a8::XParams(),
[this] (Human* hum, a8::XParams& param) -> bool
@ -144,7 +144,7 @@ void Entity::RemoveFromAroundPlayers(Room* room)
#else
std::set<GridCell*> tmp_grids;
room->grid_service->GetAllCells(room, grid_id_, tmp_grids);
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
tmp_grids,

View File

@ -27,7 +27,7 @@ void FragMiTask::Done()
grid_list
);
std::set<Creature*> objects;
sender.Get()->room->grid_service->TouchCreatures
sender.Get()->room->grid_service->TraverseCreatures
(
sender.Get()->room->GetRoomIdx(),
grid_list,
@ -41,7 +41,7 @@ void FragMiTask::Done()
}
);
std::set<Entity*> entitys;
sender.Get()->room->grid_service->TouchAllLayerEntityList
sender.Get()->room->grid_service->TraverseAllLayerEntityList
(
sender.Get()->room->GetRoomIdx(),
grid_list,

View File

@ -29,7 +29,7 @@ void FrameEvent::AddEmote(Human* sender, int emote_id)
}
{
int emote_idx = emotes_.size() - 1;
sender->TouchAllLayerHumanList
sender->TraverseAllLayerHumanList
(
[emote_idx] (Human* hum, bool& stop)
{
@ -60,7 +60,7 @@ void FrameEvent::AddShot(Creature* sender)
}
{
int shot_idx = shots_.size() - 1;
sender->TouchAllLayerHumanList
sender->TraverseAllLayerHumanList
(
[shot_idx] (Human* hum, bool& stop)
{
@ -94,7 +94,7 @@ void FrameEvent::AddBullet(Creature* sender,
}
{
int bullet_idx = bullets_.size() - 1;
sender->TouchAllLayerHumanList
sender->TraverseAllLayerHumanList
(
[bullet_idx] (Human* hum, bool& stop)
{
@ -125,7 +125,7 @@ void FrameEvent::AddExplosionEx(CreatureWeakPtr& sender, int item_id, a8::Vec2 b
}
{
int explosion_idx = explosions_.size() - 1;
sender.Get()->TouchAllLayerHumanList
sender.Get()->TraverseAllLayerHumanList
(
[explosion_idx] (Human* hum, bool& stop)
{
@ -157,7 +157,7 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos)
}
{
int idx = smokes_.size() - 1;
bullet->sender.Get()->TouchAllLayerHumanList
bullet->sender.Get()->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{
@ -180,7 +180,7 @@ void FrameEvent::AddPlaySkill(CreatureWeakPtr& sender, int skill_id)
}
{
int idx = play_skills_.size() - 1;
sender.Get()->TouchAllLayerHumanList
sender.Get()->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{
@ -193,7 +193,7 @@ void FrameEvent::AddHpChg(CreatureWeakPtr& sender)
{
chged_hps_.push_back(sender);
int idx = chged_hps_.size() - 1;
sender.Get()->TouchAllLayerHumanList
sender.Get()->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{
@ -227,7 +227,7 @@ void FrameEvent::AddBuff(CreatureWeakPtr& sender, Buff* buff)
}
{
int idx = chged_buffs_.size() - 1;
sender.Get()->TouchAllLayerHumanList
sender.Get()->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{
@ -247,7 +247,7 @@ void FrameEvent::RemoveBuff(CreatureWeakPtr& sender, int buff_id)
}
{
int idx = chged_buffs_.size() - 1;
sender.Get()->TouchAllLayerHumanList
sender.Get()->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{
@ -286,7 +286,7 @@ void FrameEvent::AddZombieIdChg(Human* sender)
chged_zombieids_.push_back(sender);
int idx = chged_zombieids_.size() - 1;
{
sender->TouchAllLayerHumanList
sender->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{
@ -310,7 +310,7 @@ void FrameEvent::AddDead(CreatureWeakPtr& sender, int revive_time)
}
{
int dead_idx = dead_alive_objs_.size() - 1;
sender.Get()->TouchAllLayerHumanList
sender.Get()->TraverseAllLayerHumanList
(
[dead_idx] (Human* hum, bool& stop)
{
@ -334,7 +334,7 @@ void FrameEvent::AddRevive(CreatureWeakPtr& sender)
}
{
int revive_idx = dead_alive_objs_.size() - 1;
sender.Get()->TouchAllLayerHumanList
sender.Get()->TraverseAllLayerHumanList
(
[revive_idx] (Human* hum, bool& stop)
{
@ -348,7 +348,7 @@ void FrameEvent::AddCarChg(Human* sender)
{
chged_cars_.push_back(sender);
int idx = chged_cars_.size() - 1;
sender->TouchAllLayerHumanList
sender->TraverseAllLayerHumanList
(
[idx] (Human* hum, bool& stop)
{

View File

@ -29,7 +29,7 @@ void GridCell::ClearRoomData(Room* room)
creatures_[room->GetRoomIdx()].clear();
}
void GridCell::TouchHumanList(std::function<void (Human*, bool&)> func,
void GridCell::TraverseHumanList(std::function<void (Human*, bool&)> func,
int room_idx,
bool& stop)
{
@ -45,7 +45,7 @@ void GridCell::TouchHumanList(std::function<void (Human*, bool&)> func,
}
}
void GridCell::TouchCreatures(std::function<void (Creature*, bool&)>& func,
void GridCell::TraverseCreatures(std::function<void (Creature*, bool&)>& func,
int room_idx,
bool& stop)
{
@ -91,7 +91,7 @@ bool GridCell::EntityExists(Room* room, Entity* entity)
entitys_[room->GetRoomIdx()].end();
}
void GridCell::TouchLayer0EntityList(std::function<void (Entity*, bool&)>& func,
void GridCell::TraverseLayer0EntityList(std::function<void (Entity*, bool&)>& func,
bool& stop)
{
for (Entity* entity : entitys_[0]) {
@ -102,7 +102,7 @@ void GridCell::TouchLayer0EntityList(std::function<void (Entity*, bool&)>& func,
}
}
void GridCell::TouchLayer1EntityList(std::function<void (Entity*, bool&)>& func,
void GridCell::TraverseLayer1EntityList(std::function<void (Entity*, bool&)>& func,
int room_idx,
bool& stop)
{
@ -114,13 +114,13 @@ void GridCell::TouchLayer1EntityList(std::function<void (Entity*, bool&)>& func,
}
}
void GridCell::TouchAllLayerEntityList(std::function<void (Entity*, bool&)>& func,
void GridCell::TraverseAllLayerEntityList(std::function<void (Entity*, bool&)>& func,
int room_idx,
bool& stop)
{
TouchLayer0EntityList(func, stop);
TraverseLayer0EntityList(func, stop);
if (!stop) {
TouchLayer1EntityList(func, room_idx, stop);
TraverseLayer1EntityList(func, room_idx, stop);
}
}

View File

@ -13,10 +13,10 @@ public:
GridCell();
void ClearRoomData(Room* room);
void TouchHumanList(std::function<void (Human*, bool&)> func,
void TraverseHumanList(std::function<void (Human*, bool&)> func,
int room_idx,
bool& stop);
void TouchCreatures(std::function<void (Creature*, bool&)>& func,
void TraverseCreatures(std::function<void (Creature*, bool&)>& func,
int room_idx,
bool& stop);
@ -29,12 +29,12 @@ public:
void AddRoomEntity(Room* room, Entity* entity);
void RemoveRoomEntity(Room* room, Entity* entity);
bool EntityExists(Room* room, Entity* Entity);
void TouchLayer0EntityList(std::function<void (Entity*, bool&)>& func,
void TraverseLayer0EntityList(std::function<void (Entity*, bool&)>& func,
bool& stop);
void TouchLayer1EntityList(std::function<void (Entity*, bool&)>& func,
void TraverseLayer1EntityList(std::function<void (Entity*, bool&)>& func,
int room_idx,
bool& stop);
void TouchAllLayerEntityList(std::function<void (Entity*, bool&)>& func,
void TraverseAllLayerEntityList(std::function<void (Entity*, bool&)>& func,
int room_idx,
bool& stop);

View File

@ -327,64 +327,64 @@ void GridService::ComputeDiff(Room* room,
GetAllCells(room, new_grid_id, grid_list);
}
void GridService::TouchLayer0EntityList(std::set<GridCell*>& grid_list,
void GridService::TraverseLayer0EntityList(std::set<GridCell*>& grid_list,
std::function<void (Entity*, bool&)> func)
{
bool stop = false;
for (auto& cell : grid_list) {
cell->TouchLayer0EntityList(func, stop);
cell->TraverseLayer0EntityList(func, stop);
if (stop) {
return;
}
}
}
void GridService::TouchLayer1EntityList(int room_idx,
void GridService::TraverseLayer1EntityList(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Entity*, bool&)> func)
{
bool stop = false;
for (auto& cell : grid_list) {
cell->TouchLayer1EntityList(func, room_idx, stop);
cell->TraverseLayer1EntityList(func, room_idx, stop);
if (stop) {
return;
}
}
}
void GridService::TouchAllLayerEntityList(int room_idx,
void GridService::TraverseAllLayerEntityList(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Entity*, bool&)> func)
{
bool stop = false;
for (auto& cell : grid_list) {
cell->TouchAllLayerEntityList(func, room_idx, stop);
cell->TraverseAllLayerEntityList(func, room_idx, stop);
if (stop) {
return;
}
}
}
void GridService::TouchAllLayerHumanList(int room_idx,
void GridService::TraverseAllLayerHumanList(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Human*, bool&)> func)
{
bool stop = false;
for (auto& cell : grid_list) {
cell->TouchHumanList(func, room_idx, stop);
cell->TraverseHumanList(func, room_idx, stop);
if (stop) {
return;
}
}
}
void GridService::TouchCreatures(int room_idx,
void GridService::TraverseCreatures(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Creature*, bool&)> func)
{
bool stop = false;
for (auto& cell : grid_list) {
cell->TouchCreatures(func, room_idx, stop);
cell->TraverseCreatures(func, room_idx, stop);
if (stop) {
return;
}
@ -395,7 +395,7 @@ void GridService::DeatchHuman(Human* target)
{
for (auto& cell : target->GetGridList()) {
bool stop = false;
cell->TouchHumanList
cell->TraverseHumanList
(
[target] (Human* hum, bool& stop)
{

View File

@ -38,18 +38,18 @@ class GridService
bool InView(int a_grid, int b_grid);
bool InView(int grid_id, float x, float y);
void TouchLayer0EntityList(std::set<GridCell*>& grid_list,
void TraverseLayer0EntityList(std::set<GridCell*>& grid_list,
std::function<void (Entity*, bool&)> func);
void TouchLayer1EntityList(int room_idx,
void TraverseLayer1EntityList(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Entity*, bool&)> func);
void TouchAllLayerEntityList(int room_idx,
void TraverseAllLayerEntityList(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Entity*, bool&)> func);
void TouchAllLayerHumanList(int room_idx,
void TraverseAllLayerHumanList(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Human*, bool&)> func);
void TouchCreatures(int room_idx,
void TraverseCreatures(int room_idx,
std::set<GridCell*>& grid_list,
std::function<void (Creature*, bool&)> func);
void DeatchHuman(Human* hum);

View File

@ -359,7 +359,7 @@ Creature* HeroAI::GetTarget()
}
Creature* target = nullptr;
myself->TouchProperTargets
myself->TraverseProperTargets
(
[myself, &target] (Creature* hum, bool& stop)
{

View File

@ -645,7 +645,7 @@ void Human::FillSMGameOver(cs::SMGameOver& msg)
{
if (stats.rank <= 0) {
std::vector<Human*> human_list;
room->TouchHumanList(a8::XParams(),
room->TraverseHumanList(a8::XParams(),
[&human_list] (Human* hum, a8::XParams& param) -> bool
{
if (hum->leave_frameno_ == 0 ||
@ -1034,7 +1034,7 @@ bool Human::HasNoDownedTeammate()
if (GetRace() == kHumanRace) {
bool has_now_downed_teammate = false;
Human* myself = this;
room->TouchHumanList
room->TraverseHumanList
(
a8::XParams(),
[myself, &has_now_downed_teammate] (Human* hum, const a8::XParams& param)
@ -1135,7 +1135,7 @@ void Human::DoGetOn(int obj_uniid)
void Human::FindLocation()
{
Entity* target = nullptr;
TouchAllLayerEntityList
TraverseAllLayerEntityList
(
[this, &target] (Entity* entity, bool& stop)
{
@ -1173,7 +1173,7 @@ void Human::FindLocation()
void Human::RefreshView()
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this] (Human* hum, bool& stop)
{
@ -1182,7 +1182,7 @@ void Human::RefreshView()
AddToNewObjects(hum);
AddToPartObjects(hum);
});
TouchAllLayerEntityList
TraverseAllLayerEntityList
(
[this] (Entity* entity, bool& stop)
{
@ -1234,7 +1234,7 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func)
});
#endif
#endif
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, file, line, func] (Human* hum, bool& stop)
{
@ -1534,7 +1534,7 @@ void Human::SendRollMsg(const std::string& msg, int killer_id, bool killer_team_
int killer_id = param.param1;
int killer_team_id = param.param2;
std::string text = param.param3.GetString();
target->room->TouchPlayerList
target->room->TraversePlayerList
(a8::XParams(),
[target, killer_id, killer_team_id, text] (Human* hum, a8::XParams& param) -> bool
{
@ -1979,7 +1979,7 @@ void Human::GenBattleReportData(a8::MutableXObject* params)
int rank = 0;
{
std::vector<Human*> human_list;
room->TouchHumanList(a8::XParams(),
room->TraverseHumanList(a8::XParams(),
[&human_list] (Human* hum, a8::XParams& param) -> bool
{
human_list.push_back(hum);
@ -2157,7 +2157,7 @@ void Human::GenZbModeBattleReportData(a8::MutableXObject* params)
int rank = 0;
{
std::vector<Human*> human_list;
room->TouchHumanList(a8::XParams(),
room->TraverseHumanList(a8::XParams(),
[&human_list] (Human* hum, a8::XParams& param) -> bool
{
human_list.push_back(hum);
@ -2449,7 +2449,7 @@ void Human::FindLocationWithTarget(Entity* target)
Entity* building = nullptr;
std::set<GridCell*> tmp_grids;
room->grid_service->GetAllCellsByXy(room, GetX(), GetY(), tmp_grids);
room->grid_service->TouchAllLayerEntityList
room->grid_service->TraverseAllLayerEntityList
(
room->GetRoomIdx(),
tmp_grids,
@ -2827,13 +2827,13 @@ void Human::OnDisable()
void Human::GetViewObjects(std::set<Entity*>& view_objects)
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[&view_objects] (Human* hum, bool& stop)
{
view_objects.insert(hum);
});
TouchAllLayerEntityList
TraverseAllLayerEntityList
(
[&view_objects] (Entity* entity, bool& stop)
{
@ -2896,7 +2896,7 @@ void Human::ProcIncGridList(std::set<GridCell*>& old_grids,
std::set<GridCell*>& inc_grids,
std::set<GridCell*>& dec_grids)
{
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
inc_grids,
@ -2911,7 +2911,7 @@ void Human::ProcIncGridList(std::set<GridCell*>& old_grids,
RemoveOutObjects(hum);
}
});
room->grid_service->TouchAllLayerEntityList
room->grid_service->TraverseAllLayerEntityList
(
room->GetRoomIdx(),
inc_grids,
@ -2938,7 +2938,7 @@ void Human::ProcDecGridList(std::set<GridCell*>& old_grids,
std::set<GridCell*>& inc_grids,
std::set<GridCell*>& dec_grids)
{
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
dec_grids,
@ -2958,7 +2958,7 @@ void Human::ProcDecGridList(std::set<GridCell*>& old_grids,
#endif
}
});
room->grid_service->TouchAllLayerEntityList
room->grid_service->TraverseAllLayerEntityList
(
room->GetRoomIdx(),
dec_grids,
@ -2985,7 +2985,7 @@ void Human::ProcDecGridList(std::set<GridCell*>& old_grids,
void Human::RemoveFromScene()
{
room->grid_service->DeatchHuman(this);
room->TouchHumanList
room->TraverseHumanList
(
a8::XParams()
.SetSender(this),
@ -3509,7 +3509,7 @@ void Human::UpdateViewObjects()
}
}
if (view_objects_.size() < 2) {
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this] (Human* hum, bool& stop)
{

View File

@ -80,7 +80,7 @@ void Incubator::RecycleAndroid(Human* hum)
Human* nearest_hum = nullptr;
Human* target = hum;
float distance = 10000000;
room->TouchAlivePlayers
room->TraverseAlivePlayers
(
a8::XParams(),
[&nearest_hum, target, &distance] (Human* hum, a8::XParams& param) -> bool
@ -129,7 +129,7 @@ bool Incubator::CanSet(Human* hum, Human* exclude_hum)
{
Human* target = hum;
bool can_set = true;
room->TouchAlivePlayers
room->TraverseAlivePlayers
(
a8::XParams(),
[target, exclude_hum, &can_set] (Human* hum, a8::XParams& param) -> bool

View File

@ -3,29 +3,29 @@
#include "room.h"
#include "human.h"
void MoveableEntity::TouchLayer0EntityList(std::function<void (Entity*, bool&)> func)
void MoveableEntity::TraverseLayer0EntityList(std::function<void (Entity*, bool&)> func)
{
room->grid_service->TouchLayer0EntityList(grid_list_, func);
room->grid_service->TraverseLayer0EntityList(grid_list_, func);
}
void MoveableEntity::TouchLayer1EntityList(std::function<void (Entity*, bool&)> func)
void MoveableEntity::TraverseLayer1EntityList(std::function<void (Entity*, bool&)> func)
{
room->grid_service->TouchLayer1EntityList(room->GetRoomIdx(), grid_list_, func);
room->grid_service->TraverseLayer1EntityList(room->GetRoomIdx(), grid_list_, func);
}
void MoveableEntity::TouchAllLayerEntityList(std::function<void (Entity*, bool&)> func)
void MoveableEntity::TraverseAllLayerEntityList(std::function<void (Entity*, bool&)> func)
{
room->grid_service->TouchAllLayerEntityList(room->GetRoomIdx(), grid_list_, func);
room->grid_service->TraverseAllLayerEntityList(room->GetRoomIdx(), grid_list_, func);
}
void MoveableEntity::TouchAllLayerHumanList(std::function<void (Human*, bool&)> func)
void MoveableEntity::TraverseAllLayerHumanList(std::function<void (Human*, bool&)> func)
{
room->grid_service->TouchAllLayerHumanList(room->GetRoomIdx(), grid_list_, func);
room->grid_service->TraverseAllLayerHumanList(room->GetRoomIdx(), grid_list_, func);
}
void MoveableEntity::RefreshView()
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this] (Human* hum, bool& stop)
{
@ -40,7 +40,7 @@ void MoveableEntity::OnGridListChange(std::set<GridCell*>& old_grids,
)
{
{
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
inc_grids,
@ -54,7 +54,7 @@ void MoveableEntity::OnGridListChange(std::set<GridCell*>& old_grids,
});
}
{
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
dec_grids,
@ -69,7 +69,7 @@ void MoveableEntity::OnGridListChange(std::set<GridCell*>& old_grids,
void MoveableEntity::SyncAroundPlayers(const char* file, int line, const char* func)
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, file, line, func] (Human* hum, bool& stop)
{

View File

@ -13,10 +13,10 @@ class MoveableEntity : public RoomEntity
int UpdatedTimes() { return updated_times_;}
std::set<GridCell*>& GetGridList() { return grid_list_; }
void TouchLayer0EntityList(std::function<void (Entity*, bool&)> func);
void TouchLayer1EntityList(std::function<void (Entity*, bool&)> func);
void TouchAllLayerEntityList(std::function<void (Entity*, bool&)> func);
void TouchAllLayerHumanList(std::function<void (Human*, bool&)> func);
void TraverseLayer0EntityList(std::function<void (Entity*, bool&)> func);
void TraverseLayer1EntityList(std::function<void (Entity*, bool&)> func);
void TraverseAllLayerEntityList(std::function<void (Entity*, bool&)> func);
void TraverseAllLayerHumanList(std::function<void (Human*, bool&)> func);
virtual void RefreshView();
virtual void OnGridListChange(std::set<GridCell*>& old_grids,

View File

@ -259,7 +259,7 @@ void Obstacle::Explosion(Bullet* bullet)
std::set<Entity*> objects;
std::set<GridCell*> tmp_grids;
room->grid_service->GetAllCellsByXy(room, GetX(), GetY(), tmp_grids);
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
tmp_grids,
@ -269,7 +269,7 @@ void Obstacle::Explosion(Bullet* bullet)
objects.insert(hum);
}
});
room->grid_service->TouchAllLayerEntityList
room->grid_service->TraverseAllLayerEntityList
(
room->GetRoomIdx(),
tmp_grids,

View File

@ -388,7 +388,7 @@ void Player::UpdateJump()
[] (const a8::XParams& param)
{
Human* hum = (Human*)param.sender.GetUserData();
hum->room->TouchHumanList
hum->room->TraverseHumanList
(
a8::XParams()
.SetSender(hum),
@ -490,7 +490,7 @@ void Player::ObstacleInteraction(Obstacle* entity)
}
entity->IncDoorOpenTimes(room);
entity->RecalcSelfCollider();
room->TouchHumanList(a8::XParams(),
room->TraverseHumanList(a8::XParams(),
[entity] (Human* hum, a8::XParams& param) -> bool
{
hum->AddToNewObjects(entity);
@ -985,7 +985,7 @@ void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
PlayerMgr::Instance()->RemovePlayerBySocket(socket_handle);
}
socket_handle = hdr.socket_handle;
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this] (Human* hum, bool& stop)
{
@ -1313,7 +1313,7 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg)
cs::SMVoiceNotify* msg = (cs::SMVoiceNotify*)param.sender.GetUserData();
hum->SendNotifyMsg(*msg);
};
room->TouchPlayerList(a8::XParams()
room->TraversePlayerList(a8::XParams()
.SetSender(&notifymsg),
send_func);
}

View File

@ -386,7 +386,7 @@ Human* Room::FindEnemy(Human* hum)
if (room_type_ == RT_MidBrid) {
sub_type = EST_Android;
Human* target = nullptr;
hum->room->TouchHumanList
hum->room->TraverseHumanList
(
a8::XParams(),
[hum, &target] (Human* huma, a8::XParams& param)
@ -413,7 +413,7 @@ Human* Room::FindEnemy(Human* hum)
}
return target;
}
hum->TouchAllLayerHumanList
hum->TraverseAllLayerHumanList
(
[&enemys, hum, sub_type] (Human* target, bool& stop)
{
@ -980,7 +980,7 @@ Entity* Room::FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aa
Entity* target = nullptr;
std::set<GridCell*> tmp_grids;
grid_service->GetAllCellsByXy(this, aabb_pos.x, aabb_pos.y, tmp_grids);
grid_service->TouchAllLayerEntityList
grid_service->TraverseAllLayerEntityList
(
room_idx_,
tmp_grids,
@ -1109,7 +1109,7 @@ int Room::NewTeam()
return current_teamid_;
}
void Room::TouchPlayerList(a8::XParams param,
void Room::TraversePlayerList(a8::XParams param,
std::function<void (Player*, a8::XParams&)> func)
{
if (!func) {
@ -1122,7 +1122,7 @@ void Room::TouchPlayerList(a8::XParams param,
}
}
void Room::TouchHumanList(a8::XParams param,
void Room::TraverseHumanList(a8::XParams param,
std::function<bool (Human*, a8::XParams&)> func)
{
if (!func) {
@ -1137,7 +1137,7 @@ void Room::TouchHumanList(a8::XParams param,
}
}
void Room::TouchEntityList(a8::XParams param,
void Room::TraverseEntityList(a8::XParams param,
std::function<bool (Entity*, a8::XParams&)> func)
{
if (!func) {
@ -1152,7 +1152,7 @@ void Room::TouchEntityList(a8::XParams param,
}
}
void Room::TouchAlivePlayers(a8::XParams param,
void Room::TraverseAlivePlayers(a8::XParams param,
std::function<bool (Human*, a8::XParams&)> func)
{
for (auto& pair : alive_player_hash_) {
@ -1165,7 +1165,7 @@ void Room::TouchAlivePlayers(a8::XParams param,
void Room::BroadcastDebugMsg(const std::string& debug_msg)
{
#ifdef DEBUG
TouchHumanList
TraverseHumanList
(
a8::XParams()
.SetParam1(debug_msg),
@ -1272,7 +1272,7 @@ void Room::UpdateGasInactive()
jump_num = 1 + rand() % 2;
}
for (int i = 0; i < jump_num; ++i) {
room->TouchHumanList
room->TraverseHumanList
(
a8::XParams()
.SetSender(room),
@ -1358,7 +1358,7 @@ void Room::UpdateGasJump()
((GetFrameNo() - GetGasData().gas_start_frameno)*airline_->i->plane_speed() / SERVER_FRAME_RATE);
plane.curr_pos = plane.start_point + len_vec;
if ((plane.end_point - plane.start_point).Norm() <= len_vec.Norm()) {
TouchHumanList(
TraverseHumanList(
a8::XParams(),
[] (Human* hum, a8::XParams& param) -> bool
{
@ -1909,7 +1909,7 @@ void Room::NotifyUiUpdate()
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->TouchPlayerList(a8::XParams(),
room->TraversePlayerList(a8::XParams(),
[] (Player * hum, a8::XParams & param)
{
hum->SendUIUpdate();
@ -1985,7 +1985,7 @@ void Room::NotifyWxVoip()
[] (const a8::XParams& param)
{
Room* room = (Room*)param.sender.GetUserData();
room->TouchPlayerList(a8::XParams(),
room->TraversePlayerList(a8::XParams(),
[] (Player * hum, a8::XParams & param)
{
hum->SendWxVoip();
@ -2747,7 +2747,7 @@ void Room::CheckAutoDie(Human* target,
int check_times)
{
bool nodie = false;
target->TouchAllLayerHumanList
target->TraverseAllLayerHumanList
(
[&nodie, target, autodie_time, autodie_distance] (Human* hum, bool& stop)
{
@ -2910,7 +2910,7 @@ void Room::CheckPartObjects(Human* testa, Human* testb)
for (auto& pair1 : human_hash_) {
Human* huma = pair1.second;
huma->TouchAllLayerHumanList
huma->TraverseAllLayerHumanList
(
[&huma, testa, testb] (Human* humb, bool& stop)
{
@ -3672,7 +3672,7 @@ void Room::OnZombieAppear(Human* hum)
{
if (hum->GetRace() == kZombieRace && hum->meta->i->level() == 3 && !sent_zombie_boss_notify) {
sent_zombie_boss_notify = true;
TouchPlayerList
TraversePlayerList
(
a8::XParams()
.SetParam1(hum->meta->i->name()),
@ -3892,7 +3892,7 @@ void Room::ShuaMon(const a8::Vec2& center, std::vector<int>& airdrop_mon_list, f
void Room::GetPartObjectWatchList(Entity* entity, std::vector<Human*>& watch_list)
{
TouchHumanList
TraverseHumanList
(
a8::XParams(),
[&watch_list, entity] (Human* hum, a8::XParams& param) -> bool

View File

@ -93,13 +93,13 @@ public:
void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg);
void TouchPlayerList(a8::XParams param,
void TraversePlayerList(a8::XParams param,
std::function<void (Player*, a8::XParams&)> func);
void TouchHumanList(a8::XParams param,
void TraverseHumanList(a8::XParams param,
std::function<bool (Human*, a8::XParams&)> func);
void TouchEntityList(a8::XParams param,
void TraverseEntityList(a8::XParams param,
std::function<bool (Entity*, a8::XParams&)> func);
void TouchAlivePlayers(a8::XParams param,
void TraverseAlivePlayers(a8::XParams param,
std::function<bool (Human*, a8::XParams&)> func);
void BroadcastDebugMsg(const std::string& debug_msg);

View File

@ -107,7 +107,7 @@ void RoomObstacle::ActiveTimerFunc()
room->grid_service->GetAllCellsByXy(room, GetPos().x, GetPos().y, *grid_list_);
}
bool has_hum = false;
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(room->GetRoomIdx(),
*grid_list_,
[this, &has_hum] (Human* hum, bool& stop)
@ -133,7 +133,7 @@ void RoomObstacle::UpdateTimerFunc()
{
if (grid_list_ && master.Get() && !IsDead(room)) {
std::set<Human*> human_list;
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(room->GetRoomIdx(),
*grid_list_,
[this, &human_list] (Human* hum, bool& stop)
@ -173,7 +173,7 @@ void RoomObstacle::Explosion()
if (meta->i->damage_dia() > 0.01f &&
meta->i->damage() > 0.01f) {
std::set<Entity*> objects;
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
*grid_list_,
@ -183,7 +183,7 @@ void RoomObstacle::Explosion()
objects.insert(hum);
}
});
room->grid_service->TouchAllLayerEntityList
room->grid_service->TraverseAllLayerEntityList
(
room->GetRoomIdx(),
*grid_list_,
@ -270,7 +270,7 @@ void RoomObstacle::SpecExplosion()
bomb_born_offset = bomb_born_offset * a8::RandEx(1, std::max(2, meta->i->explosion_float()));
a8::Vec2 bomb_pos = GetPos() + bomb_born_offset;
std::set<Entity*> objects;
room->grid_service->TouchAllLayerHumanList
room->grid_service->TraverseAllLayerHumanList
(
room->GetRoomIdx(),
*grid_list_,

View File

@ -11,7 +11,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std:
switch (skill->meta->i->skill_target()) {
case kST_All:
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
@ -29,7 +29,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std:
case kST_FriendlyIncludeSelf:
{
target_list.insert(this);
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
@ -42,7 +42,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std:
break;
case kST_FriendlyExcludeSelf:
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
@ -66,7 +66,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std:
break;
case kST_EnemyGroup:
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
@ -79,7 +79,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std:
break;
case kST_EnemyAndObject:
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{
@ -92,7 +92,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std:
break;
case kST_EnemyAndSelf:
{
TouchAllLayerHumanList
TraverseAllLayerHumanList
(
[this, skill, &target_pos, &target_list] (Human* hum, bool& stop)
{

View File

@ -19,7 +19,7 @@ void SmokeMiTask::Check()
player_set.erase(hum);
}
}
room->TouchPlayerList
room->TraversePlayerList
(a8::XParams(),
[this] (Player* hum, a8::XParams&) -> bool
{

View File

@ -385,7 +385,7 @@ Creature* ZombieModeAI::GetTarget()
}
Creature* target = nullptr;
myself->TouchProperTargets
myself->TraverseProperTargets
(
[myself, &target] (Creature* c, bool& stop)
{