Added a player searcher

This can be used in scripts to search for Player* objects within a given
range.
This commit is contained in:
Epicurus4
2015-02-10 22:16:07 -05:00
parent 36963f2442
commit 4ffdf3396d
4 changed files with 18 additions and 0 deletions

View File

@@ -677,3 +677,8 @@ void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject*
{
source->GetGameObjectListWithEntryInGrid(list, entry, maxSearchRange);
}
void GetPlayerListInGrid(std::list<Player*>& list, WorldObject* source, float maxSearchRange)
{
source->GetPlayerListInGrid(list, maxSearchRange);
}

View File

@@ -423,5 +423,6 @@ Creature* GetClosestCreatureWithEntry(WorldObject* source, uint32 entry, float m
GameObject* GetClosestGameObjectWithEntry(WorldObject* source, uint32 entry, float maxSearchRange);
void GetCreatureListWithEntryInGrid(std::list<Creature*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject* source, uint32 entry, float maxSearchRange);
void GetPlayerListInGrid(std::list<Player*>& list, WorldObject* source, float maxSearchRange);
#endif // SCRIPTEDCREATURE_H_

View File

@@ -2697,6 +2697,17 @@ void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureL
cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
}
void WorldObject::GetPlayerListInGrid(std::list<Player*>& playerList, float maxSearchRange) const
{
CellCoord pair(Trinity::ComputeCellCoord(this->GetPositionX(), this->GetPositionY()));
Cell cell(pair);
cell.SetNoCreate();
Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange);
Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerList, checker);
this->VisitNearbyWorldObject(maxSearchRange, searcher);
}
/*
namespace Trinity
{

View File

@@ -712,6 +712,7 @@ class WorldObject : public Object, public WorldLocation
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const;
void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const;
void GetPlayerListInGrid(std::list<Player*>& lList, float fMaxSearchRange) const;
void DestroyForNearbyPlayers();
virtual void UpdateObjectVisibility(bool forced = true);