replace the NPC scaffold with data-driven prefabs, and retire the builders

NPCStandIn was written to be dropped on a sphere and carried its identity in
per-instance public fields. The cost of that showed up in the scene itself: of
the two spheres, one was the Bartender and the other was named "Bartender (1)"
in the hierarchy while being configured as the Chair — data changed, name never
was. Nothing outside the scene could see what existed, and two copies could
disagree.

Identity now lives in an InteractableDefinition asset and the scene only places
a prefab. The migration matched the old objects by yarn node rather than by
name, which is the only reason the chair ended up as the chair.

InteractableDefinition rather than the planned "character definition": it covers
a character and a talkable object equally, so Bartender.prefab sits under
Prefabs/Characters and Chair.prefab under Prefabs/Interactables.

Three components collapse into one. DialogueInteractable was in no scene at all
— a dead trigger-zone variant of the same idea. ClickInteractableBridge existed
only to adapt NPCStandIn without modifying it, a constraint that died with
NPCStandIn; DialogueInteractor implements IClickInteractable itself. The parts
worth keeping were lifted out rather than discarded: WorldSpaceLabel and
InteractionPrompt are now normal components on prefab children, so a label can
be seen and positioned in the Editor instead of existing only at runtime.
InputDeviceTracker moved into NightclubArcadia.Core and gained a namespace,
leaving no global-namespace runtime types.

Characters get the same pipeline as Skills and Candidates:
Assets/Characters/characters.json is the source of truth, CharacterSetup
regenerates the definition assets on script reload and removes orphans. Adding
an NPC is a JSON entry plus a prefab — no code, and no Unity for the data half.

Phase 5.4 deletes the one-shot builders rather than disabling them. UILayerSetup,
PlayerControlSetup, UILayerSetupAutoRun and YarnDemoSetup assumed the
single-scene layout, had already destroyed a level scene and turned Systems
binary once each, and after NPCStandIn went they no longer compiled. The prefabs
they used to generate are authored and committed; the wiring knowledge is in
those prefabs and in git history. The asset generators — Skill, Candidate,
Character — are untouched and still work.

EditMode 42/42, PlayMode 7/7, YarnCheck 9 files / 35 nodes. All three scenes
still text.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
2026-08-25 21:53:06 +02:00
co-authored by Claude Opus 5
parent ec4619d9dc
commit 9a0618fd31
54 changed files with 2292 additions and 2195 deletions
+41 -9
View File
@@ -10,7 +10,7 @@ Companion reading: `docs/skill-system-refactor-plan.md`, `docs/candidate-system-
---
## 0. Status — Phases 0–4 are complete
## 0. Status — all phases complete
Executed 2026-08-25. The working tree is clean and tagged `pre-restructure`.
@@ -19,7 +19,7 @@ the UI layer, player control setup, the dialogue-vs-menu interaction fix, and th
A full pre-flight backup was taken first (`.tar.gz` of the tree excluding `Library/`, `Temp/`,
`Logs/`, and build output) plus a separate copy of the scene file.
Phases 1 through 4 are also done — see §4. Only Phase 5 (replacing the NPC scaffold) remains proposal.
Phases 1 through 5 are also done — see §4. The restructure described by this document is finished; what remains in §2 and §3 is the target state, now reached.
### 0.1 The binary scene — RESOLVED in Phase 3
@@ -535,14 +535,46 @@ to do this.
`Common.yarn` and `SC101.yarn`, and spaces were the actual problem. The `.yarnproject` graph
keys and the two character sheets in `writing/` were updated to match.
### Phase 5 — replace the scaffold
### Phase 5 — replace the scaffold ✅ DONE (2026-08-25)
| # | Step | Detail | Effort |
|---|---|---|---|
| 5.1 | Design the real NPC component | data-driven from a character definition asset, not public fields on a sphere | M |
| 5.2 | Build `Prefabs/Characters/` prefabs | one per named character | M |
| 5.3 | Migrate scene NPCs off `NPCStandIn`, delete it | proximity prompt + label logic is worth keeping — extract, don't discard | M |
| 5.4 | Retire the `Assets/Editor/*Setup.cs` one-shot builders | only once prefabs are authored and committed; `UILayerSetup.cs` alone is 818 lines of accumulated wiring knowledge | L |
| # | Step | Status |
|---|---|---|
| 5.1 | Data-driven NPC component | done — `InteractableDefinition` + `DialogueInteractor` |
| 5.2 | `Prefabs/Characters/` prefabs | done — Bartender, and Chair under `Prefabs/Interactables/` |
| 5.3 | Migrate scene NPCs off `NPCStandIn`, delete it | done — label and prompt logic extracted, not discarded |
| 5.4 | Retire the one-shot `*Setup.cs` builders | done — four deleted |
Validated: EditMode **42/42**, PlayMode **7/7**, YarnCheck 9 files / 35 nodes.
#### Phase 5 — what changed against the plan
**The second "NPC" was the chair.** The scene had two spheres. One was the Bartender; the other
was named `Bartender (1)` in the hierarchy but configured with `npcName: Chair` and
`Chair_Interaction` — a duplicate whose data was changed and whose name never was. That is
precisely the failure mode of identity living in per-instance fields, and it decided the design:
identity moved into an asset, and the migration matched objects **by yarn node, not by name**.
So the plan's "character definition" became `InteractableDefinition`, covering both a character
and a talkable object, and the prefabs split across `Prefabs/Characters/` and
`Prefabs/Interactables/`.
**Three components were deleted, not one.** `DialogueInteractable` turned out to be in **no
scene at all** — a dead trigger-zone variant of the same idea. `ClickInteractableBridge` existed
only to adapt `NPCStandIn` without modifying it, a constraint that died with `NPCStandIn`;
`DialogueInteractor` implements `IClickInteractable` directly. Net: three components replaced by
one, plus two small reusable pieces (`WorldSpaceLabel`, `InteractionPrompt`) lifted out of the
scaffold rather than thrown away.
**5.4 went further than "retire".** The plan said retire the builders once prefabs were authored.
They were also, by then, actively harmful — `YarnDemoSetup` destroyed a level scene and
`PlayerControlSetup` turned Systems binary — and after deleting `NPCStandIn` they no longer
compiled. They are deleted, not merely disabled. `UILayerSetup`'s 818 lines of wiring knowledge
now live in the committed UI prefabs, and in git history if ever needed.
**Characters got the same JSON pipeline as Skills and Candidates.** `Assets/Characters/characters.json`
is the source of truth; `CharacterSetup` regenerates the definition assets on script reload and
deletes orphans. Adding an NPC is a JSON entry and a prefab, with no code and no Unity required
for the data half.
### 4.6 Keep / relocate / replace, at a glance