Skip to content

IInteractor

Namespace: FireSoftworks.Interaction
Type: Interface
Assembly: FireSofworks.InteractionSystem

Interface defining the core functionality of an interactor. Interactors are responsible for detecting interactable targets and managing the selection and execution of actions on those targets.

public interface IInteractor

Properties

isInteractionAvailable

bool isInteractionAvailable { get; }

Indicates whether there is a currently focused interactable target. Returns true when currentTarget != null.


isValidInteractionSelected

bool isValidInteractionSelected { get; }

Indicates whether there is a valid selected action that can be executed. Returns true when a target is focused and a valid action index is selected.


SelectedAction

IInteractableAction SelectedAction { get; }

Gets the currently selected action, or null if none is selected.


Methods

IsInteracting()

bool IsInteracting()

Returns true if the interactor is currently in interaction mode or has a valid target and selected action.


HandleInteraction()

void HandleInteraction()

Main entry point for input code. Depending on the interactToShowActions setting: either enters “show actions” mode on first press, or executes the currently selected action.

Typical usage:

void Update()
{
if (Input.GetKeyDown(KeyCode.E))
interactor.HandleInteraction();
}

ShowInteractions()

void ShowInteractions()

Enters interaction mode explicitly and fires ShowActionsDiscovered. Use when you want to separate “open the action menu” from “execute an action”.


ExecuteInteraction()

void ExecuteInteraction()

Executes the currently selected action. Does nothing if no valid action is selected. Fires ActionExecuted on success and calls EndInteraction().


SelectNextAction()

IInteractableAction SelectNextAction()

Cycles forward through available actions. Skips unavailable ones. Returns the newly selected action, or null if none is available.


SelectPreviousAction()

IInteractableAction SelectPreviousAction()

Cycles backward through available actions. Returns the newly selected action, or null.


SelectAction(int)

IInteractableAction SelectAction(int actionIndex)

Selects a specific action by index. Fires ActionSelectionChanged.

ParameterTypeDescription
actionIndexintIndex into the current visible actions list.

EndInteraction()

void EndInteraction()

Cancels the current interaction, clears the target, and fires InteractionEnded.


GetVisibleActions()

List<IInteractableAction> GetVisibleActions()

Returns the list of actions that should be visible in the UI, respecting the ShowWhenUnavailable flag on each action. Used by HUD components to populate the action menu.


Events

EventArgs typeFires when
ActionsDiscoveredActionsDiscoveredEventArgsA new target is focused and actions are built
ShowActionsDiscoveredActionsDiscoveredEventArgsThe action menu should be displayed
ActionSelectionChangedActionSelectionChangedEventArgsThe selected action index changes
ActionExecutedActionExecutedEventArgsAn action completes execution
InteractionStartedInteractionLifecycleEventArgsA target is first focused
InteractionEndedInteractionLifecycleEventArgsFocus is lost

See the Event System guide for subscription examples.