TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GarrisonGridLoader Class Reference

Public Member Functions

 GarrisonGridLoader (NGridType *grid, GarrisonMap *map, Cell const &cell)
 
void Visit (GameObjectMapType &m)
 
void Visit (CreatureMapType &m)
 
void LoadN ()
 
template<class T >
void Visit (GridRefManager< T > &)
 

Static Public Member Functions

template<class T >
static void SetObjectCell (T *obj, CellCoord const &cellCoord)
 

Private Attributes

Cell i_cell
 
NGridTypei_grid
 
GarrisonMapi_map
 
Garrisoni_garrison
 
uint32 i_gameObjects
 
uint32 i_creatures
 

Constructor & Destructor Documentation

GarrisonGridLoader::GarrisonGridLoader ( NGridType grid,
GarrisonMap map,
Cell const cell 
)
inline
28  : i_cell(cell), i_grid(grid), i_map(map), i_garrison(map->GetGarrison()), i_gameObjects(0), i_creatures(0)
29  { }
GarrisonMap * i_map
Definition: GarrisonMap.cpp:42
uint32 i_gameObjects
Definition: GarrisonMap.cpp:44
uint32 i_creatures
Definition: GarrisonMap.cpp:45
NGridType * i_grid
Definition: GarrisonMap.cpp:41
Garrison * GetGarrison()
Definition: GarrisonMap.cpp:113
Garrison * i_garrison
Definition: GarrisonMap.cpp:43
Cell i_cell
Definition: GarrisonMap.cpp:40

Member Function Documentation

void GarrisonGridLoader::LoadN ( )
49 {
50  if (i_garrison)
51  {
52  i_cell.data.Part.cell_y = 0;
53  for (uint32 x = 0; x < MAX_NUMBER_OF_CELLS; ++x)
54  {
55  i_cell.data.Part.cell_x = x;
56  for (uint32 y = 0; y < MAX_NUMBER_OF_CELLS; ++y)
57  {
58  i_cell.data.Part.cell_y = y;
59 
60  //Load creatures and game objects
62  i_grid->VisitGrid(x, y, visitor);
63  }
64  }
65  }
66 
67  TC_LOG_DEBUG("maps", "%u GameObjects and %u Creatures loaded for grid %u on map %u", i_gameObjects, i_creatures, i_grid->GetGridId(), i_map->GetId());
68 }
struct Cell::@307::@308 Part
Definition: TypeContainerVisitor.h:32
GarrisonMap * i_map
Definition: GarrisonMap.cpp:42
#define MAX_NUMBER_OF_CELLS
Definition: GridDefines.h:35
union Cell::@307 data
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetId(void) const
Definition: Map.h:325
uint32 i_gameObjects
Definition: GarrisonMap.cpp:44
uint32 i_creatures
Definition: GarrisonMap.cpp:45
void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition: NGrid.h:155
NGridType * i_grid
Definition: GarrisonMap.cpp:41
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Garrison * i_garrison
Definition: GarrisonMap.cpp:43
Cell i_cell
Definition: GarrisonMap.cpp:40
G3D::int16 x
Definition: Vector2int16.h:37
uint32 GetGridId(void) const
Definition: NGrid.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
static void GarrisonGridLoader::SetObjectCell ( T *  obj,
CellCoord const cellCoord 
)
static
void GarrisonGridLoader::Visit ( GameObjectMapType m)
71 {
72  std::vector<Garrison::Plot*> plots = i_garrison->GetPlots();
73  if (!plots.empty())
74  {
75  CellCoord cellCoord = i_cell.GetCellCoord();
76  for (Garrison::Plot* plot : plots)
77  {
78  Position const& spawn = plot->PacketInfo.PlotPos;
79  if (cellCoord != Trinity::ComputeCellCoord(spawn.GetPositionX(), spawn.GetPositionY()))
80  continue;
81 
82  GameObject* go = plot->CreateGameObject(i_map, i_garrison->GetFaction());
83  if (!go)
84  continue;
85 
86  go->AddToGrid(m);
87  ObjectGridLoader::SetObjectCell(go, cellCoord);
88  go->AddToWorld();
89  ++i_gameObjects;
90  }
91  }
92 }
Definition: Garrison.h:95
GarrisonMap * i_map
Definition: GarrisonMap.cpp:42
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
static void SetObjectCell(T *obj, CellCoord const &cellCoord)
Definition: ObjectGridLoader.cpp:81
void AddToWorld() override
Definition: GameObject.cpp:125
std::vector< Plot * > GetPlots()
Definition: Garrison.cpp:309
uint32 i_gameObjects
Definition: GarrisonMap.cpp:44
float GetPositionY() const
Definition: Position.h:105
Garrison * i_garrison
Definition: GarrisonMap.cpp:43
Definition: GameObject.h:880
CellCoord GetCellCoord() const
Definition: Cell.h:81
Cell i_cell
Definition: GarrisonMap.cpp:40
void AddToGrid(GridRefManager< T > &m)
Definition: Object.h:361
Definition: Position.h:27
float GetPositionX() const
Definition: Position.h:104
GarrisonFactionIndex GetFaction() const
Definition: Garrison.cpp:304

+ Here is the call graph for this function:

void GarrisonGridLoader::Visit ( CreatureMapType m)
95 {
96 
97 }
template<class T >
void GarrisonGridLoader::Visit ( GridRefManager< T > &  )
inline
37 { }

Member Data Documentation

Cell GarrisonGridLoader::i_cell
private
uint32 GarrisonGridLoader::i_creatures
private
uint32 GarrisonGridLoader::i_gameObjects
private
Garrison* GarrisonGridLoader::i_garrison
private
NGridType* GarrisonGridLoader::i_grid
private
GarrisonMap* GarrisonGridLoader::i_map
private

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