Scripting / Instructions
Instruction
Abstract base class for every instruction in the system. Owns direction, loop count, execution context, and the coroutine lifecycle shared by all instruction types.
Serialized Fields
| Field | Type | Range | Description |
|---|---|---|---|
_direction | Direction | Up / Down / Left / Right | The direction this instruction acts in. Access via the direction property. |
_loop | int | 1 – 12 | How many times this instruction repeats. Access via the loop property. |
Properties
| Property | Type | Description |
|---|---|---|
displayName abstract | string | Label shown in the instruction sheet UI. Must be overridden in every subclass. |
direction | Direction | Current direction. Set via SetDirection(). |
loop | int | Current repetition count (1–12). |
context | ExecutionContext | Injected by Run() before Tick() is called. Read only. |
resolution virtual | bool | True by default. Set to false inside Tick() then yield break to stop the runner. |
Events
| Event | Signature | When |
|---|---|---|
OnInstructionStart | Action | Fired at the start of Run(), before Tick(). |
OnInstructionEnd | Action | Fired after Tick() completes. |
Abstract Methods — Must Override
| Method | Returns | Description |
|---|---|---|
Execute() | void | Instant synchronous side-effects before animation — deal damage, spawn a prefab, change state. Called by the runner via animation events. Can be left empty. |
Tick(ExecutionContext ctx) | IEnumerator | The coroutine driving animation and logic. Yield to wait. To fail: set resolution = false then yield break. |
Virtual Methods — Optional Override
| Method | Default | When to override |
|---|---|---|
Validate() | Returns true | Return false to block execution before the turn begins and show an error notification. |
GetExecutionList(int loop) | Yields this once | Override in sequences and modifiers that expand into multiple execution steps. |
SetDirection(Direction d) | Sets this.direction | Override in modifiers to also sync the child instruction's direction. |
Utility Methods
| Method | Description |
|---|---|
IncreaseLoop() | Increments loop count by 1 (max 12). Called from the instruction sheet UI. |
DecreaseLoop() | Decrements loop count by 1 (min 1). Called from the instruction sheet UI. |
SetLoop(int n) | Sets loop count directly. |
Clone() | Returns a deep copy via serialize/deserialize round-trip. Used by the runner before each execution. |
Serialize() | Returns a SerializedInstruction for JSON storage. |