SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
EventDispatcher.h
1#pragma once
2
3namespace spark::events
4{
6 : m_event(event) {}
7
8 template <typename T, typename F>
9 bool EventDispatcher::dispatch(const F& func)
10 {
11 if (m_event.eventType() == T::StaticType())
12 {
13 m_event.handled = func(static_cast<T&>(m_event));
14 return true;
15 }
16 return false;
17 }
18}
EventDispatcher(Event &event)
Instantiates a new EventDispatcher for the given event.
Definition EventDispatcher.h:5
bool dispatch(const F &func)
Dispatches the event to the appropriate event handler.
Definition EventDispatcher.h:9
A base class for all events in SPARK.
Definition Event.h:53
virtual EventType eventType() const =0
Gets the type of the event.