import * as Phaser from 'phaser'; export function safePlaySound( scene: Phaser.Scene, key: string, config?: Phaser.Types.Sound.SoundConfig, ): void { const soundManager = scene.sound; if (!soundManager) { return; } try { const audioCache = scene.cache.audio; const hasInCache = audioCache ? audioCache.exists(key) : false; const existing = (soundManager as Phaser.Sound.BaseSoundManager).get(key); if (!hasInCache && !existing) { console.warn('[SoundUtils] Audio key not found, skip play', { key }); return; } soundManager.play(key, config); } catch (e) { console.error('[SoundUtils] Failed to play sound', { key, error: e }); } }