InteractableComponent


public final class InteractableComponent implements Component


Provides access to raw InputEvents for given Entity, so a client can implement their own interaction logic.

Summary

Public methods

static final @NonNull InteractableComponent
create(
    @NonNull Session session,
    @NonNull Consumer<@NonNull InputEvent> inputEventListener
)

Public factory for creating an InteractableComponent.

static final @NonNull InteractableComponent
create(
    @NonNull Session session,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull InputEvent> inputEventListener
)

Public factory for creating an InteractableComponent.

boolean

Attaches this component to the given Entity.

void

Detaches this component from the given Entity.

Public methods

create

Added in 1.0.0-alpha05
public static final @NonNull InteractableComponent create(
    @NonNull Session session,
    @NonNull Consumer<@NonNull InputEvent> inputEventListener
)

Public factory for creating an InteractableComponent. It enables access to raw input events.

Parameters
@NonNull Session session

Session to create the InteractableComponent in.

@NonNull Consumer<@NonNull InputEvent> inputEventListener

Consumer that accepts InputEvents. The listener callbacks will be invoked on the main thread.

create

Added in 1.0.0-alpha05
public static final @NonNull InteractableComponent create(
    @NonNull Session session,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull InputEvent> inputEventListener
)

Public factory for creating an InteractableComponent. It enables access to raw input events.

Parameters
@NonNull Session session

Session to create the InteractableComponent in.

@NonNull Executor executor

Executor for invoking the inputEventListener.

@NonNull Consumer<@NonNull InputEvent> inputEventListener

Consumer that accepts InputEvents.

onAttach

Added in 1.0.0-alpha05
public boolean onAttach(@NonNull Entity entity)

Attaches this component to the given Entity.

Parameters
@NonNull Entity entity

The Entity to attach this component to.

Returns
boolean

true if the component was successfully attached, false otherwise.

onDetach

Added in 1.0.0-alpha05
public void onDetach(@NonNull Entity entity)

Detaches this component from the given Entity.

Parameters
@NonNull Entity entity

The Entity to detach this component from.