Simplify dialogue retrieval logic in RuntimeHost
This commit is contained in:
@@ -280,7 +280,7 @@ export interface RuntimeSceneTransitionRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RuntimeDialogueState {
|
export interface RuntimeDialogueState {
|
||||||
npcEntityId: string | null;
|
npcEntityId: string;
|
||||||
dialogueId: string;
|
dialogueId: string;
|
||||||
title: string;
|
title: string;
|
||||||
lineId: string;
|
lineId: string;
|
||||||
@@ -730,22 +730,14 @@ export class RuntimeHost {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const npc =
|
||||||
|
this.runtimeScene.entities.npcs.find(
|
||||||
|
(candidate) => candidate.entityId === this.currentDialogue?.npcEntityId
|
||||||
|
) ?? null;
|
||||||
const dialogue =
|
const dialogue =
|
||||||
this.currentDialogue.npcEntityId === null
|
npc?.dialogues.find(
|
||||||
? this.runtimeScene.dialogues.dialogues[this.currentDialogue.dialogueId] ??
|
(candidate) => candidate.id === this.currentDialogue?.dialogueId
|
||||||
null
|
) ?? null;
|
||||||
: (() => {
|
|
||||||
const npc =
|
|
||||||
this.runtimeScene.entities.npcs.find(
|
|
||||||
(candidate) =>
|
|
||||||
candidate.entityId === this.currentDialogue?.npcEntityId
|
|
||||||
) ?? null;
|
|
||||||
return (
|
|
||||||
npc?.dialogues.find(
|
|
||||||
(candidate) => candidate.id === this.currentDialogue?.dialogueId
|
|
||||||
) ?? null
|
|
||||||
);
|
|
||||||
})();
|
|
||||||
|
|
||||||
if (dialogue === null) {
|
if (dialogue === null) {
|
||||||
this.setRuntimeDialogue(null);
|
this.setRuntimeDialogue(null);
|
||||||
@@ -760,18 +752,12 @@ export class RuntimeHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setRuntimeDialogue(
|
this.setRuntimeDialogue(
|
||||||
this.currentDialogue.npcEntityId === null
|
this.createRuntimeNpcDialogueState(
|
||||||
? this.createRuntimeDialogueState(
|
this.currentDialogue.npcEntityId,
|
||||||
dialogue.id,
|
dialogue.id,
|
||||||
nextLineIndex,
|
nextLineIndex,
|
||||||
this.currentDialogue.source
|
this.currentDialogue.source
|
||||||
)
|
)
|
||||||
: this.createRuntimeNpcDialogueState(
|
|
||||||
this.currentDialogue.npcEntityId,
|
|
||||||
dialogue.id,
|
|
||||||
nextLineIndex,
|
|
||||||
this.currentDialogue.source
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user