Program Listing for File EventSubscriber.hpp¶
↰ Return to documentation for file (include/ari/en/EventSubscriber.hpp
)
#pragma once
#include "../aridef.hpp"
#include <memory>
namespace ari
{
class World;
class Entity;
class Component;
class FrameData;
namespace Internal
{
class ARI_API BaseEventSubscriber
{
public:
virtual ~BaseEventSubscriber() = default;
};
} // Internal
template<typename T>
class ARI_API EventSubscriber: public Internal::BaseEventSubscriber
{
public:
virtual ~EventSubscriber() = default;
virtual void Receive(World* world, const T& event) = 0;
}; // EventSubscriber
namespace events
{
// Called when a new entity is created.
struct OnEntityCreated
{
ARI_DECLARE_TYPE;
Entity* entity;
};
// Called when an entity is about to be destroyed.
struct OnEntityDestroyed
{
ARI_DECLARE_TYPE;
Entity* entity;
};
// Called when a component is assigned (not necessarily created).
template <class T>
struct OnComponentAssigned
{
ARI_DECLARE_TYPE;
Entity* entity;
T* component;
};
// Called when a component is removed
template <class T>
struct OnComponentRemoved
{
ARI_DECLARE_TYPE;
Entity* entity;
T* component;
};
struct OnFrameData
{
ARI_DECLARE_TYPE;
FrameData* frame_data;
};
} // events
} // ari