Make playSound method in RuntimeAudioSystem accept null for link parameter and update RuntimeInteractionSystem to handle new control effects

This commit is contained in:
2026-04-14 01:34:56 +02:00
parent 8639566565
commit a935ccfc96
2 changed files with 18 additions and 2 deletions

View File

@@ -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) {

View File

@@ -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.`
);
}
}
}