-
Notifications
You must be signed in to change notification settings - Fork 20
Lifecycle Listener Plugin
Daan van Yperen edited this page May 31, 2019
·
2 revisions
In artemis-odb-contrib 2.5.0-SNAPSHOT, release planned for artemis-odb 2.3.0. Desktop only.
Allows you to hook into odb's lifecycle for extending your internal tooling (debuggers/editors).
enum LifecycleListener.Type {
/** Triggered when the entity is scheduled for deletion */
ENTITY_DELETE_PLANNED,
/** Triggered when the entity is actually deleted. */
ENTITY_DELETE_FINALIZED,
/** Triggered just after entity is created. */
ENTITY_CREATE_POST,
/** Triggered just before entity is fetched. */
ENTITY_GET_PRE,
/** Triggers just before entity component identity is checked.*/
ENTITY_IDENTITY_PRE,
/** Triggers just before entity components are fetched. */
ENTITY_COMPONENTS_PRE,
/** Triggersat the start of entity edit() function call. */
ENTITY_EDIT_PRE,
/** Triggers just before entity is checked for activity. */
ENTITY_ISACTIVE_CHECK_PRE,
/** Triggers just before component gets fetched. {@code OptionalArg=ComponentType}. */
COMPONENT_GET_PRE,
/** Triggers just before component check. {@code OptionalArg=ComponentType}. */
COMPONENT_HAS_PRE,
/** Triggers just before attempted component removal. {@code OptionalArg=ComponentType}. */
COMPONENT_REMOVE_PRE,
/** Triggers just before attempted component removal (called by odb internally.) {@code OptionalArg=ComponentType}. */
COMPONENT_INTERNAL_REMOVE_PRE,
/** Triggers just before attempted component creation. {@code OptionalArg=ComponentType}. */
COMPONENT_CREATE_PRE,
/** Triggers just before component is created. (called by odb internally.). {@code OptionalArg=ComponentType} */
COMPONENT_INTERNAL_CREATE_PRE,
/** Triggers at the start of componentmanager clean call.*/
COMPONENTMANAGER_CLEAN_PRE,
/** Triggers at the end of componentmanager clean call. */
COMPONENTMANAGER_CLEAN_POST
}
This plugin has a performance impact.
Does not support worlds with customized ComponentMapper
, EntityManager
, SubscriptionManager
, BatchChangeProcessor
. (If you are not sure you probably don't have these customized).
<parent>
<groupId>net.mostlyoriginal.artemis-odb</groupId>
<artifactId>contrib-plugin-lifecycle-listener</artifactId>
<version>2.5.0-SNAPSHOT</version>
</parent>
// register the plugin on your world configuration builder.
worldConfigurationBuilder.dependsOn(LifecycleListenerPlugin.class);
// systems implementing LifecycleListener get events.
class MyEditorListenerSystem extends BaseSystem implements LifecycleListener {
void onLifecycleEvent(Type event, int entityId, Object optionalArg) {
switch(event) {
// do something.
}
}
}