TrinityCore
ObjectGridLoader.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_OBJECTGRIDLOADER_H
19#define TRINITY_OBJECTGRIDLOADER_H
20
21#include "Define.h"
22#include "GridDefines.h"
23#include "Cell.h"
24
25class MapObject;
26class ObjectGuid;
28
30{
31 public:
32 ObjectGridLoaderBase(NGridType& grid, Map* map, Cell const& cell)
33 : i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses(0), i_areaTriggers(0)
34 { }
35
36 static void SetObjectCell(MapObject* obj, CellCoord const& cellCoord);
37
38 uint32 GetLoadedCreatures() const { return i_creatures; }
39 uint32 GetLoadedGameObjects() const { return i_gameObjects; }
40 uint32 GetLoadedCorpses() const { return i_corpses; }
41 uint32 GetLoadedAreaTriggers() const { return i_areaTriggers; }
42
43 protected:
51};
52
54{
55 friend class ObjectWorldLoader;
56
57 public:
58 ObjectGridLoader(NGridType& grid, Map* map, Cell const& cell)
59 : ObjectGridLoaderBase(grid, map, cell)
60 { }
61
62 void Visit(GameObjectMapType &m);
63 void Visit(CreatureMapType &m);
65 void Visit(CorpseMapType &) const { }
66 void Visit(DynamicObjectMapType&) const { }
67 void Visit(SceneObjectMapType&) const { }
68 void Visit(ConversationMapType&) const { }
69
70 void LoadN();
71};
72
74{
75 public:
76 PersonalPhaseGridLoader(NGridType& grid, Map* map, Cell const& cell, ObjectGuid const& phaseOwner)
77 : ObjectGridLoaderBase(grid, map, cell), _phaseId(0), _phaseOwner(phaseOwner)
78 { }
79
80 void Visit(GameObjectMapType &m);
81 void Visit(CreatureMapType &m);
82 void Visit(AreaTriggerMapType&) const { }
83 void Visit(CorpseMapType&) const { }
84 void Visit(DynamicObjectMapType&) const { }
85 void Visit(SceneObjectMapType&) const { }
86 void Visit(ConversationMapType&) const { }
87
88 void Load(uint32 phaseId);
89
90 private:
93};
94
95//Stop the creatures before unloading the NGrid
97{
98 public:
99 void Visit(CreatureMapType &m);
100 template<class T> void Visit(GridRefManager<T> &) { }
101};
102
103//Move the foreign creatures back to respawn positions before unloading the NGrid
105{
106 public:
107 void Visit(CreatureMapType &m);
108 void Visit(GameObjectMapType &m);
109 template<class T> void Visit(GridRefManager<T> &) { }
110};
111
112//Clean up and remove from world
114{
115 public:
116 template<class T> void Visit(GridRefManager<T> &);
117};
118
119//Delete objects before deleting NGrid
121{
122 public:
123 void Visit(CorpseMapType& /*m*/) { } // corpses are deleted with Map
124 template<class T> void Visit(GridRefManager<T> &m);
125};
126#endif
#define TC_GAME_API
Definition: Define.h:123
uint32_t uint32
Definition: Define.h:142
Definition: Map.h:189
Definition: NGrid.h:70
void Visit(GridRefManager< T > &)
void Visit(GridRefManager< T > &)
uint32 GetLoadedAreaTriggers() const
uint32 GetLoadedCorpses() const
uint32 GetLoadedCreatures() const
ObjectGridLoaderBase(NGridType &grid, Map *map, Cell const &cell)
uint32 GetLoadedGameObjects() const
void Visit(CorpseMapType &) const
ObjectGridLoader(NGridType &grid, Map *map, Cell const &cell)
void Visit(DynamicObjectMapType &) const
void Visit(SceneObjectMapType &) const
void Visit(ConversationMapType &) const
void Visit(GridRefManager< T > &)
void Visit(CorpseMapType &)
void Visit(CorpseMapType &m)
ObjectGuid const & _phaseOwner
void Visit(ConversationMapType &) const
PersonalPhaseGridLoader(NGridType &grid, Map *map, Cell const &cell, ObjectGuid const &phaseOwner)
void Visit(CorpseMapType &) const
void Visit(DynamicObjectMapType &) const
void Visit(AreaTriggerMapType &) const
void Visit(SceneObjectMapType &) const
Definition: wmo.h:163
Definition: Cell.h:47