Skip to content

Commit

Permalink
adds comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelBarbosatec committed Jul 29, 2024
1 parent 77bf185 commit 50abb28
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/mixins/attackable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ mixin Attackable on GameComponent {

double get life => _life;

/// Set initial life
void initialLife(double life) {
_life = life;
_maxLife = life;
}

/// increase life
/// Increase life
void addLife(double life) {
double newLife = _life + life;

Expand All @@ -43,6 +44,7 @@ mixin Attackable on GameComponent {
_verifyLimitsLife();
}

// Update life
void updateLife(double life, {bool verifyDieOrRevive = true}) {
_life = life;
if (verifyDieOrRevive) {
Expand All @@ -62,7 +64,10 @@ mixin Attackable on GameComponent {
_verifyLimitsLife();
}

// Called when life is removed
void onRemoveLife(double life) {}

// Called when life is restored
void onRestoreLife(double life) {}

void _verifyLimitsLife() {
Expand All @@ -87,6 +92,7 @@ mixin Attackable on GameComponent {
return canReceive;
}

// Called when the component receives damage
void onReceiveDamage(
AttackOriginEnum attacker,
double damage,
Expand Down Expand Up @@ -120,15 +126,18 @@ mixin Attackable on GameComponent {
return false;
}

// Called when the component dies
void onDie() {
_isDead = true;
}

// Called when the component revives
void onRevive() {
_isDead = false;
}

bool get isDead => _isDead;

// Get rect collision of the component used to receive damage
Rect rectAttackable() => rectCollision;
}

0 comments on commit 50abb28

Please sign in to comment.