Updated Copyright year to 2013
[getmangos.git] / src / game / HostileRefManager.h
blobbdf10414d59fef879dd0ab35d781ce1e253a25cb
1 /*
2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
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.
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.
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
19 #ifndef _HOSTILEREFMANAGER
20 #define _HOSTILEREFMANAGER
22 #include "Common.h"
23 #include "ObjectGuid.h"
24 #include "Utilities/LinkedReference/RefManager.h"
26 class Unit;
27 class ThreatManager;
28 class HostileReference;
29 struct SpellEntry;
31 //=================================================
33 class HostileRefManager : public RefManager<Unit, ThreatManager>
35 public:
36 explicit HostileRefManager(Unit* pOwner);
37 ~HostileRefManager();
39 Unit* getOwner() { return iOwner; }
41 // send threat to all my hateres for the pVictim
42 // The pVictim is hated than by them as well
43 // use for buffs and healing threat functionality
44 void threatAssist(Unit* pVictim, float threat, SpellEntry const* threatSpell = 0, bool pSingleTarget = false);
46 void addThreatPercent(int32 pValue);
48 // The references are not needed anymore
49 // tell the source to remove them from the list and free the mem
50 void deleteReferences();
52 // Remove specific faction references
53 void deleteReferencesForFaction(uint32 faction);
55 HostileReference* getFirst() { return ((HostileReference*) RefManager<Unit, ThreatManager>::getFirst()); }
57 void updateThreatTables();
59 void setOnlineOfflineState(bool pIsOnline);
61 // set state for one reference, defined by Unit
62 void setOnlineOfflineState(Unit* pCreature, bool pIsOnline);
64 // delete one reference, defined by Unit
65 void deleteReference(Unit* pCreature);
67 // redirection threat data
68 void SetThreatRedirection(ObjectGuid guid, uint32 pct)
70 m_redirectionTargetGuid = guid;
71 m_redirectionMod = pct / 100.0f;
74 void ResetThreatRedirection()
76 m_redirectionTargetGuid.Clear();
77 m_redirectionMod = 0.0f;
80 float GetThreatRedirectionMod() const { return m_redirectionMod; }
81 Unit* GetThreatRedirectionTarget() const;
83 private:
84 Unit* iOwner; // owner of manager variable, back ref. to it, always exist
86 float m_redirectionMod;
87 ObjectGuid m_redirectionTargetGuid;
89 //=================================================
90 #endif