Core/Units: Added new accessor methods to select Summons either by slot, spellId or creatureId
This commit is contained in:
1 parent
2f9ced6ddc
commit
7f4c7a4412
2 files changed
+60
No files matched your search
@@ -8874,6 +8874,57 @@ void Unit::UnregisterSummon(SummonInfo* summon)
|
||||
_slottedSummons[targetSlot] = nullptr;
|
||||
}
|
||||
|
||||
SummonInfo* Unit::GetSummonInSlot(SummonPropertiesSlot slot) const
|
||||
{
|
||||
if (slot == SummonPropertiesSlot::None ||
|
||||
slot == SummonPropertiesSlot::Max ||
|
||||
slot == SummonPropertiesSlot::AnyAvailableTotem)
|
||||
return nullptr;
|
||||
|
||||
return _slottedSummons[AsUnderlyingType(slot)];
|
||||
}
|
||||
|
||||
std::vector<SummonInfo*> Unit::GetSummonsByCreatureId(uint32 creatureId)
|
||||
{
|
||||
if (creatureId == 0)
|
||||
return {};
|
||||
|
||||
std::vector<SummonInfo*> summons;
|
||||
|
||||
|
||||
std::ranges::copy_if(_wildSummons, std::back_inserter(summons), [creatureId](SummonInfo const* summon)
|
||||
{
|
||||
return summon->GetSummonedCreature()->GetEntry() == creatureId;
|
||||
});
|
||||
|
||||
std::ranges::copy_if(_slottedSummons, std::back_inserter(summons), [creatureId](SummonInfo const* summon)
|
||||
{
|
||||
return summon->GetSummonedCreature()->GetEntry() == creatureId;
|
||||
});
|
||||
|
||||
return summons;
|
||||
}
|
||||
|
||||
std::vector<SummonInfo*> Unit::GetSummonsBySpellId(uint32 spellId)
|
||||
{
|
||||
if (spellId == 0)
|
||||
return {};
|
||||
|
||||
std::vector<SummonInfo*> summons;
|
||||
|
||||
std::ranges::copy_if(_wildSummons, std::back_inserter(summons), [spellId](SummonInfo const* summon)
|
||||
{
|
||||
return summon->GetSummonedCreature()->GetUInt32Value(UNIT_CREATED_BY_SPELL) == spellId;
|
||||
});
|
||||
|
||||
std::ranges::copy_if(_slottedSummons, std::back_inserter(summons), [spellId](SummonInfo const* summon)
|
||||
{
|
||||
return summon->GetSummonedCreature()->GetUInt32Value(UNIT_CREATED_BY_SPELL) == spellId;
|
||||
});
|
||||
|
||||
return summons;
|
||||
}
|
||||
|
||||
void Unit::SetShapeshiftForm(ShapeshiftForm form)
|
||||
{
|
||||
SetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM, form);
|
||||
|
||||
@@ -103,6 +103,8 @@ enum ProcFlagsSpellType : uint32;
|
||||
enum ZLiquidStatus : uint32;
|
||||
enum CharmType : uint8;
|
||||
|
||||
enum class SummonPropertiesSlot: int8;
|
||||
|
||||
namespace Movement
|
||||
{
|
||||
class ExtraMovementStatusElement;
|
||||
@@ -1336,6 +1338,13 @@ class TC_GAME_API Unit : public WorldObject
|
||||
// Unregisters the SummonInfo API of a summoned creature so it can no longer be accessed
|
||||
void UnregisterSummon(SummonInfo* summon);
|
||||
|
||||
// Returns the currently active summon that is the summoner's specified summon slot
|
||||
SummonInfo* GetSummonInSlot(SummonPropertiesSlot slot) const;
|
||||
// Returns a vector with all currently active summons with the specified creature Id
|
||||
std::vector<SummonInfo*> GetSummonsByCreatureId(uint32 creatureId);
|
||||
// Returns a vector with all currently active summons which have been created by the specified spell Id
|
||||
std::vector<SummonInfo*> GetSummonsBySpellId(uint32 spellId);
|
||||
|
||||
ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, UNIT_BYTES_2_OFFSET_SHAPESHIFT_FORM)); }
|
||||
void SetShapeshiftForm(ShapeshiftForm form);
|
||||
|
||||
|
||||
Reference in new issue
Block a user