AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
GridObjectLoader Class Reference

#include "GridObjectLoader.h"

Public Member Functions

 GridObjectLoader (MapGridType &grid, Map *map)
 
void LoadAllCellsInGrid ()
 

Private Member Functions

template<class T >
void AddObjectHelper (Map *map, T *obj)
 
void LoadCreatures (CellGuidSet const &guid_set, Map *map)
 
void LoadGameObjects (CellGuidSet const &guid_set, Map *map)
 

Private Attributes

MapGridType_grid
 
Map_map
 

Detailed Description

Constructor & Destructor Documentation

◆ GridObjectLoader()

GridObjectLoader::GridObjectLoader ( MapGridType grid,
Map map 
)
inline
30 : _grid(grid), _map(map) { }
Map * _map
Definition GridObjectLoader.h:42
MapGridType & _grid
Definition GridObjectLoader.h:41

Member Function Documentation

◆ AddObjectHelper()

template<class T >
void GridObjectLoader::AddObjectHelper ( Map map,
T *  obj 
)
private
29{
30 CellCoord cellCoord = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
31 Cell cell(cellCoord);
32
33 map->AddToGrid(obj, cell);
34 obj->AddToWorld();
35 if (obj->isActiveObject())
36 map->AddToActive(obj);
37}
void AddToGrid(T *object, Cell const &cell)
Definition Map.cpp:116
void AddToActive(T *obj)
Definition Map.cpp:1943
CellCoord ComputeCellCoord(float x, float y)
Definition GridDefines.h:193
Definition Cell.h:45

References Map::AddToActive(), Map::AddToGrid(), and Acore::ComputeCellCoord().

◆ LoadAllCellsInGrid()

void GridObjectLoader::LoadAllCellsInGrid ( )
82{
83 CellObjectGuids const& cell_guids = sObjectMgr->GetGridObjectGuids(_map->GetId(), _map->GetSpawnMode(), _grid.GetId());
84 LoadGameObjects(cell_guids.gameobjects, _map);
85 LoadCreatures(cell_guids.creatures, _map);
86
87 if (std::unordered_set<Corpse*> const* corpses = _map->GetCorpsesInCell(_grid.GetId()))
88 {
89 for (Corpse* corpse : *corpses)
90 {
91 if (corpse->IsInGrid())
92 continue;
93
94 CellCoord cellCoord = Acore::ComputeCellCoord(corpse->GetPositionX(), corpse->GetPositionY());
95 Cell cell(cellCoord);
96
97 if (corpse->IsWorldObject())
98 _grid.AddWorldObject(cell.CellX(), cell.CellY(), corpse);
99 else
100 _grid.AddGridObject(cell.CellX(), cell.CellY(), corpse);
101 }
102 }
103}
#define sObjectMgr
Definition ObjectMgr.h:1636
Definition Corpse.h:49
void LoadCreatures(CellGuidSet const &guid_set, Map *map)
Definition GridObjectLoader.cpp:39
void LoadGameObjects(CellGuidSet const &guid_set, Map *map)
Definition GridObjectLoader.cpp:64
uint32 GetId() const
Definition MapGrid.h:40
void AddGridObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:58
void AddWorldObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:48
std::unordered_set< Corpse * > const * GetCorpsesInCell(uint32 cellId) const
Definition Map.h:372
uint8 GetSpawnMode() const
Definition Map.h:267
uint32 GetId() const
Definition Map.h:229
Definition ObjectMgr.h:478
CellGuidSet gameobjects
Definition ObjectMgr.h:480
CellGuidSet creatures
Definition ObjectMgr.h:479

References _grid, _map, MapGrid< WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddGridObject(), MapGrid< WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddWorldObject(), Cell::CellX(), Cell::CellY(), Acore::ComputeCellCoord(), CellObjectGuids::creatures, CellObjectGuids::gameobjects, Map::GetCorpsesInCell(), MapGrid< WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::GetId(), Map::GetId(), Map::GetSpawnMode(), LoadCreatures(), LoadGameObjects(), and sObjectMgr.

Referenced by MapGridManager::LoadGrid().

◆ LoadCreatures()

void GridObjectLoader::LoadCreatures ( CellGuidSet const &  guid_set,
Map map 
)
private
40{
41 for (ObjectGuid::LowType const& guid : guid_set)
42 {
43 Creature* obj = new Creature();
44 if (!obj->LoadFromDB(guid, map))
45 {
46 delete obj;
47 continue;
48 }
49
50 AddObjectHelper<Creature>(map, obj);
51
53 {
55 {
56 // call MoveInLineOfSight for nearby grid creatures
57 Acore::AIRelocationNotifier notifier(*obj);
58 Cell::VisitGridObjects(obj, notifier, 60.f);
59 }
60 }
61 }
62}
@ IDLE_MOTION_TYPE
Definition MotionMaster.h:39
@ NOTIFY_AI_RELOCATION
Definition Object.h:67
@ NOTIFY_VISIBILITY_CHANGED
Definition Object.h:68
@ UNIT_STATE_SIGHTLESS
Definition UnitDefines.h:213
@ REACT_AGGRESSIVE
Definition Unit.h:550
Definition Creature.h:43
bool HasReactState(ReactStates state) const
Definition Creature.h:97
bool IsMoveInLineOfSightDisabled()
Definition Creature.h:280
MovementGeneratorType GetDefaultMovementType() const override
-------—End of Pet responses methods-------—
Definition Creature.h:86
bool LoadFromDB(ObjectGuid::LowType guid, Map *map, bool allowDuplicate=false)
Definition Creature.h:223
uint32 LowType
Definition ObjectGuid.h:122
bool IsAlive() const
Definition Unit.h:1707
bool IsImmuneToNPC() const
Definition Unit.h:888
bool HasUnitState(const uint32 f) const
Definition Unit.h:707
bool isNeedNotify(uint16 f) const
Definition Object.h:574
Definition GridNotifiers.h:91
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References Creature::GetDefaultMovementType(), Creature::HasReactState(), Unit::HasUnitState(), IDLE_MOTION_TYPE, Unit::IsAlive(), Unit::IsImmuneToNPC(), Creature::IsMoveInLineOfSightDisabled(), WorldObject::isNeedNotify(), Creature::LoadFromDB(), NOTIFY_AI_RELOCATION, NOTIFY_VISIBILITY_CHANGED, REACT_AGGRESSIVE, UNIT_STATE_SIGHTLESS, and Cell::VisitGridObjects().

Referenced by LoadAllCellsInGrid().

◆ LoadGameObjects()

void GridObjectLoader::LoadGameObjects ( CellGuidSet const &  guid_set,
Map map 
)
private
65{
66 for (ObjectGuid::LowType const& guid : guid_set)
67 {
68 GameObjectData const* data = sObjectMgr->GetGameObjectData(guid);
69 GameObject* obj = data && sObjectMgr->IsGameObjectStaticTransport(data->id) ? new StaticTransport() : new GameObject();
70
71 if (!obj->LoadFromDB(guid, map))
72 {
73 delete obj;
74 continue;
75 }
76
77 AddObjectHelper<GameObject>(map, obj);
78 }
79}
Definition GameObject.h:120
bool LoadFromDB(ObjectGuid::LowType guid, Map *map)
Definition GameObject.h:159
Definition Transport.h:113
Definition GameObjectData.h:696
uint32 id
Definition GameObjectData.h:698

References GameObjectData::id, GameObject::LoadFromDB(), and sObjectMgr.

Referenced by LoadAllCellsInGrid().

Member Data Documentation

◆ _grid

MapGridType& GridObjectLoader::_grid
private

Referenced by LoadAllCellsInGrid().

◆ _map

Map* GridObjectLoader::_map
private

Referenced by LoadAllCellsInGrid().


The documentation for this class was generated from the following files: