From b461e31b0bb918af5171715cffed8fd96ad6fda2 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Thu, 2 Apr 2026 19:41:26 +0200 Subject: [PATCH] Implement handleAddSoundInteractionLink in App.tsx --- src/app/App.tsx | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/app/App.tsx b/src/app/App.tsx index 02e11e7e..28039745 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -1644,6 +1644,50 @@ export function App({ store, initialStatusMessage }: AppProps) { setStatusMessage(`Added a visibility link to the selected ${selectedInteractionSource.kind === "triggerVolume" ? "Trigger Volume" : "Interactable"}.`); }; + const handleAddSoundInteractionLink = (actionType: "playSound" | "stopSound") => { + if (selectedInteractionSource === null) { + setStatusMessage("Select a Trigger Volume or Interactable before adding links."); + return; + } + + const defaultTarget = soundEmitterOptions.find(({ entity }) => { + if (entity.audioAssetId === null) { + return false; + } + + const asset = editorState.document.assets[entity.audioAssetId]; + return asset?.kind === "audio"; + })?.entity; + + if (defaultTarget === undefined) { + setStatusMessage("Author a Sound Emitter with an audio asset before adding sound links."); + return; + } + + const link = + actionType === "playSound" + ? createPlaySoundInteractionLink({ + sourceEntityId: selectedInteractionSource.id, + trigger: getDefaultInteractionLinkTrigger(selectedInteractionSource), + targetSoundEmitterId: defaultTarget.id + }) + : createStopSoundInteractionLink({ + sourceEntityId: selectedInteractionSource.id, + trigger: getDefaultInteractionLinkTrigger(selectedInteractionSource), + targetSoundEmitterId: defaultTarget.id + }); + + store.executeCommand( + createUpsertInteractionLinkCommand({ + link, + label: actionType === "playSound" ? "Add play sound link" : "Add stop sound link" + }) + ); + setStatusMessage( + `Added a ${actionType === "playSound" ? "play sound" : "stop sound"} link to the selected ${selectedInteractionSource.kind === "triggerVolume" ? "Trigger Volume" : "Interactable"}.` + ); + }; + const handleDeleteInteractionLink = (linkId: string) => { try { store.executeCommand(createDeleteInteractionLinkCommand(linkId));