simpleAttackRange method

void simpleAttackRange({
  1. required Future<SpriteAnimation> animation,
  2. required Future<SpriteAnimation> animationDestroy,
  3. required Vector2 size,
  4. Vector2? destroySize,
  5. double? radAngleDirection,
  6. int? id,
  7. double speed = 150,
  8. double damage = 1,
  9. int interval = 1000,
  10. bool withDecorationCollision = true,
  11. VoidCallback? onDestroy,
  12. ShapeHitbox? collision,
  13. VoidCallback? onExecute,
  14. LightingConfig? lightingConfig,
  15. Vector2? centerOffset,
  16. double marginFromOrigin = 16,
})

Execute the ranged attack using a component with animation

Implementation

void simpleAttackRange({
  /// use animation facing right.
  required Future<SpriteAnimation> animation,
  required Future<SpriteAnimation> animationDestroy,
  required Vector2 size,
  Vector2? destroySize,
  double? radAngleDirection,
  int? id,
  double speed = 150,
  double damage = 1,
  int interval = 1000,
  bool withDecorationCollision = true,
  VoidCallback? onDestroy,
  ShapeHitbox? collision,
  VoidCallback? onExecute,
  LightingConfig? lightingConfig,
  Vector2? centerOffset,
  double marginFromOrigin = 16,
}) {
  if (!checkInterval('attackRange', interval, dtUpdate)) return;

  if (isDead) return;

  simpleAttackRangeByAngle(
    animation: animation,
    animationDestroy: animationDestroy,
    size: size,
    angle: radAngleDirection ?? angle,
    id: id,
    speed: speed,
    damage: damage,
    withDecorationCollision: withDecorationCollision,
    onDestroy: onDestroy,
    destroySize: destroySize,
    collision: collision,
    lightingConfig: lightingConfig,
    centerOffset: centerOffset,
    marginFromOrigin: marginFromOrigin,
    attackFrom: AttackOriginEnum.ENEMY,
  );

  onExecute?.call();
}