Tier 4 Series 302

302A: The Command Link

Pilot Record
Student Profile
"Directly wiring a cockpit button to a missile launcher creates a rigid system. You can't undo the shot, replay it, or rebind the button easily. A Navigator wraps actions in "Commands" to decouple the input from the execution."

The Concept: The Command Pattern

The **Command Pattern** turns a request (like "Jump" or "Fire") into an object.

* **ICommand:** An interface with an `Execute()` method.
* **Queueable:** Commands can be stored in a list to create an "Undo" history.
* **Rebindable:** You can swap which Command is inside the "A Button" object at runtime.
Red Flag Detected

The AI Trap: "The Hardwired Input"

You ask the AI: "Fire the weapon when I press Space."

// AI-Generated Code: Rigid & Brittle
void Update() {
    // Audit Fail: Input is welded to the logic.
    // Cannot be undone, replayed, or AI-controlled easily.
    if (Input.GetKeyDown(KeyCode.Space)) {
        FireWeapon();
    }
}

This is "Input Locking." If you want to add controller support or an AI pilot later, you have to rewrite the weapon script.

Elite Telemetry

Research shows "Elite" teams achieve 15% faster lead times by keeping AI on a "very tight leash."

  • Small Batches Solving one problem at a time prevents logic drift.
  • Modular Design Localizing the "blast radius" of AI changes.
  • Tight Loops Rapid iteration with constant code review.

The Navigator's Correction

Corrective Protocol
// Corrected: Decoupled & Flexible
public interface ICommand { void Execute(); }

public class FireCommand : ICommand {
    private Weapon _weapon;
    public FireCommand(Weapon w) { _weapon = w; }
    public void Execute() { _weapon.Fire(); }
}
// The InputHandler just calls currentCommand.Execute()
Your Pilot Command
> A skilled Navigator directs the AI to use Commands.
Next Mission
The Strategy Switch