Visual Audit Protocol

The Collection Agency

Return to Hangar
5A

The Array Anchor

The Concept: The Fixed Array

OPTIMIZED
Contiguous Memory
// Corrected: Performance-locked and clean. [SerializeField] private Transform[] thrusters = new Transform[4]; void Update() { // The computer treats this as a single, contiguous block of memory. for (int i = 0; i < thrusters.Length; i++) { ApplyThrust(thrusters[i]); } }
Fragmented / Dynamic
// AI-Generated Code: Technically functional, but inefficient public List<Transform> thrusters = new List<Transform>(); void Update() { // Audit Fail: Using a dynamic list for a fixed set of hardware. // Each frame, the overhead of the List logic is processed. foreach (Transform t in thrusters) { ApplyThrust(t); } }
5B

The List Launchpad

The Concept: The Dynamic List

OPTIMIZED
Contiguous Memory
// Corrected: Flexible and safe. private List<string> completedObjectives = new List<string>(); void FinishTask(string name) { // The List handles the 'parking space' management automatically. completedObjectives.Add(name); }
Fragmented / Dynamic
// AI-Generated Code: Dangerously Rigid public string[] completedObjectives = new string[5]; void FinishTask(string name) { // Audit Fail: If the player finishes 6 tasks, // the system will throw an 'IndexOutOfRangeException' and crash! completedObjectives[currentIndex] = name; currentIndex++; }
5C

The Dictionary Directory

The Concept: Key-Value Pairs

Scan
O(N)
Key
Value
O(1)
// Corrected: O(1) Complexity. Instant access. private Dictionary<int, Drone> droneFleet = new Dictionary<int, Drone>(); void UpdateFuel(int droneID, float amount) { // Audit Pass: One check, zero loops. if (droneFleet.TryGetValue(droneID, out Drone d)) { d.fuel = amount; } }
5D

Loop Efficiency

The Concept: For vs. Foreach

GC Alloc
Zero
// Corrected: Zero allocations. Maximum speed. void Update() { // Audit Pass: Direct index access is memory-clean. for (int i = 0; i < activeProjectiles.Count; i++) { activeProjectiles[i].AdvancePosition(); } }
5E

Memory Leaks

The Concept: Life-Cycle Management

GC Alloc
Zero
void OnDisable() { // Corrected: Sanitation pass. // Releases memory back to the system. flightPath.Clear(); }
5F

The Inspector List

The Concept: Serialized Collections

public int hp;
public float speed;
[Header]
public int hp;
public float speed;
CAPSTONE EXAM

The Agency Exam

The AI has generated a "Fleet Manager" that is causing severe stuttering in the simulation. Identify the three critical collection failures to restore flight performance.

Verify Capacity
Check Scope
Audit Efficiency