Condition

Condition subsystem for the Interaction System. Provides an abstract base class for defining boolean conditions that gate whether an interaction is available to a given interactor/interactable pair. Conditions are evaluated by InteractionContext before allowing an interaction to execute.

Architecture

spinner

Data Flow

spinner

Key Concepts

Concept
Description

InteractionCondition

Abstract base class. Subclass and implement OnEvaluate() to define a boolean gate.

Negate flag

Inspector-configurable toggle that inverts the condition result. Allows reuse of conditions for both "require X" and "require NOT X" scenarios.

InteractionContext

Owns a list of conditions and evaluates all of them via LINQ.All() before allowing execution.

Quick Start

1. Create a custom condition

using Paragon.Townskeep.InteractionSystem;

[Serializable]
public class HasItemCondition : InteractionCondition
{
    [SerializeField]
    private ItemData requiredItem;

    protected override bool OnEvaluate(Interactable interactable, Interactor interactor)
    {
        var inventory = interactor.GetComponent<Inventory>();
        return inventory != null && inventory.HasItem(requiredItem);
    }
}

2. Add to InteractionContext in Inspector

Conditions are serialized on the InteractionContext. Add your condition to the conditions list and optionally toggle the negate flag to invert the logic.

Classes

Class
Description

Abstract base class for interaction availability conditions

See Also

Last updated