fix: HitBox::damaged gets called once in lifetime

This commit is contained in:
Sara Gerretsen 2025-12-01 18:38:02 +01:00
parent 92b1d89d9e
commit 29cb88cfd6
2 changed files with 5 additions and 0 deletions

View file

@ -8,8 +8,12 @@ void HitBox::_bind_methods() {
}
void HitBox::damage(int level) {
if (this->destroyed) {
return;
}
if (level >= this->defense) {
GDVIRTUAL_CALL(damaged, level);
this->destroyed = true;
} else {
GDVIRTUAL_CALL(damage_blocked, level);
}

View file

@ -12,6 +12,7 @@ public:
private:
int defense{ 1 };
bool destroyed{ false };
public:
GET_SET_FNS(int, defense);