Interactable

Sealed MonoBehaviour component placed on GameObjects that can receive interactions. Manages an InteractionTable containing the available interactions, and integrates with the Outline system for visual highlight feedback.

Definition

Namespace: Paragon.Townskeep.InteractionSystem Assembly: Townskeep.dll

[RequireComponent(typeof(Outline)), HideMonoScript]
public sealed class Interactable : ParagonBehaviour

Inheritance: MonoBehaviour → ParagonBehaviour → Interactable

Remarks

Interactable is a sealed class — it cannot be subclassed. Custom interaction behavior is defined by creating Interaction subclasses and configuring them in the InteractionTable via the Inspector.

The component automatically requires an Outline component for hover/selection highlighting. The outline is controlled via SetHighlight(bool).

circle-info

The InteractionTable is serialized via Odin ([OdinSerialize]), allowing polymorphic serialization of Interaction, InteractionTrigger, and InteractionCondition instances within the table.

Quick Lookup

Goal
How

Check if available

interactable.CanInteractWith(interactor)

Get available interactions

interactable.GetAvailableInteractionsInContext(interactor)

Check if busy

interactable.IsBusy

Highlight on hover

interactable.SetHighlight(true)

Swap interaction table at runtime

interactable.SetInteractionTable(newTable)

Properties

IsBusy

Returns true if an interaction is currently active on this interactable.

IsHighlighted

Returns true if the outline highlight is currently enabled.

Methods

CanInteractWith

Checks whether the interactable is enabled, not busy, and has at least one interaction available for the given interactor.

Parameter
Type
Description

interactor

Interactor

The entity attempting to interact

Returns: true if the interactable is enabled, not busy, and has available interactions.

GetAvailableInteractionsInContext

Returns all InteractionContext entries whose conditions pass for the given interactor.

Parameter
Type
Description

interactor

Interactor

The entity to evaluate conditions against

Returns: Enumerable of matching InteractionContext entries.

SetHighlight

Enables or disables the outline highlight effect.

Parameter
Type
Description

value

bool

true to enable, false to disable

SetInteractionTable

Replaces the interaction table at runtime and initializes the new table.

Parameter
Type
Description

interactionTable

InteractionTable

The new table to use

GetInteractionTable

Returns the current interaction table.

Returns: The current InteractionTable instance.

OnInteractionBegin

Called by the Interaction lifecycle when an interaction starts. Sets this interactable as busy.

OnInteractionEnd

Called by the Interaction lifecycle when an interaction ends. Clears the busy state.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated