CustomInstruction

Extends Instruction directly. Instead of overriding Tick() in a subclass, you assign a coroutine delegate to tick. The runner treats it identically to any other instruction.

Properties

PropertyTypeDescription
displayNamestringLabel shown by the instruction pointer HUD. Defaults to an empty string — set it when you want the UI to identify this instruction.

Delegates

MemberTypeDescription
executeevent ActionInvoked by Execute() before Tick() runs. Subscribe to perform any non-coroutine setup or side-effects when the instruction starts.
tickFunc<ExecutionContext,
  IEnumerator>
The coroutine that drives the instruction's behaviour. Receives the current ExecutionContext and must yield at least once. If null, the instruction yields once and returns immediately.

Methods

MethodDescription
Execute()Invokes the execute event. Called by the runner before Tick().
Tick(ExecutionContext context)
override
Delegates to the tick function. If tick is null, yields once and returns.

Usage

Create a CustomInstruction, assign its coroutine to tick, and optionally subscribe to execute for any synchronous setup that should run before the coroutine starts.

IEnumerator HealRoutine(ExecutionContext context)
{
    context.inventory.TryUseItem(healthPotion);
    context.player.UseItem(healthPotion);
    yield return new WaitForSeconds(0.3f);
}

var instruction = new CustomInstruction();
instruction.displayName = "Heal";
instruction.tick    = (ctx) => HealRoutine(ctx);
instruction.execute += () => Debug.Log("Heal started");
💡
CustomInstruction vs subclass Use CustomInstruction for transient, runtime-generated behaviour — scripted events, tutorial prompts, or instructions assembled from data. For reusable player actions that appear in the palette, extend PlayerInstruction instead.