import 'package:wolf_3d_dart/src/data_types/game_version.dart';
import 'package:wolf_3d_dart/src/registry/asset_registry.dart';
import 'package:wolf_3d_dart/src/registry/built_in/built_in_music_module.dart';
import 'package:wolf_3d_dart/src/registry/built_in/built_in_sfx_module.dart';
import 'package:wolf_3d_dart/src/registry/built_in/shareware_entity_module.dart';
import 'package:wolf_3d_dart/src/registry/built_in/shareware_hud_module.dart';
import 'package:wolf_3d_dart/src/registry/built_in/shareware_menu_module.dart';

/// The [AssetRegistry] for the Wolfenstein 3D v1.4 Shareware release.
///
/// - SFX slots are resolved through version-aware [SoundEffect.idFor].
/// - Music routing uses [Music.levelFor] for the 10-level shareware table.
/// - Entity definitions are limited to the three shareware enemies.
/// - HUD indices are shareware-aware and offset from retail layout.
/// - Menu picture indices are resolved via runtime heuristic offset; call
///   [SharewareMenuPicModule.initWithImageSizes] after the VGA images are
///   available so the shift is computed correctly.
class SharewareAssetRegistry extends AssetRegistry {
  SharewareAssetRegistry({bool strictOriginalShareware = false})
    : super(
        sfx: const BuiltInSfxModule(GameVersion.shareware),
        music: const BuiltInMusicModule(GameVersion.shareware),
        entities: const SharewareEntityModule(),
        hud: SharewareHudModule(
          useOriginalWl1Map: strictOriginalShareware,
        ),
        menu: SharewareMenuPicModule(
          useOriginalWl1Map: strictOriginalShareware,
        ),
      );

  /// Convenience accessor to the menu module for post-load initialisation.
  SharewareMenuPicModule get sharewareMenu => menu as SharewareMenuPicModule;

  /// Convenience accessor to the HUD module for post-load initialisation.
  SharewareHudModule get sharewareHud => hud as SharewareHudModule;
}
