AttackApi class

API with attack helpers available in every GameComponent.

Access it through the attack object:

component.attack.melee(damage: 10, size: Vector2(20, 20));
component.attack.rangeByAngle(...);

Constructors

AttackApi(GameComponent comp)

Properties

comp GameComponent
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

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}) → void
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).
meleeByAngle({required double damage, required double angle, required AttackOriginEnum attackFrom, required Vector2 size, dynamic id, Future<SpriteAnimation>? animation, bool withPush = true, double marginFromCenter = 0, Vector2? centerOffset, void onDamage(WithLife attackable)?}) → void
Executes a melee attack by angle (radians).
meleeByDirection({required double damage, required Direction direction, required Vector2 size, required AttackOriginEnum attackFrom, Future<SpriteAnimation>? animationRight, dynamic id, bool withPush = true, double? sizePush, double? marginFromCenter, Vector2? centerOffset, void onDamage(WithLife attackable)?}) → void
Executes a melee attack by direction.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
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}) → void
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).
rangeByAngle({required Future<SpriteAnimation> animation, required Vector2 size, required double angle, required double damage, required AttackOriginEnum attackFrom, Vector2? destroySize, Future<SpriteAnimation>? animationDestroy, dynamic id, double speed = 150, bool withDecorationCollision = true, VoidCallback? onDestroy, ShapeHitbox? collision, LightingConfig? lightingConfig, double marginFromOrigin = 16, Vector2? centerOffset}) → void
Executes a ranged attack using a component with animation by angle.
rangeByDirection({required Future<SpriteAnimation> animationRight, required Vector2 size, required Direction direction, required AttackOriginEnum attackFrom, Vector2? destroySize, dynamic id, double speed = 150, double damage = 1, bool withCollision = true, VoidCallback? onDestroy, ShapeHitbox? collision, LightingConfig? lightingConfig, Future<SpriteAnimation>? animationDestroy, double marginFromOrigin = 16, Vector2? centerOffset}) → void
Executes a ranged attack using a component with animation by direction.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited