Component.h
79 #define DynacoeEvent(_Name_) bool _Name_(void * functionData, Dynacoe::Component * component, Dynacoe::Entity::ID self, Dynacoe::Entity::ID source, const std::vector<std::string> & args)
132 using EventHandler = bool (*)(void *, Component * component, Entity::ID self, Entity::ID source, const std::vector<std::string> & args);
145 bool EmitEvent(const std::string & eventName, Entity::ID source = Entity::ID(), const std::vector<std::string> & args = {});
205 void InstallEvent(const std::string & eventName, EventHandler mainHandler = nullptr, void * data = nullptr);
bool CanHandleEvent(const std::string &eventName)
Returns whether there exists at least one handler for the given event.
void InstallHook(const std::string &eventName, EventHandler, void *data=nullptr)
Adds a hook to the event.
virtual void OnAttach()
Function that is called upon a host entity's Attach() function calling. It is run right after the hos...
Definition: Component.h:198
bool EmitEvent(const std::string &eventName, Entity::ID source=Entity::ID(), const std::vector< std::string > &args={})
Triggers the specified event for this EventSystem.
bool(*)(void *, Component *component, Entity::ID self, Entity::ID source, const std::vector< std::string > &args) EventHandler
A handler for an event.
Definition: Component.h:132
T * GetHostAs() const
Convenience function. Equivalent to dynamic_cast(GetHost())
Definition: Component.h:105
void UninstallHook(const std::string &eventName, EventHandler)
Removes a hook added with InstallHook()
void UninstallEvent(const std::string &)
removes a handler of an event
void InstallEvent(const std::string &eventName, EventHandler mainHandler=nullptr, void *data=nullptr)
void InstallHandler(const std::string &eventName, EventHandler, void *data=nullptr)
virtual std::string GetInfo()
Returns a string containing human-readable information on the state of the component.
Definition: Component.h:114
Definition: AssetID.h:37
Entity::ID GetHostID() const
Returns a ID of the host.
Definition: Component.h:109
std::vector< std::string > GetKnownEvents() const
virtual void OnStep()
Function that is called upon each Run iteration. Component Run()s are run before the entity's run fun...
Definition: Component.h:187
std::string GetTag()
Returns a string identifier belonging to the component. Each component implementation should have a u...
Definition: Component.h:95
virtual void OnDraw()
Function that is called upon each Draw iteration. Component Draw()s are run before the entity's draw ...
Definition: Component.h:193
void UninstallHandler(const std::string &eventName, EventHandler)
Removes a handler added with InstallHandler()
Class that extends the functionality of an Entity, but as a removable and addable object...
Definition: Component.h:66
Entity * GetHost() const
Returns the set host of the component. If no host is set, nullptr is returned.
Definition: Component.h:100