Scripting / Instructions
ExecutionContext
Passed as ctx to every Tick() call. Provides read access to all live scene state for the current run — player, inventory, turn settings, and events.
Read only at call time
Do not store
ctx across frames or between instructions. It is valid only during the coroutine it was passed to.
Player
| Member | Type | Description |
|---|---|---|
ctx.player | PlayerController | The player character instance for this run. |
ctx.player.position | Vector2 | Current world position. Assign directly to move the player instantly (no animation). |
ctx.player.SetDirection(Direction) | void | Flips the player sprite to face a direction. |
ctx.player.PlayAnimation(string) | void | Plays a named Animator state on the player. |
ctx.player.ValidatePosition(Vector3) | bool | Returns true if the position is on a valid PathTile with no obstacle. Always check before moving. |
ctx.player.PlaySound(AudioResource) | void | Plays a sound through the player's AudioSource. Stops any currently playing clip first. |
ctx.player.UseItem(Item) | void | Consumes an item, applies its effects, and shows the use VFX. |
Player Stats
| Member | Type | Description |
|---|---|---|
ctx.player.stamina | PlayerStamina | Access .currentValue to check available stamina. Call .Substract(n) to spend it. |
ctx.player.health | Health | Check .isDead. Call .ApplyDamage(n) to deal damage. |
ctx.player.damage | int | Player's current damage value (derived from equipped weapon stat). |
ctx.player.defense | int | Player's current defense value (derived from equipped armor stat). |
State
| Member | Type | Description |
|---|---|---|
ctx.carryingObject | bool | True if the player is currently carrying an ICarryObject. Many instructions are blocked while carrying. |
ctx.inventory | PlayerInventory | The inventory snapshot for this run. Read items and equipment slots. |
ctx.currentPlayerInstruction | PlayerInstruction | The instruction currently executing (set to this by the runner). |
Events
| Member | Type | Description |
|---|---|---|
ctx.OnTurnStart | Action | Fired at the beginning of each turn within this run. |
ctx.OnTurnEnd | Action | Fired at the end of each turn. Subscribe here to collect items or tick effects. |
Need to react to each instruction step from an enemy or interactable? See IExecutionSuscriber — a lightweight notification interface that is auto-registered from the enemy's hierarchy.