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
31{
32 CellCoord cellCoord = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
33 Cell cell(cellCoord);
34
35 map->AddToGrid<T>(obj, cell);
36 obj->AddToWorld();
37}
void AddToGrid(T *object, Cell const &cell)
Definition Map.cpp:113
CellCoord ComputeCellCoord(float x, float y)
Definition GridDefines.h:197
Definition Cell.h:45

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

◆ LoadAllCellsInGrid()

void GridObjectLoader::LoadAllCellsInGrid ( )
108{
109 CellObjectGuids const& cell_guids = sObjectMgr->GetGridObjectGuids(_map->GetId(), _map->GetSpawnMode(), _grid.GetId());
110 LoadGameObjects(cell_guids.gameobjects, _map);
111 LoadCreatures(cell_guids.creatures, _map);
112
113 if (std::unordered_set<Corpse*> const* corpses = _map->GetCorpsesInGrid(_grid.GetId()))
114 {
115 for (Corpse* corpse : *corpses)
116 {
117 if (corpse->IsInGrid())
118 continue;
119
120 AddObjectHelper<Corpse>(_map, corpse);
121 }
122 }
123}
#define sObjectMgr
Definition ObjectMgr.h:1723
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:73
uint32 GetId() const
Definition MapGrid.h:41
std::unordered_set< Corpse * > const * GetCorpsesInGrid(uint32 gridId) const
Definition Map.h:360
uint8 GetSpawnMode() const
Definition Map.h:269
uint32 GetId() const
Definition Map.h:232
Definition ObjectMgr.h:479
CellGuidSet gameobjects
Definition ObjectMgr.h:481
CellGuidSet creatures
Definition ObjectMgr.h:480

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
40{
41 for (ObjectGuid::LowType const& guid : guid_set)
42 {
43 // Skip spawns whose spawn group is not active on this map
44 CreatureData const* cData = sObjectMgr->GetCreatureData(guid);
45 if (cData && !map->IsSpawnGroupActive(cData->spawnGroupId))
46 continue;
47
48 Creature* obj = new Creature();
49 if (!obj->LoadFromDB(guid, map))
50 {
51 delete obj;
52 continue;
53 }
54
55 AddObjectHelper<Creature>(map, obj);
56
57 // Grid load bypasses Map::AddToMap, so seat accessories here.
58 if (Vehicle* vehicle = obj->GetVehicleKit())
59 vehicle->Reset();
60
62 {
64 {
65 // call MoveInLineOfSight for nearby grid creatures
66 Acore::AIRelocationNotifier notifier(*obj);
67 Cell::VisitObjects(obj, notifier, 60.f);
68 }
69 }
70 }
71}
@ IDLE_MOTION_TYPE
Definition MotionMaster.h:39
@ NOTIFY_AI_RELOCATION
Definition Object.h:70
@ NOTIFY_VISIBILITY_CHANGED
Definition Object.h:71
@ UNIT_STATE_SIGHTLESS
Definition UnitDefines.h:220
@ REACT_AGGRESSIVE
Definition Unit.h:568
Definition Creature.h:47
bool HasReactState(ReactStates state) const
Definition Creature.h:102
bool IsMoveInLineOfSightDisabled()
Definition Creature.h:282
MovementGeneratorType GetDefaultMovementType() const override
-------—End of Pet responses methods-------—
Definition Creature.h:91
bool LoadFromDB(ObjectGuid::LowType guid, Map *map, bool allowDuplicate=false)
Definition Creature.h:223
bool IsSpawnGroupActive(uint32 groupId) const
Definition Map.cpp:2531
uint32 LowType
Definition ObjectGuid.h:122
bool IsAlive() const
Definition Unit.h:1794
bool IsImmuneToNPC() const
Definition Unit.h:929
bool HasUnitState(const uint32 f) const
Definition Unit.h:736
Vehicle * GetVehicleKit() const
Definition Unit.h:1926
Definition Vehicle.h:28
bool isNeedNotify(uint16 f) const
Definition Object.h:665
Definition GridNotifiers.h:91
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165
Definition CreatureData.h:370
uint32 spawnGroupId
Definition SpawnData.h:78

References Creature::GetDefaultMovementType(), Unit::GetVehicleKit(), Creature::HasReactState(), Unit::HasUnitState(), IDLE_MOTION_TYPE, Unit::IsAlive(), Unit::IsImmuneToNPC(), Creature::IsMoveInLineOfSightDisabled(), WorldObject::isNeedNotify(), Map::IsSpawnGroupActive(), Creature::LoadFromDB(), NOTIFY_AI_RELOCATION, NOTIFY_VISIBILITY_CHANGED, REACT_AGGRESSIVE, sObjectMgr, SpawnData::spawnGroupId, UNIT_STATE_SIGHTLESS, and Cell::VisitObjects().

Referenced by LoadAllCellsInGrid().

◆ LoadGameObjects()

void GridObjectLoader::LoadGameObjects ( CellGuidSet const &  guid_set,
Map map 
)
private
74{
75 for (ObjectGuid::LowType const& guid : guid_set)
76 {
77 GameObjectData const* data = sObjectMgr->GetGameObjectData(guid);
78
79 // Skip spawns whose spawn group is not active on this map
80 if (data && !map->IsSpawnGroupActive(data->spawnGroupId))
81 continue;
82
83 if (data && sObjectMgr->IsGameObjectStaticTransport(data->id))
84 {
85 StaticTransport* transport = new StaticTransport();
86
87 // Special case for static transports - we are loaded via grids
88 // but we do not want to actually be stored in the grid
89 if (!transport->LoadGameObjectFromDB(guid, map, true))
90 delete transport;
91 }
92 else
93 {
94 GameObject* obj = new GameObject();
95
96 if (!obj->LoadFromDB(guid, map))
97 {
98 delete obj;
99 continue;
100 }
101
102 AddObjectHelper<GameObject>(map, obj);
103 }
104 }
105}
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:699
Definition GameObjectData.h:715
uint32 id
Definition GameObjectData.h:717

References GameObjectData::id, Map::IsSpawnGroupActive(), GameObject::LoadFromDB(), StaticTransport::LoadGameObjectFromDB(), sObjectMgr, and SpawnData::spawnGroupId.

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: