Skip to content

InteractableActionSO

Namespace: FireSoftworks.Interaction
Assembly: FireSoftworks.Interaction
Type: Class

Convenient abstract base class for ScriptableObject-based interaction actions with common serialized fields. Automatically implements IInteractableAction by providing Id and Label properties. Subclasses only need to override the Execute method.

This class is designed to be created as a ScriptableObject asset and referenced by an InteractableTarget component through its soActions list. This allows reusable action definitions that can be shared across multiple interactables without needing to attach them as MonoBehaviour components.

Example usage:

public class OpenDoorActionSO : InteractableActionSO { public override void Execute(InteractionContext context) { // Open the door logic here } }

public class InteractableActionSO : ScriptableObject, IInteractableAction

Methods

Execute(InteractionContext)

Override this method to implement the specific action logic. This method is called when the player executes this action.

public virtual void Execute(InteractionContext context)

Parameters

NameTypeDescription
contextFireSoftworks.Interaction.InteractionContextThe interaction context containing information about the interactor and environment.

IsAvailable(InteractionContext)

Determines whether this action is currently available in the given context. Override this method to implement conditional action availability. By default, all actions are available.

public virtual bool IsAvailable(InteractionContext context)

Parameters

NameTypeDescription
contextFireSoftworks.Interaction.InteractionContextThe interaction context containing information about the interactor and environment.

Returns: True if the action can be executed, false otherwise.

Propertys

Icon

Gets the sprite/icon for this action to be displayed in the HUD. Returns null if no icon is assigned, in which case only the label text is displayed.

public Sprite Icon { get; }

Id

Gets the technical identifier for this action.

public string Id { get; }

Label

Gets the human-readable label for this action displayed in the UI.

public string Label { get; }

OnExecuted

Gets the UnityEvent that will be invoked after execution.

public UnityEvent<InteractionContext> OnExecuted { get; }

ShowWhenUnavailable

Determines if this action should be displayed in the UI when unavailable. Override in subclasses if you want to hide this action when it’s not available. By default, unavailable actions are shown (grayed out).

public virtual bool ShowWhenUnavailable { get; }