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:
@@ -0,0 +1,46 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NightclubArcadia.Interaction
|
||||
{
|
||||
/// <summary>
|
||||
/// What a thing in the world is called and which conversation it starts.
|
||||
///
|
||||
/// This replaces a set of public fields edited per scene object. The scaffold it
|
||||
/// grew out of had the name, colour, yarn node, ranges and font sizes all set on
|
||||
/// each sphere by hand, which meant two objects claiming to be the same character
|
||||
/// could disagree, and nothing outside the scene could see what existed.
|
||||
///
|
||||
/// Generated from Assets/Characters/characters.json — edit the JSON, not the asset.
|
||||
/// Hand edits are overwritten, the same contract as Skills and Candidates.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Nightclub Arcadia/Interactable Definition", order = 30)]
|
||||
public sealed class InteractableDefinition : ScriptableObject
|
||||
{
|
||||
[SerializeField] string id;
|
||||
[SerializeField] string displayName;
|
||||
[SerializeField] string yarnNode;
|
||||
[SerializeField] float interactionRange = 3f;
|
||||
|
||||
[Tooltip("Shown as a floating label. Off for scenery that should not announce itself.")]
|
||||
[SerializeField] bool showLabel = true;
|
||||
|
||||
public string Id => id;
|
||||
public string DisplayName => displayName;
|
||||
public string YarnNode => yarnNode;
|
||||
public float InteractionRange => interactionRange;
|
||||
public bool ShowLabel => showLabel;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>Editor-only, for the generator. Not part of the runtime surface.</summary>
|
||||
public void EditorSet(string newId, string newDisplayName, string newYarnNode,
|
||||
float newRange, bool newShowLabel)
|
||||
{
|
||||
id = newId;
|
||||
displayName = newDisplayName;
|
||||
yarnNode = newYarnNode;
|
||||
interactionRange = newRange;
|
||||
showLabel = newShowLabel;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user