Scripting / Interactables
IInteractable
Marks a world object as interactable. The Instruction_Interact searches for this interface on the player's current tile and calls Interact() if Validate() returns true. Objects with automatic = true are triggered automatically at the end of any turn the player lands on their tile. See Built-in Instructions for a list of all player actions.
Properties
| Property | Type | Description |
|---|---|---|
automatic | bool | If 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. |
OnInteract | UnityEvent | Raised every time this object is successfully interacted with. Declare with [field: SerializeField] to expose it in the Inspector. |
Methods
| Method | Returns | Description |
|---|---|---|
Validate() | bool | Called before Interact(). Return true if interaction is currently legal. Return false to block — call NotificationCenter.Notify() before returning to give the player feedback. |
Interact() | void | Executes 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:
| Class | Description |
|---|---|
InteractableObject_Pickup | Automatically collected when the player steps on it. Adds a configurable Item to inventory and destroys itself. |
InteractableObject_Chest | Requires an explicit Interact instruction. Gives a configurable item and quantity, plays an open animation, and shows the item icon above the chest. |