TrinityCore
SpellScript::BeforeHitHandler Class Referencefinal

#include <SpellScript.h>

Public Types

using SpellBeforeHitFnType = void(SpellScript::*)(SpellMissInfo missInfo)
 
using SafeWrapperType = void(*)(SpellScript *spellScript, SpellMissInfo missInfo, SpellBeforeHitFnType callImpl)
 

Public Member Functions

template<typename ScriptFunc >
 BeforeHitHandler (ScriptFunc handler)
 
void Call (SpellScript *spellScript, SpellMissInfo missInfo) const
 

Private Attributes

SpellBeforeHitFnType _callImpl
 
SafeWrapperType _safeWrapper
 

Detailed Description

Definition at line 387 of file SpellScript.h.

Member Typedef Documentation

◆ SafeWrapperType

Definition at line 392 of file SpellScript.h.

◆ SpellBeforeHitFnType

Definition at line 390 of file SpellScript.h.

Constructor & Destructor Documentation

◆ BeforeHitHandler()

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

Definition at line 395 of file SpellScript.h.

396 {
397 using ScriptClass = GetScriptClass_t<ScriptFunc>;
398
399 static_assert(sizeof(SpellBeforeHitFnType) >= sizeof(ScriptFunc));
400 static_assert(alignof(SpellBeforeHitFnType) >= alignof(ScriptFunc));
401
402 static_assert(std::is_invocable_r_v<void, ScriptFunc, ScriptClass, SpellMissInfo>,
403 "BeforeHitHandler signature must be \"void HandleBeforeHit(SpellMissInfo missInfo)\"");
404
405 _callImpl = reinterpret_cast<SpellBeforeHitFnType>(handler);
406 _safeWrapper = [](SpellScript* spellScript, SpellMissInfo missInfo, SpellBeforeHitFnType callImpl) -> void
407 {
408 return (static_cast<ScriptClass*>(spellScript)->*reinterpret_cast<ScriptFunc>(callImpl))(missInfo);
409 };
410 }
SpellMissInfo
void(SpellScript::*)(SpellMissInfo missInfo) SpellBeforeHitFnType
Definition: SpellScript.h:390
SafeWrapperType _safeWrapper
Definition: SpellScript.h:418
SpellBeforeHitFnType _callImpl
Definition: SpellScript.h:417

Member Function Documentation

◆ Call()

void SpellScript::BeforeHitHandler::Call ( SpellScript spellScript,
SpellMissInfo  missInfo 
) const
inline

Definition at line 412 of file SpellScript.h.

413 {
414 return _safeWrapper(spellScript, missInfo, _callImpl);
415 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ _callImpl

SpellBeforeHitFnType SpellScript::BeforeHitHandler::_callImpl
private

Definition at line 417 of file SpellScript.h.

◆ _safeWrapper

SafeWrapperType SpellScript::BeforeHitHandler::_safeWrapper
private

Definition at line 418 of file SpellScript.h.


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