AI Command Lab // Flight Simulator
302F: The Event Bus
Initial AI Output (Fragile)
// AI-Generated Code: Spaghetti References
public class Enemy : MonoBehaviour {
public UIManager ui; // Dependency
public AudioManager aud; // Dependency
public VFXManager vfx; // Dependency
void Die() {
ui.UpdateScore();
aud.PlayBoom();
vfx.SpawnFire();
}
}
Initial AI Prompt
"You ask the AI: "Update the UI, play a sound, and spawn particles when the enemy dies.""
Pilot Comm Link
Mission Objective: A skilled Navigator directs the AI to use an Event Bus.
Optimized Protocol
// Corrected: Fire and Forget
void Die() {
// The Enemy just shouts into the void.
EventBus.Publish(new EnemyDeathEvent(this.scoreValue));
}
// The UI listens elsewhere: EventBus.Subscribe<EnemyDeathEvent>(OnScore);