From 846174f7720e0b4ed4d6f8da24f8f2d7583d3abb Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Sat, 19 Sep 2026 02:13:30 -0400 Subject: [PATCH] HurtboxBase can now find a character hit solely from the CharacterSkeleton3D. --- src/liborng/nodes/hurtbox/hurtbox_base.cpp | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/liborng/nodes/hurtbox/hurtbox_base.cpp b/src/liborng/nodes/hurtbox/hurtbox_base.cpp index 906955f..cd717b4 100644 --- a/src/liborng/nodes/hurtbox/hurtbox_base.cpp +++ b/src/liborng/nodes/hurtbox/hurtbox_base.cpp @@ -55,47 +55,47 @@ void HurtboxBase::_ready() void HurtboxBase::_physics_process(double delta) { - TypedArray characters_hit_this_frame; - const TypedArray &bodies = this->get_overlapping_bodies(); const uint32_t num_bodies = bodies.size(); for (uint32_t i = 0; i < num_bodies; i++) { - if (Character3D *body = cast_to(bodies[i])) + if (PhysicalBone3D *character_bone = cast_to(bodies[i])) { - if (!this->hit_character_bodies.has(body)) + if (CharacterSkeleton3D *character_skeleton = cast_to(character_bone->get_owner())) { - characters_hit_this_frame.append(body); - TypedArray bone_hits; - - for (uint32_t bone_index = 0; bone_index < num_bodies; bone_index++) + Character3D *body = cast_to(character_skeleton->get_parent()); + if (body && !this->hit_character_bodies.has(body)) { - if (PhysicalBone3D *bone = cast_to(bodies[bone_index])) + this->hit_character_bodies.append(body); + TypedArray bone_hits; + + for (uint32_t bone_index = 0; bone_index < num_bodies; bone_index++) { - if (String(bone->get_path()).begins_with(String(body->get_path()))) + if (PhysicalBone3D *bone = cast_to(bodies[bone_index])) { - bone_hits.append(bone->get_bone_id()); - PRINT_LOG(HURTBOX_BASE_TAG, "Bone hit: ", bone->get_name(), " (", bone->get_class(), " : ", bone->get_rid(), ")"); + if (String(bone->get_path()).begins_with(String(body->get_path()))) + { + bone_hits.append(bone->get_bone_id()); + PRINT_LOG(HURTBOX_BASE_TAG, "Bone hit: ", bone->get_name(), " (", bone->get_class(), " : ", bone->get_rid(), ")"); + } } } + + PRINT_LOG(HURTBOX_BASE_TAG, "Character hit: ", body->get_name(), " (", body->get_class(), " : ", body->get_rid(), ")"); + + Dictionary hit_data; + hit_data["body"] = body; + hit_data["bone_hits"] = bone_hits; + hit_data["hit_points"] = this->hit_points; + hit_data["hit_transform"] = this->get_global_transform(); + + this->hit_data_queue.emplace_back(hit_data); } - - PRINT_LOG(HURTBOX_BASE_TAG, "Character hit: ", body->get_name(), " (", body->get_class(), " : ", body->get_rid(), ")"); - - Dictionary hit_data; - hit_data["body"] = body; - hit_data["bone_hits"] = bone_hits; - hit_data["hit_points"] = this->hit_points; - hit_data["hit_transform"] = this->get_global_transform(); - - this->hit_data_queue.emplace_back(hit_data); } } } - this->hit_character_bodies.append_array(characters_hit_this_frame); - if (this->remaining_life <= 0.0f) this->collision_shape->set_disabled(true); else