Merge [SD2]
r1088 Add grid searcher class PlayerAtMinimumRangeAway and create ScriptedAI function GetPlayerAtMinimumRange that return player in grid with at least the defined range away from m_creature. r1089 Remove no longer needed grid search code and use function instead. - skip r1090 Rename and clarify function variables - skip r1091 Add two new grid search functions to return list of creature and gameobject. Remove unused class. r1092 Remove more grid search code in scripts and use functions instead. r1093 Remove obsolete grid search class and rename new to a more consistent name. r1094 Speed up functions GetCreature/GameObjectListWithEntryInGrid a bit --HG-- branch : trunk
This commit is contained in:
+43
-22
@@ -1135,19 +1135,57 @@ namespace Trinity
|
||||
Unit const* pUnit;
|
||||
};
|
||||
|
||||
class AllGameObjectsWithEntryInGrid
|
||||
class AllGameObjectsWithEntryInRange
|
||||
{
|
||||
public:
|
||||
AllGameObjectsWithEntryInGrid(uint32 ent) : entry(ent) {}
|
||||
bool operator() (GameObject* g)
|
||||
AllGameObjectsWithEntryInRange(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
|
||||
bool operator() (GameObject* pGo)
|
||||
{
|
||||
if(g->GetEntry() == entry)
|
||||
if (pGo->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pGo,m_fRange,false))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
uint32 entry;
|
||||
const WorldObject* m_pObject;
|
||||
uint32 m_uiEntry;
|
||||
float m_fRange;
|
||||
};
|
||||
|
||||
class AllCreaturesOfEntryInRange
|
||||
{
|
||||
public:
|
||||
AllCreaturesOfEntryInRange(const WorldObject* pObject, uint32 uiEntry, float fMaxRange) : m_pObject(pObject), m_uiEntry(uiEntry), m_fRange(fMaxRange) {}
|
||||
bool operator() (Unit* pUnit)
|
||||
{
|
||||
if (pUnit->GetEntry() == m_uiEntry && m_pObject->IsWithinDist(pUnit,m_fRange,false))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
const WorldObject* m_pObject;
|
||||
uint32 m_uiEntry;
|
||||
float m_fRange;
|
||||
};
|
||||
|
||||
class PlayerAtMinimumRangeAway
|
||||
{
|
||||
public:
|
||||
PlayerAtMinimumRangeAway(Unit const* unit, float fMinRange) : pUnit(unit), fRange(fMinRange) {}
|
||||
bool operator() (Player* pPlayer)
|
||||
{
|
||||
//No threat list check, must be done explicit if expected to be in combat with creature
|
||||
if (!pPlayer->isGameMaster() && pPlayer->isAlive() && !pUnit->IsWithinDist(pPlayer,fRange,false))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
Unit const* pUnit;
|
||||
float fRange;
|
||||
};
|
||||
|
||||
class GameObjectInRangeCheck
|
||||
@@ -1162,23 +1200,6 @@ namespace Trinity
|
||||
float x, y, z, range;
|
||||
};
|
||||
|
||||
class AllCreaturesOfEntryInRange
|
||||
{
|
||||
public:
|
||||
AllCreaturesOfEntryInRange(Unit const* obj, uint32 ent, float ran) : pUnit(obj), entry(ent), range(ran) {}
|
||||
bool operator() (Unit* u)
|
||||
{
|
||||
if(u->GetEntry() == entry && pUnit->IsWithinDistInMap(u, range))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
private:
|
||||
Unit const* pUnit;
|
||||
uint32 entry;
|
||||
float range;
|
||||
};
|
||||
|
||||
// Player checks and do
|
||||
|
||||
// Prepare using Builder localized packets with caching and send to player
|
||||
|
||||
@@ -1992,6 +1992,36 @@ GameObject* WorldObject::FindNearestGameObject(uint32 entry, float range)
|
||||
return go;
|
||||
}
|
||||
|
||||
void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange)
|
||||
{
|
||||
CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY()));
|
||||
Cell cell(pair);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
Trinity::AllGameObjectsWithEntryInRange check(this, uiEntry, fMaxSearchRange);
|
||||
Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, lList, check);
|
||||
TypeContainerVisitor<Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange>, GridTypeMapContainer> visitor(searcher);
|
||||
|
||||
CellLock<GridReadGuard> cell_lock(cell, pair);
|
||||
cell_lock->Visit(cell_lock, visitor, *(this->GetMap()));
|
||||
}
|
||||
|
||||
void WorldObject::GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange)
|
||||
{
|
||||
CellPair pair(Trinity::ComputeCellPair(this->GetPositionX(), this->GetPositionY()));
|
||||
Cell cell(pair);
|
||||
cell.data.Part.reserved = ALL_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
|
||||
Trinity::AllCreaturesOfEntryInRange check(this, uiEntry, fMaxSearchRange);
|
||||
Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, lList, check);
|
||||
TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> visitor(searcher);
|
||||
|
||||
CellLock<GridReadGuard> cell_lock(cell, pair);
|
||||
cell_lock->Visit(cell_lock, visitor, *(this->GetMap()));
|
||||
}
|
||||
|
||||
/*
|
||||
namespace MaNGOS
|
||||
{
|
||||
|
||||
@@ -548,6 +548,9 @@ class TRINITY_DLL_SPEC WorldObject : public Object
|
||||
Creature* FindNearestCreature(uint32 entry, float range, bool alive = true);
|
||||
GameObject* FindNearestGameObject(uint32 entry, float range);
|
||||
|
||||
void GetGameObjectListWithEntryInGrid(std::list<GameObject*>& lList, uint32 uiEntry, float fMaxSearchRange);
|
||||
void GetCreatureListWithEntryInGrid(std::list<Creature*>& lList, uint32 uiEntry, float fMaxSearchRange);
|
||||
|
||||
bool isActiveObject() const { return m_isActive; }
|
||||
void setActive(bool isActiveObject);
|
||||
void SetWorldObject(bool apply);
|
||||
|
||||
Reference in New Issue
Block a user