melee method

void melee({
  1. required double damage,
  2. required Vector2 size,
  3. Future<SpriteAnimation>? animation,
  4. dynamic id,
  5. Direction? direction,
  6. double? angle,
  7. bool withPush = true,
  8. double? sizePush,
  9. Vector2? centerOffset,
  10. double? marginFromCenter,
  11. bool diagonalEnabled = true,
  12. AttackOriginEnum? attackFrom,
})

Executes a melee attack. If angle (radians) is provided the attack is performed in that direction, otherwise direction is used (defaults to the player, the component direction or the last movement direction).

Implementation

void melee({
  required double damage,
  required Vector2 size,
  Future<SpriteAnimation>? animation,
  dynamic id,
  Direction? direction,
  double? angle,
  bool withPush = true,
  double? sizePush,
  Vector2? centerOffset,
  double? marginFromCenter,
  bool diagonalEnabled = true,
  AttackOriginEnum? attackFrom,
}) {
  final origin = attackFrom ?? _defaultAttackFrom();
  if (angle != null) {
    meleeByAngle(
      damage: damage,
      size: size,
      animation: animation,
      id: id,
      angle: angle,
      attackFrom: origin,
      withPush: withPush,
      centerOffset: centerOffset,
      marginFromCenter: marginFromCenter ?? 0,
    );
  } else {
    meleeByDirection(
      damage: damage,
      size: size,
      animationRight: animation,
      id: id,
      direction: direction ?? _defaultMeleeDirection(diagonalEnabled),
      attackFrom: origin,
      withPush: withPush,
      sizePush: sizePush,
      centerOffset: centerOffset,
      marginFromCenter: marginFromCenter,
    );
  }
}