receiveDamage method
This method is called to give damage a this component.
Only receive damage if the method checkCanReceiveDamage return true
.
Implementation
void receiveDamage(
AttackFromEnum attacker,
double damage,
dynamic identify,
) {
if (checkCanReceiveDamage(attacker, damage, identify)) {
if (life > 0) {
life -= damage;
}
if (life <= 0 && !_isDead) {
die();
}
}
}