simpleAttackRange method

void simpleAttackRange({
  1. required Future<SpriteAnimation> animationRight,
  2. required Future<SpriteAnimation> animationDestroy,
  3. required Vector2 size,
  4. Vector2? destroySize,
  5. int? id,
  6. double speed = 150,
  7. double damage = 1,
  8. Direction? direction,
  9. int interval = 1000,
  10. bool withCollision = true,
  11. ShapeHitbox? collision,
  12. VoidCallback? onDestroy,
  13. VoidCallback? execute,
  14. LightingConfig? lightingConfig,
})

Execute the ranged attack using a component with animation

Implementation

void simpleAttackRange({
  required Future<SpriteAnimation> animationRight,
  required Future<SpriteAnimation> animationDestroy,
  required Vector2 size,
  Vector2? destroySize,
  int? id,
  double speed = 150,
  double damage = 1,
  Direction? direction,
  int interval = 1000,
  bool withCollision = true,
  ShapeHitbox? collision,
  VoidCallback? onDestroy,
  VoidCallback? execute,
  LightingConfig? lightingConfig,
}) {
  if (!checkInterval('attackRange', interval, dtUpdate)) return;

  if (isDead) return;

  Direction direct = direction ??
      (gameRef.player != null
          ? getComponentDirectionFromMe(gameRef.player!)
          : lastDirection);

  simpleAttackRangeByDirection(
    animationRight: animationRight,
    animationDestroy: animationDestroy,
    size: size,
    direction: direct,
    id: id,
    speed: speed,
    damage: damage,
    withCollision: withCollision,
    collision: collision,
    onDestroy: onDestroy,
    destroySize: destroySize,
    lightingConfig: lightingConfig,
    attackFrom: AttackOriginEnum.ENEMY,
  );
  execute?.call();
}