Properties

PropertyTypeDescription
automaticboolIf true, the object is collected at turn end without requiring an Interact instruction. Use for floor pickups. If false, the player must use Interact explicitly.
OnInteractUnityEventRaised every time this object is successfully interacted with. Declare with [field: SerializeField] to expose it in the Inspector.

Methods

MethodReturnsDescription
Validate()boolCalled before Interact(). Return true if interaction is currently legal. Return false to block — call NotificationCenter.Notify() before returning to give the player feedback.
Interact()voidExecutes the interaction behaviour. Add inventory items, play animations, fire events, or destroy the object here.

Example

public class InteractableObject_Chest : ExecutionContextElement, IInteractable
{
    [SerializeField] Item item;
    [field: SerializeField] public UnityEvent OnInteract { get; set; }

    public bool automatic => false;

    public bool Validate() => item != null;

    public void Interact()
    {
        context.inventory.Add(item);
        OnInteract?.Invoke();
    }
}

Built-in Implementations

Ready-made classes that implement IInteractable:

ClassDescription
InteractableObject_PickupAutomatically collected when the player steps on it. Adds a configurable Item to inventory and destroys itself.
InteractableObject_ChestRequires an explicit Interact instruction. Gives a configurable item and quantity, plays an open animation, and shows the item icon above the chest.
ℹ️