📚 Encyclopedia

Games & Graphics · updated 2026-10-13

Game content data models (stable ids, schemas, serialization)

data-modelserializationjsonidslevel-editorarchitecturemigrations

Lessons about how a game should identify, store, and evolve its levels and entities, drawn from a full audit of Run (Flutter/Flame) in 2026-10, where most recurring bugs traced back to these structural choices rather than to gameplay code.

Give every piece of content a stable identity

One pipeline, not three

Run had 23 legacy levels as Dart classes (4.6k lines), 15 JSON built-ins, and server-side "worlds". Each path had its own bugs. Prefer one repository (bundled asset pack -> disk cache -> network manifest), with built-ins published like any other content.

The "forgotten field" bug class

When an entity's field is declared in ~9 places (declaration, constructor, toJson, fromJson, copy, runtime builder, runtime constructor, properties panel, canvas), adding a field means editing 9 files, and missing one silently drops data. Run's editor audit found: copy() dropping lock fields, "is this draft empty?" checks ignoring newer entity lists (which then auto-deleted real work), serialization that skipped fields when a toggle was off (so turning the toggle back on lost the settings). Fixes: - One entity interface (sealed class) and a dimension.all enumeration instead of N parallel typed lists enumerated by hand in ~20 places. - A type registry/schema that drives JSON, the properties panel, spawning, and respawn policy. - Code generation for copy/equality/JSON. - Serialize every field whenever it differs from the default, regardless of toggles. - An exhaustive round-trip test (build every entity with non-default values, serialize, parse, compare) plus a golden parse of all built-in levels.

Tolerant, versioned decoding

Dynamic content ("worlds")

Run's plan to scale past dozens of levels: themed worlds stored in the database (name, description, difficulty 1-5, theme, icon, sort order, lock state, ordered levels) so the app binary stays small and content ships without a release. Requirements: identical UX to built-ins, stale-while-revalidate caching for offline, server withholds JSON for editor-locked levels, thumbnails generated client-side from geometry. Missing pieces found later: no per-level version/updated_at, N+1 fetches, no offline cache.

See also

Linked from

Sources: run memory (architecture-audit-2026-10.md, improvement-cycles.md, session-v085.md, level-design-worlds.md, feedback-dont-jump-ahead.md)