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 module for Spear of Destiny demo/shareware (`.SDM`).
///
/// The sprite enum in the original source inserts four additional static
/// sprites before enemy animations for SPEAR builds, so all Wolf3D enemy
/// animation ranges are shifted by +4.
class SpearDemoEntityModule extends EntityAssetModule {
  const SpearDemoEntityModule();

  static final Map<EntityKey, EntityAssetDefinition> _defs = {
    EntityKey.guard: const EntityAssetDefinition(
      availableInShareware: true,
      animations: EnemyAnimationMap(
        idle: SpriteFrameRange(54, 61),
        walking: SpriteFrameRange(62, 93),
        dying: SpriteFrameRange(94, 97),
        pain: SpriteFrameRange(98, 98),
        dead: SpriteFrameRange(99, 99),
        attacking: SpriteFrameRange(100, 102),
      ),
    ),
    EntityKey.dog: const EntityAssetDefinition(
      availableInShareware: true,
      animations: EnemyAnimationMap(
        idle: SpriteFrameRange(103, 110),
        walking: SpriteFrameRange(103, 134),
        attacking: SpriteFrameRange(139, 141),
        pain: SpriteFrameRange(0, 0),
        dying: SpriteFrameRange(135, 137),
        dead: SpriteFrameRange(138, 138),
      ),
    ),
    EntityKey.ss: const EntityAssetDefinition(
      availableInShareware: true,
      animations: EnemyAnimationMap(
        idle: SpriteFrameRange(142, 149),
        walking: SpriteFrameRange(150, 181),
        attacking: SpriteFrameRange(188, 190),
        pain: SpriteFrameRange(186, 186),
        dying: SpriteFrameRange(182, 185),
        dead: SpriteFrameRange(187, 187),
      ),
    ),
  };

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