From 29cb88cfd61952cf9daa4fe39bac9e5cf79f9976 Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 1 Dec 2025 18:38:02 +0100 Subject: [PATCH] fix: HitBox::damaged gets called once in lifetime --- modules/break_utopia/hit_box.cpp | 4 ++++ modules/break_utopia/hit_box.h | 1 + 2 files changed, 5 insertions(+) diff --git a/modules/break_utopia/hit_box.cpp b/modules/break_utopia/hit_box.cpp index 30fc97be..a1ec7e81 100644 --- a/modules/break_utopia/hit_box.cpp +++ b/modules/break_utopia/hit_box.cpp @@ -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); } diff --git a/modules/break_utopia/hit_box.h b/modules/break_utopia/hit_box.h index 592f2b57..ade7d33e 100644 --- a/modules/break_utopia/hit_box.h +++ b/modules/break_utopia/hit_box.h @@ -12,6 +12,7 @@ public: private: int defense{ 1 }; + bool destroyed{ false }; public: GET_SET_FNS(int, defense);