IEntityEvents¶
-
namespace
marengine -
template<typename
TEntityEventImpl>
classIEntityEvents¶ - #include “Core/ecs/Entity/IEntityEvents.h”
Base class for all Entity Events. It is based on CRTP - Curiously recurring template pattern. You can use derived classes with Derived::onCreateEntity() call. It is that simple. How to use it? class Derived : IEntityEvents<Derived> and then implement all methods to override them.
- Template Parameters
TEntityEventImpl:
Public Static Functions
-
void
onCreateEntity()¶ Overloaded methods should call create Entity function on Scene and invoke other needed events.
-
void
onDestroyEntity(const Entity &entity)¶ Overloaded methods should call destroy Entity function on Scene and invoke other needed events. Imagine situation, when user wants delete some light and renderable from scene, which are assigned to specific entity. Then he can just destroy it.
- Parameters
entity: entity, that will be destroyed
-
void
onSelectedEntity(const Entity &entity)¶ Overloaded methods should invoke all events when entity is selected. Imagine situation, when user wants to pick some entity from scene, then this event can be called.
- Parameters
entity: entity, which is selected by user, game etc.
-
void
onUnselectedEntity(const Entity &entity)¶ Overloaded methods should invoke all events when entity is unselected. Image situation, when user has a choice, selects some entity and then decides to change selected entity. On entity, which is unselected can be called this event.
- Parameters
entity: entity, which is already unselected
-
void
onCopyEntity(const Entity &entity)¶ Overloaded methods should call copy Entity function on Scene and invoke other needed events. There are some situation, when entity can be copied, there is possibility to create duplicates by this event.
- Parameters
entity: entity, that will be copied to newly created entity instance
-
void
onSetVisibleEntity(const Entity &entity)¶ Overloaded methods should call set visible Entity function on Scene and invoke other needed events. When Entity has CRenderable and some material, then it can be rendered. By calling this function we can be sure that entity will be visible.
- Parameters
entity: entity, which we want to see during runtime.
-
void
onSetInvisibleEntity(const Entity &entity)¶ Overloaded methods should call set invisible Entity function on Scene and invoke other needed events. When Entity is already visible and we want it to disappear, then we can call this event. Its job is to be sure, that entity won’t be visible anymore.
- Parameters
entity: entity, which we want to not be visible during runtime.
-
void
onAssignChild(const Entity &entity, const Entity &child)¶ Overloaded methods should call assign child to entity Entity function and invoke other needed events. When we want some entities to be relative to other, we need to make parents and children. When a child is created, we should use this method.
- Parameters
entity: entity, to which given child will be assignedchild: child, which will be assigned to given entity
-
void
onRemoveChild(const Entity &entity, const Entity &child)¶ Overloaded methods should call remove child from entity Entity function and invoke other needed events. There can be situation, when child is assigned to some entity and everything is fine. But sometimes we want to remove child from entity, for instance assign to other entity. Then we can call this event.
- Parameters
entity: entity, from which given child will be takenchild: child, which will be taken from given entity
-
void
onCreateChild(const Entity &entity)¶ Overloaded methods should call create child Entity function when child is created. Then automatically child is assigned to given entity.
- Parameters
entity: entity, to which will be newly created child assigned.
-
void
onDestroyChild(const Entity &entity, const Entity &child)¶ Overloaded methods should call destroy child Entity function when child is destroyed. Then automatically child is removed from given entity.
- Parameters
entity: entity, from which will be child removedchild: child, that will be firstly removed from given entity, then destroyed
-
template<typename