6#include "LkEngine/Core/LObject/ObjectPtr.h"
33 LK_ENUM_RANGE_BY_COUNT(
EEventType, EEventType::COUNT);
55 #define LEVENT(EventName, EventType, ...) \
57 using StaticEventClass = EventName; \
58 static ::LkEngine::EEventType GetStaticType() { return EEventType::EventType; } \
59 virtual ::LkEngine::EEventType GetType() const override { return GetStaticType(); } \
60 virtual const char* GetName() const override { return #EventType; } \
76 virtual const char* GetName()
const = 0;
77 virtual std::string ToString()
const {
return GetName(); }
79 FORCEINLINE
bool IsHandled()
const {
return bHandled; }
82 bool bHandled =
false;
85 inline std::ostream& operator<<(std::ostream& OStream,
const LEvent& InEvent)
87 return OStream << InEvent.ToString();
90 using FEventCallback = std::function<void(LEvent&)>;
91 using FEventHandler = std::function<void(LEvent&)>;
98 template<
typename EventType>
99 using EventFn = std::function<bool(EventType&)>;
107 FORCEINLINE
bool Dispatch(EventFn<T> InEventFunc)
109 if (!EventRef.bHandled)
111 EventRef.bHandled = InEventFunc(*(T*)&EventRef);
112 LK_CORE_TRACE_TAG(
"EventDispatcher",
"Executing: '{}'", EventRef.GetName());
EEventType
Definition Event.h:16
EEventCategory
Definition Event.h:41