fix: HitBox::damaged gets called once in lifetime
This commit is contained in:
parent
92b1d89d9e
commit
29cb88cfd6
2 changed files with 5 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public:
|
|||
|
||||
private:
|
||||
int defense{ 1 };
|
||||
bool destroyed{ false };
|
||||
|
||||
public:
|
||||
GET_SET_FNS(int, defense);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue