feat(Core/Map): add DoForAllPlayers method (#10371)

This commit is contained in:
Nefertumm
2022-02-04 14:54:29 -03:00
committed by GitHub
parent 27c6699d60
commit aa6ecec2ab
2 changed files with 14 additions and 0 deletions

View File

@@ -3757,6 +3757,17 @@ void Map::SetZoneOverrideLight(uint32 zoneId, uint32 lightId, Milliseconds fadeI
}
}
void Map::DoForAllPlayers(std::function<void(Player*)> exec)
{
for (auto const& it : GetPlayers())
{
if (Player* player = it.GetSource())
{
exec(player);
}
}
}
/**
* @brief Check if a given source can reach a specific point following a path
* and normalize the coords. Use this method for long paths, otherwise use the

View File

@@ -606,6 +606,9 @@ public:
void UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* source);
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry);
// Do whatever you want to all the players in map [including GameMasters], i.e.: param exec = [&](Player* p) { p->Whatever(); }
void DoForAllPlayers(std::function<void(Player*)> exec);
GridMap* GetGrid(float x, float y);
void EnsureGridCreated(const GridCoord&);
[[nodiscard]] bool AllTransportsEmpty() const; // pussywizard