ExecutionStatus

Enum representing the runner's current state.

ValueDescription
UninitializedThe runner has not been started yet.
StoppedExecution was stopped manually via Stop().
RunningInstructions are actively executing.
ObservingRunning in observe mode (no validation, infinite loop).
FinishedAll instructions completed — either success or failure.
FailExecution ended due to a validation failure or player death.
SuccessAll level goals were met and the player reached the end tile.

Properties

PropertyTypeDescription
statusExecutionStatusThe runner's current execution state.
contextExecutionContextThe active ExecutionContext for the current run. null when status is Stopped or Uninitialized.

Methods

MethodDescription
Play()Starts a full execution run. Calls each instruction's Validate() before execution and checks level goals at the end. Fires OnStartExecution.
Observe()Starts execution in observe mode — instructions run in an infinite loop without validation or goal checking. Used to let designers preview behaviour. Fires OnStartExecution.
Stop()Halts any running coroutine, resets Time.timeScale to 1, stops all scheduled tasks, and fires OnStopExecution.
Reset()Calls context.Reset() to restore cloned game objects to their pre-run state, then fires OnReset.

Events

EventSignatureDescription
OnTurnStartActionRaised at the beginning of each turn cycle, before any instruction executes.
OnTurnEndActionRaised at the end of each turn cycle, after all tasks complete.
OnAnyTurnEndstatic ActionStatic version of OnTurnEnd — fired by every runner instance. Useful for systems that need to react to any turn ending regardless of which runner is active.
OnResetActionRaised after Reset() restores the scene to its pre-run state.
OnStartExecutionAction<ExecutionContext>Raised when Play() or Observe() is called. The context passed is the one for this run.
OnStopExecutionAction<ExecutionContext>Raised when Stop() is called manually. Not fired when the run ends naturally.
OnFinishExecutionAction<ExecutionContext>Raised when the run ends — either with success or failure. Always fired after OnSucceedExecution or OnFailedExecution.
OnFailedExecutionAction<ExecutionContext>Raised when an instruction signals failure (resolution = false) or the player dies mid-run.
OnSucceedExecutionAction<ExecutionContext>Raised when all instructions complete without failure and all level goals are satisfied.

Turn Cycle

Each turn follows this sequence:

  1. OnTurnStart fires.
  2. All ITaskReceiver tasks in the context (enemies, interactables) are started in parallel via TaskSchedule.
  3. The current instruction's Execute() is called, then Tick() runs as a coroutine.
  4. The runner waits until both the instruction's coroutine and all parallel tasks finish.
  5. OnTurnEnd and OnAnyTurnEnd fire.
  6. Player health and position are validated. If invalid, Fail() is called.
  7. Execution advances to the next instruction. When all instructions are exhausted, goals are evaluated.

InstructionRunner.TaskSchedule

Inner helper class created at the start of each run. It collects all ITaskReceiver objects from context.taskSchedulers (enemies, traps, interactables) and starts their tasks in parallel at the beginning of each turn. The runner waits for TaskSchedule.running to become false before advancing to the next turn.