AI Command Lab // Flight Simulator
2E: Value vs. Reference
Initial AI Output (Fragile)
// AI-Generated Code (Memory Heavy)
public List<object> scores = new List<object>();
void AddScore(int value) {
scores.Add(value); // ERROR: Boxing occurs here!
}
Initial AI Prompt
"You ask the AI: "Write a list to store a collection of different whole numbers for my score manager.""
Pilot Comm Link
Mission Objective: Use TryGetComponent to safely handle null checks and component retrieval.
Optimized Protocol
// Corrected Code (Type Safe & Fast)
public List<int> scores = new List<int>();
void AddScore(int value) {
scores.Add(value); // Success: Stays in the pocket!
}