InstructionPlayerInstruction └── InstructionModifier ← you are here ├── Instruction_Invert └── Instruction_Rotate

Fields & Properties

MemberTypeDescription
_instructionPlayerInstructionSerialized child. Access via the instruction property.
instructionPlayerInstructionThe wrapped child instruction. Its direction is auto-synced whenever the modifier's direction changes.
ChildrensIReadOnlyList<PlayerInstruction>Single-element list containing instruction. Used by layout components.
resolutionboolForwards the child's resolution value — if the child fails, the modifier also fails.

Events

EventSignatureWhen
OnInstructionModified eventActionFired after ModifyInstruction() runs. Used by the UI to refresh the layout.

Abstract Methods — Must Override

MethodDescription
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

MethodDescription
AddInstruction(PlayerInstruction i)Sets the child and syncs its direction to the modifier's current direction. Called by the UI drag-and-drop.
Validate() overrideReturns 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);
        }
    }
}