From dfc5ac680aca90bb427f959e5327e67e1ead8a62 Mon Sep 17 00:00:00 2001 From: Sara Date: Mon, 2 Feb 2026 20:19:11 +0100 Subject: [PATCH] chore: detector line_of_sight_exists is public --- modules/wave_survival/player_detector.cpp | 22 +++++++++++----------- modules/wave_survival/player_detector.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/wave_survival/player_detector.cpp b/modules/wave_survival/player_detector.cpp index 3a550bfd..6869cccf 100644 --- a/modules/wave_survival/player_detector.cpp +++ b/modules/wave_survival/player_detector.cpp @@ -8,17 +8,6 @@ void PlayerDetector::_bind_methods() { ADD_SIGNAL(MethodInfo(sig_awareness_changed, PropertyInfo(Variant::BOOL, "aware"))); } -// check if there is geometry between detector and player -bool PlayerDetector::line_of_sight_exists() const { - PhysicsDirectSpaceState3D::RayParameters params{ this->ray_params }; - params.from = get_global_position(); - params.to = PlayerBody::get_singleton()->get_global_position(); - PhysicsDirectSpaceState3D *space{ get_world_3d()->get_direct_space_state() }; - PhysicsDirectSpaceState3D::RayResult result{}; - space->intersect_ray(params, result); - return result.collider == nullptr; -} - // Check if the player is in a bounded area in front of the detector and unobscured. // As all tests are required to pass, we do them in increasing order of complexity, to minimize unneeded resource use. bool PlayerDetector::check() const { @@ -82,6 +71,17 @@ void PlayerDetector::_notification(int what) { } } +// check if there is geometry between detector and player +bool PlayerDetector::line_of_sight_exists() const { + PhysicsDirectSpaceState3D::RayParameters params{ this->ray_params }; + params.from = get_global_position(); + params.to = PlayerBody::get_singleton()->get_global_position(); + PhysicsDirectSpaceState3D *space{ get_world_3d()->get_direct_space_state() }; + PhysicsDirectSpaceState3D::RayResult result{}; + space->intersect_ray(params, result); + return result.collider == nullptr; +} + bool PlayerDetector::is_aware_of_player() const { return this->aware_of_player; } diff --git a/modules/wave_survival/player_detector.h b/modules/wave_survival/player_detector.h index b9447aca..f57f0dca 100644 --- a/modules/wave_survival/player_detector.h +++ b/modules/wave_survival/player_detector.h @@ -6,7 +6,6 @@ class PlayerDetector : public Node3D { GDCLASS(PlayerDetector, Node3D); static void _bind_methods(); - bool line_of_sight_exists() const; bool check() const; void ready(); void process(double delta); @@ -17,6 +16,7 @@ protected: void _notification(int what); public: + bool line_of_sight_exists() const; bool is_aware_of_player() const; private: