import 'package:wolf_3d_dart/src/registry/keys/music_key.dart';

/// The resolved reference for a music track: a numeric index into
/// [WolfensteinData.music].
class MusicRoute {
  const MusicRoute(this.trackIndex);

  final int trackIndex;

  @override
  String toString() => 'MusicRoute($trackIndex)';
}

/// Owns the mapping from music contexts to IMF track indices.
///
/// Implement this class to provide a custom music layout for a modded or
/// alternate game version. Pass the implementation inside a custom
/// [AssetRegistry] when loading data.
abstract class MusicModule {
  const MusicModule();

  /// Resolves a named [Music] to a [MusicRoute].
  ///
  /// Returns `null` if the key is not supported by this module.
  MusicRoute? resolve(Music key);

  /// Resolves the level music track for a given [episodeIndex] and
  /// zero-based [levelIndex].
  ///
  /// This is the primary routing path for in-game level music, which the
  /// original engine mapped via a lookup table rather than per-level fields.
  MusicRoute musicForLevel(int episodeIndex, int levelIndex);

  /// The music track to play while the main menu is shown.
  MusicRoute get menuMusic;
}
