TrinityCore
SpellScript::HitHandler Class Referencefinal

#include <SpellScript.h>

Public Types

using SpellHitFnType = void(SpellScript::*)()
 
using SafeWrapperType = void(*)(SpellScript *spellScript, SpellHitFnType callImpl)
 

Public Member Functions

template<typename ScriptFunc >
 HitHandler (ScriptFunc handler)
 
void Call (SpellScript *spellScript) const
 

Private Attributes

SpellHitFnType _callImpl
 
SafeWrapperType _safeWrapper
 

Detailed Description

Definition at line 421 of file SpellScript.h.

Member Typedef Documentation

◆ SafeWrapperType

using SpellScript::HitHandler::SafeWrapperType = void(*)(SpellScript* spellScript, SpellHitFnType callImpl)

Definition at line 426 of file SpellScript.h.

◆ SpellHitFnType

using SpellScript::HitHandler::SpellHitFnType = void(SpellScript::*)()

Definition at line 424 of file SpellScript.h.

Constructor & Destructor Documentation

◆ HitHandler()

template<typename ScriptFunc >
SpellScript::HitHandler::HitHandler ( ScriptFunc  handler)
inlineexplicit

Definition at line 429 of file SpellScript.h.

430 {
431 using ScriptClass = GetScriptClass_t<ScriptFunc>;
432
433 static_assert(sizeof(SpellHitFnType) >= sizeof(ScriptFunc));
434 static_assert(alignof(SpellHitFnType) >= alignof(ScriptFunc));
435
436 static_assert(std::is_invocable_r_v<void, ScriptFunc, ScriptClass>,
437 "HitHandler signature must be \"void HandleHit()\"");
438
439 _callImpl = reinterpret_cast<SpellHitFnType>(handler);
440 _safeWrapper = [](SpellScript* spellScript, SpellHitFnType callImpl) -> void
441 {
442 return (static_cast<ScriptClass*>(spellScript)->*reinterpret_cast<ScriptFunc>(callImpl))();
443 };
444 }
void(SpellScript::*)() SpellHitFnType
Definition: SpellScript.h:424
SafeWrapperType _safeWrapper
Definition: SpellScript.h:452
SpellHitFnType _callImpl
Definition: SpellScript.h:451

Member Function Documentation

◆ Call()

void SpellScript::HitHandler::Call ( SpellScript spellScript) const
inline

Definition at line 446 of file SpellScript.h.

447 {
448 return _safeWrapper(spellScript, _callImpl);
449 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ _callImpl

SpellHitFnType SpellScript::HitHandler::_callImpl
private

Definition at line 451 of file SpellScript.h.

◆ _safeWrapper

SafeWrapperType SpellScript::HitHandler::_safeWrapper
private

Definition at line 452 of file SpellScript.h.


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