TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
UnitEvents.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 _UNITEVENTS
20 #define _UNITEVENTS
21 
22 #include "Common.h"
23 
24 class ThreatContainer;
25 class ThreatManager;
26 class HostileReference;
27 
28 //==============================================================
29 //==============================================================
30 
32 {
33  // Player/Pet changed on/offline status
35 
36  // Threat for Player/Pet changed
38 
39  // Player/Pet will be removed from list (dead) [for internal use]
41 
42  // Player/Pet entered/left water or some other place where it is/was not accessible for the creature
44 
45  // Threat list is going to be sorted (if dirty flag is set)
47 
48  // New target should be fetched, could tbe the current target as well
50 
51  // A new victim (target) was set. Could be NULL
53 
54  // Future use
55  //UEV_UNIT_KILLED = 1<<7,
56 
57  //Future use
58  //UEV_UNIT_HEALTH_CHANGE = 1<<8,
59 };
60 
61 #define UEV_THREAT_REF_EVENT_MASK (UEV_THREAT_REF_ONLINE_STATUS | UEV_THREAT_REF_THREAT_CHANGE | UEV_THREAT_REF_REMOVE_FROM_LIST | UEV_THREAT_REF_ASSECCIBLE_STATUS)
62 #define UEV_THREAT_MANAGER_EVENT_MASK (UEV_THREAT_SORT_LIST | UEV_THREAT_SET_NEXT_TARGET | UEV_THREAT_VICTIM_CHANGED)
63 #define UEV_ALL_EVENT_MASK (0xffffffff)
64 
65 // Future use
66 //#define UEV_UNIT_EVENT_MASK (UEV_UNIT_KILLED | UEV_UNIT_HEALTH_CHANGE)
67 
68 //==============================================================
69 
71 {
72  private:
74  public:
75  UnitBaseEvent(uint32 pType) { iType = pType; }
76  uint32 getType() const { return iType; }
77  bool matchesTypeMask(uint32 pMask) const { return (iType & pMask) != 0; }
78 
79  void setType(uint32 pType) { iType = pType; }
80 };
81 
82 //==============================================================
83 
85 {
86  private:
88  union
89  {
90  float iFValue;
92  bool iBValue;
93  };
95  public:
96  ThreatRefStatusChangeEvent(uint32 pType) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = NULL; }
97 
98  ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = pHostileReference; }
99 
100  ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, float pValue) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = pHostileReference; iFValue = pValue; }
101 
102  ThreatRefStatusChangeEvent(uint32 pType, HostileReference* pHostileReference, bool pValue) : UnitBaseEvent(pType), iThreatManager(NULL) { iHostileReference = pHostileReference; iBValue = pValue; }
103 
104  int32 getIValue() const { return iIValue; }
105 
106  float getFValue() const { return iFValue; }
107 
108  bool getBValue() const { return iBValue; }
109 
110  void setBValue(bool pValue) { iBValue = pValue; }
111 
112  HostileReference* getReference() const { return iHostileReference; }
113 
114  void setThreatManager(ThreatManager* pThreatManager) { iThreatManager = pThreatManager; }
115 
116  ThreatManager* getThreatManager() const { return iThreatManager; }
117 };
118 
119 //==============================================================
120 
122 {
123  private:
125  public:
126  ThreatManagerEvent(uint32 pType) : ThreatRefStatusChangeEvent(pType), iThreatContainer(NULL) { }
127  ThreatManagerEvent(uint32 pType, HostileReference* pHostileReference) : ThreatRefStatusChangeEvent(pType, pHostileReference), iThreatContainer(NULL) { }
128 
129  void setThreatContainer(ThreatContainer* pThreatContainer) { iThreatContainer = pThreatContainer; }
130 
132 };
133 
134 //==============================================================
135 #endif
Definition: UnitEvents.h:43
float getFValue() const
Definition: UnitEvents.h:106
ThreatContainer * getThreatContainer() const
Definition: UnitEvents.h:131
bool iBValue
Definition: UnitEvents.h:92
void setThreatManager(ThreatManager *pThreatManager)
Definition: UnitEvents.h:114
bool matchesTypeMask(uint32 pMask) const
Definition: UnitEvents.h:77
int32 iIValue
Definition: UnitEvents.h:91
ThreatContainer * iThreatContainer
Definition: UnitEvents.h:124
uint32 getType() const
Definition: UnitEvents.h:76
ThreatRefStatusChangeEvent(uint32 pType, HostileReference *pHostileReference, bool pValue)
Definition: UnitEvents.h:102
ThreatRefStatusChangeEvent(uint32 pType)
Definition: UnitEvents.h:96
ThreatRefStatusChangeEvent(uint32 pType, HostileReference *pHostileReference)
Definition: UnitEvents.h:98
Definition: UnitEvents.h:121
arena_t NULL
Definition: jemalloc_internal.h:624
ThreatManagerEvent(uint32 pType, HostileReference *pHostileReference)
Definition: UnitEvents.h:127
ThreatManagerEvent(uint32 pType)
Definition: UnitEvents.h:126
UnitBaseEvent(uint32 pType)
Definition: UnitEvents.h:75
Definition: ThreatManager.h:201
Definition: UnitEvents.h:37
Definition: UnitEvents.h:52
UNIT_EVENT_TYPE
Definition: UnitEvents.h:31
float iFValue
Definition: UnitEvents.h:90
Definition: UnitEvents.h:46
void setType(uint32 pType)
Definition: UnitEvents.h:79
Definition: UnitEvents.h:40
Definition: UnitEvents.h:34
Definition: ThreatManager.h:49
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
ThreatManager * iThreatManager
Definition: UnitEvents.h:94
ThreatManager * getThreatManager() const
Definition: UnitEvents.h:116
Definition: ThreatManager.h:144
Definition: UnitEvents.h:70
uint32 iType
Definition: UnitEvents.h:73
#define TC_GAME_API
Definition: Define.h:134
HostileReference * getReference() const
Definition: UnitEvents.h:112
void setBValue(bool pValue)
Definition: UnitEvents.h:110
int32 getIValue() const
Definition: UnitEvents.h:104
bool getBValue() const
Definition: UnitEvents.h:108
Definition: UnitEvents.h:84
Definition: UnitEvents.h:49
ThreatRefStatusChangeEvent(uint32 pType, HostileReference *pHostileReference, float pValue)
Definition: UnitEvents.h:100
HostileReference * iHostileReference
Definition: UnitEvents.h:87
void setThreatContainer(ThreatContainer *pThreatContainer)
Definition: UnitEvents.h:129