Skip to content

Conditions

Conditions answer one question: should this happen? Stack multiple conditions to build complex rules without code.

For example, an attachment point might require all three of these to pass before accepting an object:

  • Is the slot available?
  • Does the object have the right tag?
  • Is the system in the correct phase?

If any single condition fails, the action is blocked. You add, remove, and reorder conditions in the Inspector - no scripting needed.

Invert toggle

Every condition has an invert toggle: the small ¬ button on its type row. Turn it on and the condition flips its logic - "is within 5 meters" becomes "is farther than 5 meters." The row then reads "NOT ..." so you can spot inverted conditions without expanding them. You only need the positive version; the inverse comes for free.


How Conditions Stack

When multiple conditions are applied to a single gate, they use AND logic: all conditions must pass for the gate to open. If any single condition evaluates to false, the action is blocked.

Condition A: Distance < 5m     ✓
Condition B: Is Carrying Item  ✓
Condition C: Zone Not Full     ✗
─────────────────────────────────
Result: BLOCKED (C failed)

This stacking model is simple and predictable. For OR logic, create a composite condition that internally evaluates multiple sub-conditions.


Built-in Conditions

Duration-Based

Condition Stops When
DurationExecutionCondition A specified number of seconds have elapsed since OnStarted()
ExecuteOnceExecutionCondition Immediately after the first evaluation
NeverStopExecutionCondition Never — always returns true

Distance-Based

Condition Stops When
DistanceBetweenCondition Point A comes within a distance of point B, optionally for a hold time. It reads both points itself, so it works in any condition slot

Event-Based

Condition Stops When
EventFiredExecutionCondition A specified IEvent fires
WhileConditionMetExecutionCondition An external condition stops being met

Technical API

ExecutionCondition

The base class for conditions in Jungle:

public abstract class ExecutionCondition
{
    void OnStarted();
    void OnPaused();
    void OnResumed();
    bool ShouldContinue();
    protected abstract bool Evaluate();
    void Reset();
}
Method Purpose
Evaluate() The core logic - override this to return true (continue) or false (stop)
ShouldContinue() Public entry point that respects the invert toggle, then calls Evaluate()
OnStarted() Called once when the host system begins execution - initialize state here
OnPaused() / OnResumed() Called when the host pauses and resumes; time-based conditions freeze their clock here
Reset() Resets internal state for reuse

Where Conditions Are Used

Conditions appear throughout Jungle and its plugins:

Process Gating

Conditions can gate whether a process begins or continues. Commands check conditions in their OnBegin() override, and hosts like ProcessComponent and a Reactor reaction can require conditions to pass before their process starts. See Processes & Commands for details.

Octoputs: Attachment Filtering

In Octoputs, attachment points use conditions to decide whether they accept an incoming object. The conditions list on an attachment point might include:

  • A capacity check — is the slot available?
  • A tag filter — does the object have the right tag?
  • A state check — is the system in the right phase?

All must pass for the attachment to proceed.

Octoputs: Phase Gating

Drag and drop phases (prepare, drag, drop) can be gated with conditions. For example, a drop preparation phase might require the object to be within a certain distance of the target before it begins.


How They Appear in the Inspector

Conditions are serialized with [SerializeReference] and [JungleClassSelection], so they render as TypeSelectableFields. When used in a list, they render as a JungleList with add/remove and drag reorder.

Inspector
Attachable Object? ⇅ ⋮
Attaching
Attached
Detaching
Attach Conditions2+
Attach Condition 1Attachment Point Holding1¬2
Holding ZoneSlot (Attachment Point)3
Attach Condition 2Random Condition
Probability0.5
Two attach conditions. Both must pass: the slot is free (Holding, inverted) and a coin flip comes up.
  1. The condition type. Click to change it.
  2. The invert toggle, pinned on here.
  3. The condition's own settings.

Each condition entry shows:

  1. The condition type name (clickable to change)
  2. The ¬ invert toggle, revealed on hover and pinned while on
  3. The condition's configuration fields (expanded via foldout)

Creating Custom Conditions

Extend ExecutionCondition and implement Evaluate():

[Serializable]
[JungleClassInfo("Stops after a health threshold is reached", "Icons/health", "Gameplay")]
public class HealthThresholdCondition : ExecutionCondition
{
    [SerializeField] private float threshold = 0.5f;

    [SerializeReference] [JungleClassSelection]
    private IValue<float> health;

    protected override bool Evaluate()
    {
        return health.Value() > threshold;
    }
}

The condition will appear in the class selection popup under the "Gameplay" category and can be assigned to any condition field on a process, command, or Octoputs component.