AI Command Lab // Flight Simulator
6F: The Interface Bridge
Initial AI Output (Fragile)
// AI-Generated Code: Rigid and Brittle
if (other.GetComponent<Crate>()) {
other.GetComponent<Crate>().Break();
}
else if (other.GetComponent<Enemy>()) {
other.GetComponent<Enemy>().Hurt();
}
// Audit Fail: Every new object requires new code here!
Initial AI Prompt
"You ask the AI: "Make a system where the player can damage Crates, Barrels, and Enemies.""
Pilot Comm Link
Mission Objective: A skilled Mechanic directs the AI to use an Interface. You command: "Use an IDamageable interface so the projectile works on anything."
Optimized Protocol
// Corrected: Universal Socket
IDamageable target = other.GetComponent<IDamageable>();
if (target != null) {
target.TakeDamage(10);
}