feat(Core): GetDeadCreatureListInGrid helper added, for aoe loot (#8445)

This commit is contained in:
acidmanifesto
2021-10-13 10:32:01 -04:00
committed by GitHub
parent b5f8b485a8
commit 430157f71d
5 changed files with 38 additions and 0 deletions

View File

@@ -714,3 +714,8 @@ void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& list, WorldObject*
{
source->GetGameObjectListWithEntryInGrid(list, entry, maxSearchRange);
}
void GetDeadCreatureListInGrid(std::list<Creature*>& list, WorldObject* source, float maxSearchRange, bool alive /*= false*/)
{
source->GetDeadCreatureListInGrid(list, maxSearchRange, alive);
}

View File

@@ -505,5 +505,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 GetDeadCreatureListInGrid(std::list<Creature*>& list, WorldObject* source, float maxSearchRange, bool alive = false);
#endif // SCRIPTEDCREATURE_H_

View File

@@ -2503,6 +2503,13 @@ void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& creatureL
Cell::VisitGridObjects(this, searcher, maxSearchRange);
}
void WorldObject::GetDeadCreatureListInGrid(std::list<Creature*>& creaturedeadList, float maxSearchRange, bool alive /*= false*/) const
{
Acore::AllDeadCreaturesInRange check(this, maxSearchRange, alive);
Acore::CreatureListSearcher<Acore::AllDeadCreaturesInRange> searcher(this, creaturedeadList, check);
Cell::VisitGridObjects(this, searcher, maxSearchRange);
}
/*
namespace Acore
{

View File

@@ -1007,6 +1007,7 @@ public:
[[nodiscard]] Player* SelectNearestPlayer(float distance = 0) const;
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange) const;
void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange) const;
void GetDeadCreatureListInGrid(std::list<Creature*>& lList, float maxSearchRange, bool alive = false) const;
void DestroyForNearbyPlayers();
virtual void UpdateObjectVisibility(bool forced = true, bool fromUpdate = false);

View File

@@ -1327,6 +1327,30 @@ namespace Acore
float m_fRange;
};
class AllDeadCreaturesInRange
{
public:
AllDeadCreaturesInRange(WorldObject const* obj, float range, bool reqAlive = true) : _obj(obj), _range(range), _reqAlive(reqAlive) {}
bool operator()(Unit* unit) const
{
if (_reqAlive && unit->IsAlive())
{
return false;
}
if (!_obj->IsWithinDistInMap(unit, _range))
{
return false;
}
return true;
}
private:
WorldObject const* _obj;
float _range;
bool _reqAlive;
};
class PlayerAtMinimumRangeAway
{
public: