1 | /* |
---|
2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
3 | * |
---|
4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef _UNITEVENTS |
---|
22 | #define _UNITEVENTS |
---|
23 | |
---|
24 | #include "Common.h" |
---|
25 | |
---|
26 | class ThreatContainer; |
---|
27 | class ThreatManager; |
---|
28 | class HostilReference; |
---|
29 | |
---|
30 | //============================================================== |
---|
31 | //============================================================== |
---|
32 | |
---|
33 | enum UNIT_EVENT_TYPE |
---|
34 | { |
---|
35 | // Player/Pet changed on/offline status |
---|
36 | UEV_THREAT_REF_ONLINE_STATUS = 1<<0, |
---|
37 | |
---|
38 | // Threat for Player/Pet changed |
---|
39 | UEV_THREAT_REF_THREAT_CHANGE = 1<<1, |
---|
40 | |
---|
41 | // Player/Pet will be removed from list (dead) [for internal use] |
---|
42 | UEV_THREAT_REF_REMOVE_FROM_LIST = 1<<2, |
---|
43 | |
---|
44 | // Player/Pet entered/left water or some other place where it is/was not accessible for the creature |
---|
45 | UEV_THREAT_REF_ASSECCIBLE_STATUS = 1<<3, |
---|
46 | |
---|
47 | // Threat list is going to be sorted (if dirty flag is set) |
---|
48 | UEV_THREAT_SORT_LIST = 1<<4, |
---|
49 | |
---|
50 | // New target should be fetched, could tbe the current target as well |
---|
51 | UEV_THREAT_SET_NEXT_TARGET = 1<<5, |
---|
52 | |
---|
53 | // A new victim (target) was set. Could be NULL |
---|
54 | UEV_THREAT_VICTIM_CHANGED = 1<<6, |
---|
55 | |
---|
56 | // Future use |
---|
57 | //UEV_UNIT_KILLED = 1<<7, |
---|
58 | |
---|
59 | //Future use |
---|
60 | //UEV_UNIT_HEALTH_CHANGE = 1<<8, |
---|
61 | }; |
---|
62 | |
---|
63 | #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) |
---|
64 | #define UEV_THREAT_MANAGER_EVENT_MASK (UEV_THREAT_SORT_LIST | UEV_THREAT_SET_NEXT_TARGET | UEV_THREAT_VICTIM_CHANGED) |
---|
65 | #define UEV_ALL_EVENT_MASK (0xffffffff) |
---|
66 | |
---|
67 | // Future use |
---|
68 | //#define UEV_UNIT_EVENT_MASK (UEV_UNIT_KILLED | UEV_UNIT_HEALTH_CHANGE) |
---|
69 | |
---|
70 | //============================================================== |
---|
71 | |
---|
72 | class TRINITY_DLL_SPEC UnitBaseEvent |
---|
73 | { |
---|
74 | private: |
---|
75 | uint32 iType; |
---|
76 | public: |
---|
77 | UnitBaseEvent(uint32 pType) { iType = pType; } |
---|
78 | uint32 getType() const { return iType; } |
---|
79 | bool matchesTypeMask(uint32 pMask) const { return iType & pMask; } |
---|
80 | |
---|
81 | void setType(uint32 pType) { iType = pType; } |
---|
82 | |
---|
83 | }; |
---|
84 | |
---|
85 | //============================================================== |
---|
86 | |
---|
87 | class TRINITY_DLL_SPEC ThreatRefStatusChangeEvent : public UnitBaseEvent |
---|
88 | { |
---|
89 | private: |
---|
90 | HostilReference* iHostilReference; |
---|
91 | union |
---|
92 | { |
---|
93 | float iFValue; |
---|
94 | int32 iIValue; |
---|
95 | bool iBValue; |
---|
96 | }; |
---|
97 | ThreatManager* iThreatManager; |
---|
98 | public: |
---|
99 | ThreatRefStatusChangeEvent(uint32 pType) : UnitBaseEvent(pType) { iHostilReference = NULL; } |
---|
100 | |
---|
101 | ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; } |
---|
102 | |
---|
103 | ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference, float pValue) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; iFValue = pValue; } |
---|
104 | |
---|
105 | ThreatRefStatusChangeEvent(uint32 pType, HostilReference* pHostilReference, bool pValue) : UnitBaseEvent(pType) { iHostilReference = pHostilReference; iBValue = pValue; } |
---|
106 | |
---|
107 | int32 getIValue() const { return iIValue; } |
---|
108 | |
---|
109 | float getFValue() const { return iFValue; } |
---|
110 | |
---|
111 | bool getBValue() const { return iBValue; } |
---|
112 | |
---|
113 | void setBValue(bool pValue) { iBValue = pValue; } |
---|
114 | |
---|
115 | HostilReference* getReference() const { return iHostilReference; } |
---|
116 | |
---|
117 | void setThreatManager(ThreatManager* pThreatManager) { iThreatManager = pThreatManager; } |
---|
118 | |
---|
119 | ThreatManager* getThreatManager() const { return iThreatManager; } |
---|
120 | }; |
---|
121 | |
---|
122 | //============================================================== |
---|
123 | |
---|
124 | class TRINITY_DLL_SPEC ThreatManagerEvent : public ThreatRefStatusChangeEvent |
---|
125 | { |
---|
126 | private: |
---|
127 | ThreatContainer* iThreatContainer; |
---|
128 | public: |
---|
129 | ThreatManagerEvent(uint32 pType) : ThreatRefStatusChangeEvent(pType) {} |
---|
130 | ThreatManagerEvent(uint32 pType, HostilReference* pHostilReference) : ThreatRefStatusChangeEvent(pType, pHostilReference) {} |
---|
131 | |
---|
132 | void setThreatContainer(ThreatContainer* pThreatContainer) { iThreatContainer = pThreatContainer; } |
---|
133 | |
---|
134 | ThreatContainer* getThreatContainer() const { return iThreatContainer; } |
---|
135 | }; |
---|
136 | |
---|
137 | //============================================================== |
---|
138 | #endif |
---|