Tier 2 Series 106

106C: The Data Model

Pilot Record
Student Profile
"Saving `PlayerPrefs` works for one number. But what about an Inventory with 50 items? You can't save 50 separate keys. An Engineer creates a "Data Class" to bundle complex data into a single package."

The Concept: Serialization Class

A plain class (no MonoBehaviour) meant for saving.

* **Structure:** `[System.Serializable] public class SaveData { ... }`
* **Usage:** Holds List, Level, Position.
* **Benefit:** You save ONE object, not 100 variables.
Red Flag Detected

The AI Trap: "The Prefs Spam"

You ask the AI: "Save the inventory items."

// AI-Generated Code: Key Explosion
PlayerPrefs.SetString("Item1", "Sword");
PlayerPrefs.SetString("Item2", "Shield");
PlayerPrefs.SetString("Item3", "Potion");

This is "Scalability Failure." Managing 100 keys for an inventory is impossible to maintain.

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 Engineer's Correction

Corrective Protocol
// Corrected: Structural Data
[System.Serializable]
public class PlayerData {
    public List<string> inventory = new List<string>();
}
Your Pilot Command
> Implement an Event-driven system for level completion using C# Actions.
Next Mission
The JSON Carrier