Add mission_brief_shown event to hint system

- Add 'mission_brief_shown' event type to HintEntry interface
- Add triggerMissionBriefShown() method to LevelHintSystem
- Call hint trigger when mission brief is displayed in Level1
- Remove old missionBriefAudio playback from MissionBrief class

This enables database-configurable audio hints (like welcome_rookie)
to play when the mission brief is shown.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Michael Mainguy 2025-12-01 12:33:10 -06:00
parent 3104859bb7
commit 64331b4566
4 changed files with 15 additions and 22 deletions

View File

@ -146,6 +146,16 @@ export class LevelHintSystem {
}
}
/**
* Trigger mission brief shown hints - call when mission brief is displayed
*/
public triggerMissionBriefShown(): void {
const hints = this._hints.filter(h => h.eventType === 'mission_brief_shown');
for (const hint of hints) {
this.queueHint(hint);
}
}
/**
* Queue a hint for audio playback
*/

View File

@ -239,6 +239,9 @@ export class Level1 implements Level {
inputManager.enableShipControls("MissionBrief");
this.startGameplay();
});
// Trigger mission brief hints (e.g., welcome_rookie audio)
this._hintSystem?.triggerMissionBriefShown();
}
/**

View File

@ -7,7 +7,7 @@ import log from '../core/logger';
export interface HintEntry {
id: string;
levelId: string;
eventType: 'ship_status' | 'asteroid_destroyed' | 'collision';
eventType: 'ship_status' | 'asteroid_destroyed' | 'collision' | 'mission_brief_shown';
eventConfig: Record<string, unknown>;
audioUrl: string;
playMode: 'once' | 'always';

View File

@ -8,7 +8,7 @@ import {
} from "@babylonjs/gui";
import { DefaultScene } from "../../core/defaultScene";
import {MeshBuilder, Vector3, Observable, Observer} from "@babylonjs/core";
import type { AudioEngineV2, StaticSound } from "@babylonjs/core";
import type { AudioEngineV2 } from "@babylonjs/core";
import log from '../../core/logger';
import { LevelConfig } from "../../levels/config/levelConfig";
import { CloudLevelEntry } from "../../services/cloudLevelService";
@ -24,7 +24,6 @@ export class MissionBrief {
private _onStartCallback: (() => void) | null = null;
private _triggerObserver: Observer<void> | null = null;
private _audioEngine: AudioEngineV2 | null = null;
private _currentSound: StaticSound | null = null;
/**
* Initialize the mission brief as a fullscreen overlay
@ -236,21 +235,6 @@ export class MissionBrief {
this._container.isVisible = true;
this._isVisible = true;
// Play mission brief audio if specified
if (directoryEntry?.missionBriefAudio && this._audioEngine) {
log.info('[MissionBrief] Playing audio:', directoryEntry.missionBriefAudio);
this._audioEngine.createSoundAsync(
"missionBriefAudio",
directoryEntry.missionBriefAudio,
{ loop: false, volume: 1.0 }
).then(sound => {
this._currentSound = sound;
sound.play();
}).catch(err => {
log.error('[MissionBrief] Failed to load audio:', err);
});
}
log.info('[MissionBrief] ========== CONTAINER NOW VISIBLE ==========');
log.info('[MissionBrief] Container.isVisible:', this._container.isVisible);
log.info('[MissionBrief] _isVisible flag:', this._isVisible);
@ -317,10 +301,6 @@ export class MissionBrief {
* Clean up resources
*/
public dispose(): void {
if (this._currentSound) {
this._currentSound.dispose();
this._currentSound = null;
}
if (this._advancedTexture) {
this._advancedTexture.dispose();
this._advancedTexture = null;