Core/Shared: Move container functions to shared project under Trinity::Container namespace. Also implement RandomResizeList which takes a predicate function as parameter.
Core/ScriptedAI: Extend SummonList::DoAction to take a predicate function as parameter and allow specifying a maximum number of units to be selected.
This commit is contained in:
1 parent
e636531da3
commit
bc96df1aae
33 files changed
+153
-82
No files matched your search
@@ -38,7 +38,18 @@ class SummonList : public std::list<uint64>
|
||||
void Despawn(Creature* summon) { remove(summon->GetGUID()); }
|
||||
void DespawnEntry(uint32 entry);
|
||||
void DespawnAll();
|
||||
void DoAction(uint32 entry, int32 info);
|
||||
|
||||
template <class Predicate> void DoAction(int32 info, Predicate& predicate, uint16 max = 0)
|
||||
{
|
||||
Trinity::Containers::RandomResizeList<uint64, Predicate>(*this, predicate, max);
|
||||
for (iterator i = begin(); i != end(); )
|
||||
{
|
||||
Creature* summon = Unit::GetCreature(*me, *i++);
|
||||
if (summon && summon->IsAIEnabled)
|
||||
summon->AI()->DoAction(info);
|
||||
}
|
||||
}
|
||||
|
||||
void DoZoneInCombat(uint32 entry = 0);
|
||||
void RemoveNotExisting();
|
||||
bool HasEntry(uint32 entry);
|
||||
@@ -46,6 +57,22 @@ class SummonList : public std::list<uint64>
|
||||
Creature* me;
|
||||
};
|
||||
|
||||
class EntryCheckPredicate
|
||||
{
|
||||
public:
|
||||
EntryCheckPredicate(uint32 entry) : _entry(entry) {}
|
||||
bool operator()(uint64 guid) { return GUID_ENPART(guid) == _entry; }
|
||||
|
||||
private:
|
||||
uint32 _entry;
|
||||
};
|
||||
|
||||
class DummyEntryCheckPredicate
|
||||
{
|
||||
public:
|
||||
bool operator()(uint64) { return true; }
|
||||
};
|
||||
|
||||
struct ScriptedAI : public CreatureAI
|
||||
{
|
||||
explicit ScriptedAI(Creature* creature);
|
||||
|
||||
Reference in new issue
Block a user