Instruction → PlayerInstruction
└── InstructionModifier ← you are here
├── Instruction_Invert
└── Instruction_Rotate
Fields & Properties
| Member | Type | Description |
_instruction | PlayerInstruction | Serialized child. Access via the instruction property. |
instruction | PlayerInstruction | The wrapped child instruction. Its direction is auto-synced whenever the modifier's direction changes. |
Childrens | IReadOnlyList<PlayerInstruction> | Single-element list containing instruction. Used by layout components. |
resolution | bool | Forwards the child's resolution value — if the child fails, the modifier also fails. |
Events
| Event | Signature | When |
OnInstructionModified event | Action | Fired after ModifyInstruction() runs. Used by the UI to refresh the layout. |
Abstract Methods — Must Override
| Method | Description |
Execute() | Instant side-effects. Leave empty if the modifier has none. |
ModifyInstruction() | Called automatically after the child instruction executes each loop iteration. Apply the transformation here — change instruction.direction, toggle state, etc. |
Public Methods
| Method | Description |
AddInstruction(PlayerInstruction i) | Sets the child and syncs its direction to the modifier's current direction. Called by the UI drag-and-drop. |
Validate() override | Returns false if no child is assigned. Always validates child before execution. |
Example
namespace LoopAdventure
{
[TypeName("RotateRight")]
public class Instruction_RotateRight : InstructionModifier
{
public override string displayName => "Rotate Right";
public override void Execute() { }
// Called after the child executes each loop.
public override void ModifyInstruction()
{
Direction next = (Direction)(((int)instruction.direction + 1) % 4);
instruction.SetDirection(next);
}
}
}