From a935ccfc964b2e9fd1e1d6282f14a39d8dc92ee3 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Tue, 14 Apr 2026 01:34:56 +0200 Subject: [PATCH] Make playSound method in RuntimeAudioSystem accept null for link parameter and update RuntimeInteractionSystem to handle new control effects --- src/runtime-three/runtime-audio-system.ts | 2 +- .../runtime-interaction-system.ts | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/runtime-three/runtime-audio-system.ts b/src/runtime-three/runtime-audio-system.ts index c74a5baa..3067e602 100644 --- a/src/runtime-three/runtime-audio-system.ts +++ b/src/runtime-three/runtime-audio-system.ts @@ -147,7 +147,7 @@ export class RuntimeAudioSystem { }); } - playSound(soundEmitterId: string, link: InteractionLink) { + playSound(soundEmitterId: string, link: InteractionLink | null = null) { const soundEmitter = this.soundEmitters.get(soundEmitterId); if (soundEmitter === undefined) { diff --git a/src/runtime-three/runtime-interaction-system.ts b/src/runtime-three/runtime-interaction-system.ts index 10ff41f1..a87bcf4c 100644 --- a/src/runtime-three/runtime-interaction-system.ts +++ b/src/runtime-three/runtime-interaction-system.ts @@ -1,5 +1,9 @@ import type { Vec3 } from "../core/vector"; -import type { InteractionLink } from "../interactions/interaction-links"; +import type { ControlEffect } from "../controls/control-surface"; +import { + getInteractionActionControlEffect, + type InteractionLink +} from "../interactions/interaction-links"; import type { RuntimeInteractable, @@ -19,6 +23,7 @@ export interface RuntimeInteractionDispatcher { stopAnimation(instanceId: string, link: InteractionLink): void; playSound(soundEmitterId: string, link: InteractionLink): void; stopSound(soundEmitterId: string, link: InteractionLink): void; + dispatchControlEffect?(effect: ControlEffect, link: InteractionLink): void; } export interface RuntimeInteractionPrompt { @@ -293,6 +298,13 @@ export class RuntimeInteractionSystem { continue; } + const controlEffect = getInteractionActionControlEffect(link.action); + + if (controlEffect !== null && dispatcher.dispatchControlEffect !== undefined) { + dispatcher.dispatchControlEffect(controlEffect, link); + continue; + } + switch (link.action.type) { case "teleportPlayer": { const teleportTarget = resolveTeleportTarget(runtimeScene, link.action.targetEntityId); @@ -317,6 +329,10 @@ export class RuntimeInteractionSystem { case "stopSound": dispatcher.stopSound(link.action.targetSoundEmitterId, link); break; + case "control": + throw new Error( + `Runtime control action ${link.action.effect.type} could not be dispatched because the runtime dispatcher does not support control effects.` + ); } } }