Add null checks and event listeners for audio system in runtime host

This commit is contained in:
2026-04-02 19:39:55 +02:00
parent 75c6492751
commit 12facde036
2 changed files with 33 additions and 3 deletions

View File

@@ -161,7 +161,9 @@ export class RuntimeAudioSystem {
for (const soundEmitter of this.soundEmitters.values()) {
this.soundGroup.remove(soundEmitter.group);
soundEmitter.group.remove(soundEmitter.audio as PositionalAudio);
if (soundEmitter.audio !== null) {
soundEmitter.group.remove(soundEmitter.audio);
}
}
this.soundEmitters.clear();
@@ -189,7 +191,9 @@ export class RuntimeAudioSystem {
for (const soundEmitter of this.soundEmitters.values()) {
this.stopSound(soundEmitter.entity.entityId);
this.soundGroup.remove(soundEmitter.group);
soundEmitter.group.remove(soundEmitter.audio as PositionalAudio);
if (soundEmitter.audio !== null) {
soundEmitter.group.remove(soundEmitter.audio);
}
}
this.soundEmitters.clear();