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

/// The resolved reference for a HUD element: a zero-based index into
/// [WolfensteinData.vgaImages].
class HudAssetRef {
  const HudAssetRef(this.vgaIndex);

  final int vgaIndex;

  @override
  String toString() => 'HudAssetRef($vgaIndex)';
}

/// Owns the mapping from symbolic [HudKey] identifiers to VGA image indices.
///
/// Implement this class to provide a custom HUD layout for a modded or
/// alternate game version. Pass the implementation inside a custom
/// [AssetRegistry] when loading data.
abstract class HudModule {
  const HudModule();

  /// Resolves [key] to a [HudAssetRef] containing the VGA image index.
  ///
  /// Returns `null` if the key is not supported by this module.
  HudAssetRef? resolve(HudKey key);

  /// Returns the appropriate [HudKey] for BJ's face sprite given the
  /// player's current [health].
  HudKey faceKeyForHealth(int health);

  /// Convenience: resolves BJ's face image directly from [health].
  HudAssetRef? faceForHealth(int health) => resolve(faceKeyForHealth(health));
}
