range method
void
range({
- required Future<
SpriteAnimation> animation, - required Vector2 size,
- Future<
SpriteAnimation> ? animationDestroy, - Vector2? destroySize,
- dynamic id,
- double speed = 150,
- double damage = 1,
- Direction? direction,
- double? angle,
- bool useAngle = false,
- bool withCollision = true,
- bool withDecorationCollision = true,
- ShapeHitbox? collision,
- VoidCallback? onDestroy,
- LightingConfig? lightingConfig,
- Vector2? centerOffset,
- double marginFromOrigin = 16,
- AttackOriginEnum? attackFrom,
Executes a ranged attack. If angle (radians) or useAngle is provided
the projectile is fired in that direction, otherwise direction is used
(defaults to the player or the component direction).
Implementation
void range({
required Future<SpriteAnimation> animation,
required Vector2 size,
Future<SpriteAnimation>? animationDestroy,
Vector2? destroySize,
dynamic id,
double speed = 150,
double damage = 1,
Direction? direction,
double? angle,
bool useAngle = false,
bool withCollision = true,
bool withDecorationCollision = true,
ShapeHitbox? collision,
VoidCallback? onDestroy,
LightingConfig? lightingConfig,
Vector2? centerOffset,
double marginFromOrigin = 16,
AttackOriginEnum? attackFrom,
}) {
final origin = attackFrom ?? _defaultAttackFrom();
if (angle != null || useAngle) {
rangeByAngle(
animation: animation,
animationDestroy: animationDestroy,
size: size,
angle: angle ?? comp.util.getAngleToPlayer(),
damage: damage,
attackFrom: origin,
destroySize: destroySize,
id: id,
speed: speed,
withDecorationCollision: withDecorationCollision,
onDestroy: onDestroy,
collision: collision,
lightingConfig: lightingConfig,
centerOffset: centerOffset,
marginFromOrigin: marginFromOrigin,
);
} else {
rangeByDirection(
animationRight: animation,
animationDestroy: animationDestroy,
size: size,
direction: direction ?? _defaultMeleeDirection(true),
damage: damage,
attackFrom: origin,
destroySize: destroySize,
id: id,
speed: speed,
withCollision: withCollision,
onDestroy: onDestroy,
collision: collision,
lightingConfig: lightingConfig,
centerOffset: centerOffset,
marginFromOrigin: marginFromOrigin,
);
}
}