From 5a132cb3519e2ed5e4bc128af23f91f5bd2f7112 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 15 Apr 2026 10:57:59 +0200 Subject: [PATCH] Refactor NPC interaction logic in runtime-interaction-system.ts --- .../runtime-interaction-system.ts | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/src/runtime-three/runtime-interaction-system.ts b/src/runtime-three/runtime-interaction-system.ts index 4fe3ac43..316b88aa 100644 --- a/src/runtime-three/runtime-interaction-system.ts +++ b/src/runtime-three/runtime-interaction-system.ts @@ -336,6 +336,10 @@ function getNpcDialoguePrompt( const hasNpcDialogue = npc.defaultDialogueId !== null || npc.dialogues.length > 0; + if (!hasClickLinks) { + return trimmedName.length > 0 ? `Talk to ${trimmedName}` : "Talk"; + } + if (hasNpcDialogue) { return trimmedName.length > 0 ? `Talk to ${trimmedName}` : "Talk"; } @@ -586,11 +590,7 @@ export class RuntimeInteractionSystem { const hasClickLinks = hasTriggerLinks(runtimeScene, npc.entityId, "click"); - if ( - !hasClickLinks && - npc.defaultDialogueId === null && - npc.dialogues.length === 0 - ) { + if (!hasClickLinks) { continue; } @@ -638,20 +638,8 @@ export class RuntimeInteractionSystem { ) ?? null; if (npc !== null) { - if (hasTriggerLinks(runtimeScene, npc.entityId, "click")) { - this.dispatchLinks(sourceEntityId, "click", runtimeScene, dispatcher); - return; - } - - if (npc.defaultDialogueId !== null || npc.dialogues.length > 0) { - dispatcher.startNpcDialogue?.(npc.entityId, npc.defaultDialogueId, { - kind: "npc", - sourceEntityId: npc.entityId, - linkId: null, - trigger: "click" - }); - return; - } + this.dispatchLinks(sourceEntityId, "click", runtimeScene, dispatcher); + return; } this.dispatchLinks(sourceEntityId, "click", runtimeScene, dispatcher);