43 lines
		
	
	
		
			883 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			883 B
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifndef PLAYER_DETECTOR_H
 | 
						|
#define PLAYER_DETECTOR_H
 | 
						|
 | 
						|
#include "player_body.h"
 | 
						|
#include "scene/3d/node_3d.h"
 | 
						|
 | 
						|
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);
 | 
						|
	void on_player_sound(Vector3 at, float range);
 | 
						|
	void set_aware_of_player(bool value);
 | 
						|
 | 
						|
protected:
 | 
						|
	void _notification(int what);
 | 
						|
 | 
						|
public:
 | 
						|
	bool is_aware_of_player() const;
 | 
						|
 | 
						|
private:
 | 
						|
	bool aware_of_player{ false };
 | 
						|
 | 
						|
	float max_hearing_range{ 100.f };
 | 
						|
 | 
						|
	float max_sight_range{ 60.f };
 | 
						|
	float min_sight_dot{ 0.7f };
 | 
						|
 | 
						|
	double query_time{ 0.3 };
 | 
						|
	double query_timer{ 0.0 };
 | 
						|
	double awareness{ 0.0 };
 | 
						|
	double awareness_increments{ 0.4 };
 | 
						|
 | 
						|
	PhysicsDirectSpaceState3D::RayParameters ray_params{};
 | 
						|
 | 
						|
public:
 | 
						|
	static String sig_awareness_changed;
 | 
						|
};
 | 
						|
 | 
						|
#endif // !PLAYER_DETECTOR_H
 |