root/trunk/src/game/UnitEvents.h @ 6

Revision 2, 4.8 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

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