TrinityCore
SpellScript::ObjectTargetSelectHandler Class Referencefinal

#include <SpellScript.h>

Classes

union  SpellObjectTargetSelectFnType
 

Public Types

using SafeWrapperType = void(*)(SpellScript *spellScript, WorldObject *&target, SpellObjectTargetSelectFnType callImpl)
 

Public Member Functions

template<typename ScriptFunc >
 ObjectTargetSelectHandler (ScriptFunc handler, uint8 effIndex, uint16 targetType)
 
void Call (SpellScript *spellScript, WorldObject *&target) const
 
- Public Member Functions inherited from SpellScript::TargetHook
 TargetHook (uint8 effectIndex, uint16 targetType, bool area, bool dest)
 
 TargetHook (TargetHook const &right)=delete
 
 TargetHook (TargetHook &&right) noexcept
 
TargetHookoperator= (TargetHook const &right)=delete
 
TargetHookoperator= (TargetHook &&right) noexcept
 
virtual ~TargetHook ()
 
bool CheckEffect (SpellInfo const *spellInfo, uint8 effIndex) const override
 
std::string ToString () const
 
uint16 GetTarget () const
 
- Public Member Functions inherited from SpellScriptBase::EffectHook
 EffectHook (uint8 effIndex)
 
 EffectHook (EffectHook const &right)=delete
 
 EffectHook (EffectHook &&right) noexcept
 
EffectHookoperator= (EffectHook const &right)=delete
 
EffectHookoperator= (EffectHook &&right) noexcept
 
virtual ~EffectHook ()
 
uint32 GetAffectedEffectsMask (SpellInfo const *spellInfo) const
 
bool IsEffectAffected (SpellInfo const *spellInfo, uint8 effIndex) const
 
virtual bool CheckEffect (SpellInfo const *spellInfo, uint8 effIndex) const =0
 
std::string EffIndexToString () const
 

Private Attributes

SpellObjectTargetSelectFnType _callImpl
 
SafeWrapperType _safeWrapper
 

Additional Inherited Members

- Protected Attributes inherited from SpellScript::TargetHook
uint16 _targetType
 
bool _area
 
bool _dest
 
- Protected Attributes inherited from SpellScriptBase::EffectHook
uint8 _effIndex
 

Detailed Description

Definition at line 578 of file SpellScript.h.

Member Typedef Documentation

◆ SafeWrapperType

Definition at line 587 of file SpellScript.h.

Constructor & Destructor Documentation

◆ ObjectTargetSelectHandler()

template<typename ScriptFunc >
SpellScript::ObjectTargetSelectHandler::ObjectTargetSelectHandler ( ScriptFunc  handler,
uint8  effIndex,
uint16  targetType 
)
inlineexplicit

Definition at line 590 of file SpellScript.h.

591 : TargetHook(effIndex, targetType, false, false)
592 {
593 using ScriptClass = GetScriptClass_t<ScriptFunc>;
594
595 static_assert(sizeof(SpellObjectTargetSelectFnType) >= sizeof(ScriptFunc));
596 static_assert(alignof(SpellObjectTargetSelectFnType) >= alignof(ScriptFunc));
597
598 if constexpr (!std::is_void_v<ScriptClass>)
599 {
600 static_assert(std::is_invocable_r_v<void, ScriptFunc, ScriptClass, WorldObject*&>,
601 "ObjectTargetSelectHandler signature must be \"void SetTarget(WorldObject*& target)\"");
602
603 _callImpl = { .Member = reinterpret_cast<decltype(SpellObjectTargetSelectFnType::Member)>(handler) };
604 _safeWrapper = [](SpellScript* spellScript, WorldObject*& target, SpellObjectTargetSelectFnType callImpl) -> void
605 {
606 return (static_cast<ScriptClass*>(spellScript)->*reinterpret_cast<ScriptFunc>(callImpl.Member))(target);
607 };
608 }
609 else
610 {
611 static_assert(std::is_invocable_r_v<void, ScriptFunc, WorldObject*&>,
612 "ObjectTargetSelectHandler signature must be \"static void SetTarget(WorldObject*& target)\"");
613
614 _callImpl = { .Static = reinterpret_cast<decltype(SpellObjectTargetSelectFnType::Static)>(handler) };
615 _safeWrapper = [](SpellScript* /*spellScript*/, WorldObject*& target, SpellObjectTargetSelectFnType callImpl) -> void
616 {
617 return reinterpret_cast<ScriptFunc>(callImpl.Static)(target);
618 };
619 }
620 }
SpellObjectTargetSelectFnType _callImpl
Definition: SpellScript.h:627
TargetHook(uint8 effectIndex, uint16 targetType, bool area, bool dest)

Member Function Documentation

◆ Call()

void SpellScript::ObjectTargetSelectHandler::Call ( SpellScript spellScript,
WorldObject *&  target 
) const
inline

Definition at line 622 of file SpellScript.h.

623 {
624 return _safeWrapper(spellScript, target, _callImpl);
625 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ _callImpl

SpellObjectTargetSelectFnType SpellScript::ObjectTargetSelectHandler::_callImpl
private

Definition at line 627 of file SpellScript.h.

◆ _safeWrapper

SafeWrapperType SpellScript::ObjectTargetSelectHandler::_safeWrapper
private

Definition at line 628 of file SpellScript.h.


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