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<T>(obj, cell);
34 obj->AddToWorld();
35}
void AddToGrid(T *object, Cell const &cell)
Definition Map.cpp:108
CellCoord ComputeCellCoord(float x, float y)
Definition GridDefines.h:197
Definition Cell.h:45

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

◆ LoadAllCellsInGrid()

void GridObjectLoader::LoadAllCellsInGrid ( )
93{
94 CellObjectGuids const& cell_guids = sObjectMgr->GetGridObjectGuids(_map->GetId(), _map->GetSpawnMode(), _grid.GetId());
95 LoadGameObjects(cell_guids.gameobjects, _map);
96 LoadCreatures(cell_guids.creatures, _map);
97
98 if (std::unordered_set<Corpse*> const* corpses = _map->GetCorpsesInGrid(_grid.GetId()))
99 {
100 for (Corpse* corpse : *corpses)
101 {
102 if (corpse->IsInGrid())
103 continue;
104
105 AddObjectHelper<Corpse>(_map, corpse);
106 }
107 }
108}
#define sObjectMgr
Definition ObjectMgr.h:1650
Definition Corpse.h:49
void LoadCreatures(CellGuidSet const &guid_set, Map *map)
Definition GridObjectLoader.cpp:37
void LoadGameObjects(CellGuidSet const &guid_set, Map *map)
Definition GridObjectLoader.cpp:62
uint32 GetId() const
Definition MapGrid.h:40
std::unordered_set< Corpse * > const * GetCorpsesInGrid(uint32 gridId) const
Definition Map.h:353
uint8 GetSpawnMode() const
Definition Map.h:264
uint32 GetId() const
Definition Map.h:226
Definition ObjectMgr.h:478
CellGuidSet gameobjects
Definition ObjectMgr.h:480
CellGuidSet creatures
Definition ObjectMgr.h:479

References _grid, _map, CellObjectGuids::creatures, CellObjectGuids::gameobjects, Map::GetCorpsesInGrid(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_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
38{
39 for (ObjectGuid::LowType const& guid : guid_set)
40 {
41 Creature* obj = new Creature();
42 if (!obj->LoadFromDB(guid, map))
43 {
44 delete obj;
45 continue;
46 }
47
48 AddObjectHelper<Creature>(map, obj);
49
51 {
53 {
54 // call MoveInLineOfSight for nearby grid creatures
55 Acore::AIRelocationNotifier notifier(*obj);
56 Cell::VisitObjects(obj, notifier, 60.f);
57 }
58 }
59 }
60}
@ IDLE_MOTION_TYPE
Definition MotionMaster.h:39
@ NOTIFY_AI_RELOCATION
Definition Object.h:69
@ NOTIFY_VISIBILITY_CHANGED
Definition Object.h:70
@ UNIT_STATE_SIGHTLESS
Definition UnitDefines.h:213
@ REACT_AGGRESSIVE
Definition Unit.h:551
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:874
bool HasUnitState(const uint32 f) const
Definition Unit.h:691
bool isNeedNotify(uint16 f) const
Definition Object.h:660
Definition GridNotifiers.h:91
static void VisitObjects(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::VisitObjects().

Referenced by LoadAllCellsInGrid().

◆ LoadGameObjects()

void GridObjectLoader::LoadGameObjects ( CellGuidSet const &  guid_set,
Map map 
)
private
63{
64 for (ObjectGuid::LowType const& guid : guid_set)
65 {
66 GameObjectData const* data = sObjectMgr->GetGameObjectData(guid);
67
68 if (data && sObjectMgr->IsGameObjectStaticTransport(data->id))
69 {
70 StaticTransport* transport = new StaticTransport();
71
72 // Special case for static transports - we are loaded via grids
73 // but we do not want to actually be stored in the grid
74 if (!transport->LoadGameObjectFromDB(guid, map, true))
75 delete transport;
76 }
77 else
78 {
79 GameObject* obj = new GameObject();
80
81 if (!obj->LoadFromDB(guid, map))
82 {
83 delete obj;
84 continue;
85 }
86
87 AddObjectHelper<GameObject>(map, obj);
88 }
89 }
90}
Definition GameObject.h:120
virtual bool LoadFromDB(ObjectGuid::LowType guid, Map *map)
Definition GameObject.h:159
Definition Transport.h:115
bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true) override
Definition Transport.cpp:693
Definition GameObjectData.h:698
uint32 id
Definition GameObjectData.h:700

References GameObjectData::id, GameObject::LoadFromDB(), StaticTransport::LoadGameObjectFromDB(), 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: