Overview
| Class | Behaviour |
Tile_Interactable_PressurePlate | Detects when the player or any obstacle stands on its tile and fires OnActivated / OnDeactivated events. Useful for triggering doors, bridges, or any reaction that depends on occupation state. |
Tile_Interactable_AppearingSpikes | Cycles through a configurable array of stages each turn. On spike stages it deals lethal damage to any entity with a Health component on the tile. |
ℹ️
Automatic registration
Any ExecutionContextElement that also implements ITaskReceiver is discovered and registered automatically during initialization. You do not need to register trap objects manually.
Tile_Interactable_PressurePlate
Checks its tile once per turn — at the halfway point of the turn interval — and transitions between pressed and released states based on whether the player or an IObstacle is present.
Inspector Fields
| Field | Type | Description |
OnActivated | UnityEvent | Fired the turn the plate transitions from released to pressed. Wire this to doors, bridges, or any reaction object. |
OnDeactivated | UnityEvent | Fired the turn the plate transitions from pressed to released. |
Properties
| Property | Type | Description |
currentInstruction | Instruction | The instruction currently being executed. Exposed so HUD indicators can display the trap's active action. |
ITaskReceiver Events
| Event | Signature | Description |
OnStart | Action<EnemyAction> | Raised when the trap's task begins executing for this turn. |
OnActionChange | Action<EnemyAction> | Raised when transitioning between internal execution stages. |
OnEnd | Action | Raised when the trap's task finishes for this turn. |
OnExecute | Action<ExecutionContext> | Raised each time an execution step runs, providing the current context. |
Methods
| Method | Returns | Description |
GetTask() | Task | Returns the Task the runner should execute this turn. Called automatically by InstructionRunner. |
Initialize( ExecutionContext context, ExecutionContextElement parent) | void | Called during level initialization. Caches the Animator and sets up the internal CustomInstruction. |
💡
Detection logic
The plate uses Physics2D.OverlapBoxAll at the halfway point of the turn interval (context.turnInterval × 0.5f). It detects any collider that has either an IObstacle component or a PlayerController component. Pushable objects and carried crates count as obstacles.
Tile_Interactable_AppearingSpikes
Cycles through a configurable stages array each turn. A true entry means spikes are extended and deal lethal damage; false means they are retracted and safe to walk on. The stage advances automatically at the end of each turn.
Inspector Fields
| Field | Type | Description |
stages | bool[] | Ordered list of spike states. Default is [false, true] — safe on turn 1, lethal on turn 2, repeating. Add more entries to create longer patterns (e.g. [false, false, true] for safe-safe-lethal). |
Properties
| Property | Type | Description |
currentInstruction | Instruction | The instruction currently being executed. Exposed for HUD display. |
ITaskReceiver Events
| Event | Signature | Description |
OnStart | Action<EnemyAction> | Raised when the trap's task begins executing for this turn. |
OnActionChange | Action<EnemyAction> | Raised when transitioning between internal execution stages. |
OnEnd | Action | Raised when the trap's task finishes for this turn. |
OnExecute | Action<ExecutionContext> | Raised each time an execution step runs, providing the current context. |
Methods
| Method | Returns | Description |
GetTask() | Task | Returns the Task the runner should execute this turn. |
Initialize( ExecutionContext context, ExecutionContextElement parent) | void | Called during level initialization. Caches the Animator and sets up the internal CustomInstruction. |
💡
Damage model
When a spike stage is active, the trap calls Health.Kill() on every object with a Health component found by Physics2D.OverlapBoxAll on its tile. The check runs mid-turn so the spikes animate before the kill is applied. Entities that move off the tile before the check survives.
Animator Parameters
| Class | Parameter | Type | Description |
Tile_Interactable_PressurePlate | Activated | bool | true while the plate is pressed down. |
Tile_Interactable_AppearingSpikes | Appeared | bool | true while the spikes are extended. |