TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CreatureGroups.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _FORMATIONS_H
20 #define _FORMATIONS_H
21 
22 #include "Define.h"
23 #include <unordered_map>
24 #include <map>
25 
26 class Creature;
27 class CreatureGroup;
28 
30 {
32  float follow_dist;
33  float follow_angle;
37 };
38 
39 typedef std::unordered_map<ObjectGuid::LowType/*memberDBGUID*/, FormationInfo*> CreatureGroupInfoType;
40 
42 {
43  private:
45  ~FormationMgr();
46 
47  public:
48  static FormationMgr* instance();
49 
50  void AddCreatureToGroup(ObjectGuid::LowType leaderGuid, Creature* creature);
51  void RemoveCreatureFromGroup(CreatureGroup* group, Creature* creature);
52  void LoadCreatureFormations();
54 };
55 
57 {
58  private:
59  Creature* m_leader; //Important do not forget sometimes to work with pointers instead synonims :D:D
60  typedef std::map<Creature*, FormationInfo*> CreatureGroupMemberType;
61  CreatureGroupMemberType m_members;
62 
64  bool m_Formed;
65 
66  public:
67  //Group cannot be created empty
68  explicit CreatureGroup(ObjectGuid::LowType id) : m_leader(NULL), m_groupID(id), m_Formed(false) { }
70 
71  Creature* getLeader() const { return m_leader; }
72  ObjectGuid::LowType GetId() const { return m_groupID; }
73  bool isEmpty() const { return m_members.empty(); }
74  bool isFormed() const { return m_Formed; }
75 
76  void AddMember(Creature* member);
77  void RemoveMember(Creature* member);
78  void FormationReset(bool dismiss);
79 
80  void LeaderMoveTo(float x, float y, float z);
81  void MemberAttackStart(Creature* member, Unit* target);
82 };
83 
84 #define sFormationMgr FormationMgr::instance()
85 
86 #endif
CreatureGroupInfoType CreatureGroupMap
Definition: CreatureGroups.h:53
std::unordered_map< ObjectGuid::LowType, FormationInfo * > CreatureGroupInfoType
Definition: CreatureGroups.h:39
ObjectGuid::LowType leaderGUID
Definition: CreatureGroups.h:31
CreatureGroup(ObjectGuid::LowType id)
Definition: CreatureGroups.h:68
uint32 point_2
Definition: CreatureGroups.h:36
arena_t NULL
Definition: jemalloc_internal.h:624
#define false
Definition: CascPort.h:18
Definition: CreatureGroups.h:29
Creature * getLeader() const
Definition: CreatureGroups.h:71
Definition: CreatureGroups.h:41
Definition: Creature.h:467
uint64 LowType
Definition: ObjectGuid.h:199
Definition: CreatureGroups.h:56
G3D::int16 z
Definition: Vector3int16.h:46
float follow_dist
Definition: CreatureGroups.h:32
bool isFormed() const
Definition: CreatureGroups.h:74
uint32_t uint32
Definition: Define.h:150
ObjectGuid::LowType m_groupID
Definition: CreatureGroups.h:63
G3D::int16 y
Definition: Vector2int16.h:38
std::map< Creature *, FormationInfo * > CreatureGroupMemberType
Definition: CreatureGroups.h:60
uint32 point_1
Definition: CreatureGroups.h:35
Creature * m_leader
Definition: CreatureGroups.h:59
#define TC_GAME_API
Definition: Define.h:134
uint8_t uint8
Definition: Define.h:152
ObjectGuid::LowType GetId() const
Definition: CreatureGroups.h:72
bool m_Formed
Definition: CreatureGroups.h:64
~CreatureGroup()
Definition: CreatureGroups.h:69
G3D::int16 x
Definition: Vector2int16.h:37
FormationMgr()
Definition: CreatureGroups.h:44
Definition: Unit.h:1305
float follow_angle
Definition: CreatureGroups.h:33
bool isEmpty() const
Definition: CreatureGroups.h:73
CreatureGroupMemberType m_members
Definition: CreatureGroups.h:61
uint8 groupAI
Definition: CreatureGroups.h:34