import 'package:wolf_3d_dart/src/data_types/enemy_animation.dart';
import 'package:wolf_3d_dart/src/data_types/sprite_frame_range.dart';
import 'package:wolf_3d_dart/src/registry/keys/entity_key.dart';
import 'package:wolf_3d_dart/src/registry/modules/entity_asset_module.dart';

/// Built-in entity asset module for the Wolfenstein 3D v1.4 Shareware release.
///
/// Shareware restricts the available enemy roster to Guard, Dog, and SS.
/// Mutant and Officer are absent; Boss entries are retail-only.
///
/// Sprite ranges for the three available enemies are identical to retail
/// (the VSWAP sprite layout is the same for this subset).
class SharewareEntityModule extends EntityAssetModule {
  const SharewareEntityModule();

  static final Map<EntityKey, EntityAssetDefinition> _defs = {
    EntityKey.guard: const EntityAssetDefinition(
      availableInShareware: true,
      animations: EnemyAnimationMap(
        idle: SpriteFrameRange(50, 57),
        walking: SpriteFrameRange(58, 89),
        dying: SpriteFrameRange(90, 93),
        pain: SpriteFrameRange(94, 94),
        dead: SpriteFrameRange(95, 95),
        attacking: SpriteFrameRange(96, 98),
      ),
    ),
    EntityKey.dog: const EntityAssetDefinition(
      availableInShareware: true,
      animations: EnemyAnimationMap(
        idle: SpriteFrameRange(99, 106),
        walking: SpriteFrameRange(99, 130),
        attacking: SpriteFrameRange(135, 137),
        pain: SpriteFrameRange(0, 0),
        dying: SpriteFrameRange(131, 133),
        dead: SpriteFrameRange(134, 134),
      ),
    ),
    EntityKey.ss: const EntityAssetDefinition(
      availableInShareware: true,
      animations: EnemyAnimationMap(
        idle: SpriteFrameRange(138, 145),
        walking: SpriteFrameRange(146, 177),
        attacking: SpriteFrameRange(184, 186),
        pain: SpriteFrameRange(182, 182),
        dying: SpriteFrameRange(178, 181),
        dead: SpriteFrameRange(183, 183),
      ),
    ),
    // Mutant and Officer are NOT present in shareware; resolving them
    // intentionally returns null so callers can handle absence cleanly.
  };

  @override
  EntityAssetDefinition? resolve(EntityKey key) => _defs[key];
}
