#pragma once #include "../loader/Event.hpp" namespace cocos2d { class CCNode; } namespace geode { template concept InheritsCCNode = std::is_base_of_v; template class EnterLayerEvent : public Event { protected: std::string m_layerID; T* m_layer; public: EnterLayerEvent( std::string const& layerID, T* layer ) : m_layerID(layerID), m_layer(layer) {} std::string getID() const { return m_layerID; } T* getLayer() const { return m_layer; } }; template concept InheritsEnterLayer = std::is_base_of_v, T>; template T> class EnterLayerEventHandler : public EventHandler> { public: using Consumer = void(*)(T*); protected: Consumer m_consumer; std::optional m_targetID; public: PassThrough handle(EnterLayerEvent* event) override { if (m_targetID == event->getID()) { m_consumer(static_cast(event)); } return PassThrough::Propagate; } EnterLayerEventHandler( std::optional const& id, Consumer handler ) : m_targetID(id), m_consumer(handler) {} }; }