Delegate all audio management to the new audio package, then manage that through a new wolf3d class

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-15 14:33:58 +01:00
parent 070110adae
commit 6eb903cbaa
10 changed files with 249 additions and 81 deletions

View File

@@ -2,6 +2,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:wolf_3d_data/wolf_3d_data.dart';
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
import 'package:wolf_3d_synth/wolf_3d_synth.dart';
class Wolf3d {
Wolf3d._();
@@ -12,6 +13,9 @@ class Wolf3d {
final List<WolfensteinData> availableGames = [];
WolfensteinData? _activeGame;
// --- Core Systems ---
final WolfAudio audio = WolfAudio();
// --- Getters ---
WolfensteinData get activeGame {
if (_activeGame == null) {
@@ -20,6 +24,15 @@ class Wolf3d {
return _activeGame!;
}
// --- Episode ---
int _activeEpisode = 0;
int get activeEpisode => _activeEpisode;
void setActiveEpisode(int episodeIndex) {
_activeEpisode = episodeIndex;
}
// Convenience getters for the active game's assets
List<WolfLevel> get levels => activeGame.levels;
List<Sprite> get walls => activeGame.walls;
@@ -36,6 +49,7 @@ class Wolf3d {
/// Initializes the engine by loading available game data.
Future<void> init({String? directory}) async {
await audio.init();
availableGames.clear();
// 1. Bundle asset loading (migrated from GameSelectScreen)