TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SummonList Class Reference

#include <ScriptedCreature.h>

Public Types

typedef GuidList StorageType
 
typedef StorageType::iterator iterator
 
typedef StorageType::const_iterator const_iterator
 
typedef StorageType::size_type size_type
 
typedef StorageType::value_type value_type
 

Public Member Functions

 SummonList (Creature *creature)
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator erase (iterator i)
 
bool empty () const
 
size_type size () const
 
void Summon (Creature const *summon)
 
void Despawn (Creature const *summon)
 
void DespawnEntry (uint32 entry)
 
void DespawnAll ()
 
template<typename T >
void DespawnIf (T const &predicate)
 
template<class Predicate >
void DoAction (int32 info, Predicate &predicate, uint16 max=0)
 
void DoZoneInCombat (uint32 entry=0)
 
void RemoveNotExisting ()
 
bool HasEntry (uint32 entry) const
 

Private Attributes

Creatureme
 
StorageType storage_
 

Member Typedef Documentation

typedef StorageType::const_iterator SummonList::const_iterator
typedef StorageType::iterator SummonList::iterator
typedef StorageType::size_type SummonList::size_type
typedef StorageType::value_type SummonList::value_type

Constructor & Destructor Documentation

SummonList::SummonList ( Creature creature)
inlineexplicit
51  : me(creature)
52  { }
Creature * me
Definition: ScriptedCreature.h:122

Member Function Documentation

iterator SummonList::begin ( )
inline
58  {
59  return storage_.begin();
60  }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the caller graph for this function:

const_iterator SummonList::begin ( ) const
inline
63  {
64  return storage_.begin();
65  }
StorageType storage_
Definition: ScriptedCreature.h:123
void SummonList::Despawn ( Creature const summon)
inline
93 { storage_.remove(summon->GetGUID()); }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SummonList::DespawnAll ( )
67 {
68  while (!storage_.empty())
69  {
70  Creature* summon = ObjectAccessor::GetCreature(*me, storage_.front());
71  storage_.pop_front();
72  if (summon)
73  summon->DespawnOrUnsummon();
74  }
75 }
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
Creature * me
Definition: ScriptedCreature.h:122
StorageType storage_
Definition: ScriptedCreature.h:123
Definition: Creature.h:467
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174

+ Here is the call graph for this function:

void SummonList::DespawnEntry ( uint32  entry)
50 {
51  for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
52  {
53  Creature* summon = ObjectAccessor::GetCreature(*me, *i);
54  if (!summon)
55  i = storage_.erase(i);
56  else if (summon->GetEntry() == entry)
57  {
58  i = storage_.erase(i);
59  summon->DespawnOrUnsummon();
60  }
61  else
62  ++i;
63  }
64 }
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
Creature * me
Definition: ScriptedCreature.h:122
StorageType storage_
Definition: ScriptedCreature.h:123
Definition: Creature.h:467
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
uint32 GetEntry() const
Definition: Object.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void SummonList::DespawnIf ( T const predicate)
inline
99  {
100  storage_.remove_if(predicate);
101  }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the caller graph for this function:

template<class Predicate >
void SummonList::DoAction ( int32  info,
Predicate &  predicate,
uint16  max = 0 
)
inline
105  {
106  // We need to use a copy of SummonList here, otherwise original SummonList would be modified
107  StorageType listCopy = storage_;
108  Trinity::Containers::RandomResizeList<ObjectGuid, Predicate>(listCopy, predicate, max);
109  for (StorageType::iterator i = listCopy.begin(); i != listCopy.end(); )
110  {
111  Creature* summon = ObjectAccessor::GetCreature(*me, *i++);
112  if (summon && summon->IsAIEnabled)
113  summon->AI()->DoAction(info);
114  }
115  }
Creature * me
Definition: ScriptedCreature.h:122
StorageType storage_
Definition: ScriptedCreature.h:123
Definition: Creature.h:467
bool IsAIEnabled
Definition: Unit.h:2161
GuidList StorageType
Definition: ScriptedCreature.h:44
T max(const T &x, const T &y)
Definition: g3dmath.h:320
CreatureAI * AI() const
Definition: Creature.h:525
virtual void DoAction(int32)
Definition: UnitAI.h:138
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SummonList::DoZoneInCombat ( uint32  entry = 0)
36 {
37  for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
38  {
39  Creature* summon = ObjectAccessor::GetCreature(*me, *i);
40  ++i;
41  if (summon && summon->IsAIEnabled
42  && (!entry || summon->GetEntry() == entry))
43  {
44  summon->AI()->DoZoneInCombat();
45  }
46  }
47 }
Creature * me
Definition: ScriptedCreature.h:122
void DoZoneInCombat(Creature *creature=NULL, float maxRangeToNearestTarget=50.0f)
Definition: CreatureAI.cpp:47
StorageType storage_
Definition: ScriptedCreature.h:123
Definition: Creature.h:467
bool IsAIEnabled
Definition: Unit.h:2161
CreatureAI * AI() const
Definition: Creature.h:525
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
uint32 GetEntry() const
Definition: Object.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SummonList::empty ( ) const
inline
83  {
84  return storage_.empty();
85  }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the caller graph for this function:

iterator SummonList::end ( )
inline
68  {
69  return storage_.end();
70  }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the caller graph for this function:

const_iterator SummonList::end ( ) const
inline
73  {
74  return storage_.end();
75  }
StorageType storage_
Definition: ScriptedCreature.h:123
iterator SummonList::erase ( iterator  i)
inline
78  {
79  return storage_.erase(i);
80  }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the caller graph for this function:

bool SummonList::HasEntry ( uint32  entry) const
89 {
90  for (StorageType::const_iterator i = storage_.begin(); i != storage_.end(); ++i)
91  {
92  Creature* summon = ObjectAccessor::GetCreature(*me, *i);
93  if (summon && summon->GetEntry() == entry)
94  return true;
95  }
96 
97  return false;
98 }
Creature * me
Definition: ScriptedCreature.h:122
StorageType storage_
Definition: ScriptedCreature.h:123
Definition: Creature.h:467
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174
uint32 GetEntry() const
Definition: Object.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SummonList::RemoveNotExisting ( )
78 {
79  for (StorageType::iterator i = storage_.begin(); i != storage_.end();)
80  {
82  ++i;
83  else
84  i = storage_.erase(i);
85  }
86 }
Creature * me
Definition: ScriptedCreature.h:122
StorageType storage_
Definition: ScriptedCreature.h:123
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:174

+ Here is the call graph for this function:

size_type SummonList::size ( ) const
inline
88  {
89  return storage_.size();
90  }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the caller graph for this function:

void SummonList::Summon ( Creature const summon)
inline
92 { storage_.push_back(summon->GetGUID()); }
StorageType storage_
Definition: ScriptedCreature.h:123

+ Here is the call graph for this function:

Member Data Documentation

Creature* SummonList::me
private
StorageType SummonList::storage_
private

The documentation for this class was generated from the following files: