BNM 2.4.0
 
Loading...
Searching...
No Matches
BNM::Event< Ret, Parameters > Struct Template Reference

Typed class for working with il2cpp events. More...

#include <Event.hpp>

Public Member Functions

constexpr Event ()=default
 Create empty event base.
 
template<typename OtherType>
 Event (const Event< OtherType > &other)
 Copy event.
 
 Event (const IL2CPP::EventInfo *info)
 Create event from il2cpp event.
 
 Event (const EventBase &other)
 Convert base event to typed event.
 
Event< Ret, Parameters... > & operator[] (void *instance)
 Operator for setting instance.
 
Event< Ret, Parameters... > & operator[] (IL2CPP::Il2CppObject *instance)
 Operator for setting instance.
 
Event< Ret, Parameters... > & operator[] (UnityEngine::Object *instance)
 Operator for setting instance.
 
void Add (Delegate< Ret > *delegate)
 Add delegate to event.
 
Event< Ret, Parameters... > & operator+= (Delegate< Ret > *delegate)
 Operator for adding delegate to event.
 
void Remove (Delegate< Ret > *delegate)
 Remove delegate from event.
 
Event< Ret, Parameters... > & operator-= (Delegate< Ret > *v)
 Operator for removing delegate from event.
 
Ret Raise (Parameters ...parameters) const
 Raise (call) event.
 
Ret operator() (Parameters ...parameters) const
 Raise (call) event.
 
Event< Ret > & operator= (const EventBase &other)
 Convert base event to typed event.
 
- Public Member Functions inherited from BNM::EventBase
constexpr EventBase () noexcept=default
 Create empty event base.
 
 EventBase (const EventBase &other)=default
 Copy event.
 
 EventBase (const IL2CPP::EventInfo *info)
 Create event from il2cpp event.
 
EventBaseSetInstance (IL2CPP::Il2CppObject *instance)
 Set event instance if it's non-static.
 
EventBaseoperator[] (void *instance)
 Operator for setting instance.
 
EventBaseoperator[] (IL2CPP::Il2CppObject *instance)
 Operator for setting instance.
 
EventBaseoperator[] (UnityEngine::Object *instance)
 Operator for setting instance.
 
bool IsValid () const noexcept
 Check if event is valid.
 
std::string str () const
 Get full event name.
 
template<typename NewRet, typename ... NewParameters>
Event< NewRet, NewParameters... > & cast () const
 Cast event to be able to add, remove and raise it.
 

Additional Inherited Members

- Public Attributes inherited from BNM::EventBase
IL2CPP::EventInfo * _data {}
 
MethodBase _add {}
 
MethodBase _remove {}
 
MethodBase _raise {}
 
uint8_t _hasAdd: 1 = false
 
uint8_t _hasRemove: 1 = false
 
uint8_t _hasRaise: 1 = false
 

Detailed Description

template<typename Ret = void, typename ... Parameters>
struct BNM::Event< Ret, Parameters >

Typed class for working with il2cpp events.

This class provides API for adding, removing and rising event.

Template Parameters
RetReturn type of event
ParametersParameters of event

Constructor & Destructor Documentation

◆ Event() [1/3]

template<typename Ret = void, typename ... Parameters>
template<typename OtherType>
BNM::Event< Ret, Parameters >::Event ( const Event< OtherType > & other)
inline

Copy event.

Parameters
otherOther event
Template Parameters
OtherTypeType of other event

◆ Event() [2/3]

template<typename Ret = void, typename ... Parameters>
BNM::Event< Ret, Parameters >::Event ( const IL2CPP::EventInfo * info)
inline

Create event from il2cpp event.

Parameters
infoIl2cpp event

◆ Event() [3/3]

template<typename Ret = void, typename ... Parameters>
BNM::Event< Ret, Parameters >::Event ( const EventBase & other)
inline

Convert base event to typed event.

Parameters
otherBase event

Member Function Documentation

◆ Add()

template<typename Ret = void, typename ... Parameters>
void BNM::Event< Ret, Parameters >::Add ( Delegate< Ret > * delegate)
inline

Add delegate to event.

Parameters
delegateDelegate to add

◆ operator()()

template<typename Ret = void, typename ... Parameters>
Ret BNM::Event< Ret, Parameters >::operator() ( Parameters ... parameters) const
inline

Raise (call) event.

Parameters
parametersParameters of event
Returns
Value of Ret type

◆ operator+=()

template<typename Ret = void, typename ... Parameters>
Event< Ret, Parameters... > & BNM::Event< Ret, Parameters >::operator+= ( Delegate< Ret > * delegate)
inline

Operator for adding delegate to event.

Parameters
delegateDelegate to add

◆ operator-=()

template<typename Ret = void, typename ... Parameters>
Event< Ret, Parameters... > & BNM::Event< Ret, Parameters >::operator-= ( Delegate< Ret > * v)
inline

Operator for removing delegate from event.

Parameters
delegateDelegate to remove

◆ operator=()

template<typename Ret = void, typename ... Parameters>
Event< Ret > & BNM::Event< Ret, Parameters >::operator= ( const EventBase & other)
inline

Convert base event to typed event.

Parameters
otherBase event

◆ operator[]() [1/3]

template<typename Ret = void, typename ... Parameters>
Event< Ret, Parameters... > & BNM::Event< Ret, Parameters >::operator[] ( IL2CPP::Il2CppObject * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Event

◆ operator[]() [2/3]

template<typename Ret = void, typename ... Parameters>
Event< Ret, Parameters... > & BNM::Event< Ret, Parameters >::operator[] ( UnityEngine::Object * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Event

◆ operator[]() [3/3]

template<typename Ret = void, typename ... Parameters>
Event< Ret, Parameters... > & BNM::Event< Ret, Parameters >::operator[] ( void * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Event

◆ Raise()

template<typename Ret = void, typename ... Parameters>
Ret BNM::Event< Ret, Parameters >::Raise ( Parameters ... parameters) const
inline

Raise (call) event.

Parameters
parametersParameters of event
Returns
Value of Ret type

◆ Remove()

template<typename Ret = void, typename ... Parameters>
void BNM::Event< Ret, Parameters >::Remove ( Delegate< Ret > * delegate)
inline

Remove delegate from event.

Parameters
delegateDelegate to remove