57 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifndef TR_PLAYER_HPP
 | 
						|
#define TR_PLAYER_HPP
 | 
						|
 | 
						|
#include "camera_effects.hpp"
 | 
						|
#include "damageable_entity.hpp"
 | 
						|
#include "player_anim_tree.hpp"
 | 
						|
#include "utils/player_input.hpp"
 | 
						|
#include <godot_cpp/classes/character_body3d.hpp>
 | 
						|
#include <godot_cpp/classes/animation_node_state_machine_playback.hpp>
 | 
						|
namespace gd = godot;
 | 
						|
 | 
						|
class Player : public gd::CharacterBody3D, public DamageableEntity {
 | 
						|
    GDCLASS(Player, gd::CharacterBody3D);
 | 
						|
    static void _bind_methods();
 | 
						|
public:
 | 
						|
    virtual void _enter_tree() override;
 | 
						|
    virtual void _ready() override;
 | 
						|
    virtual void _process(double delta) override;
 | 
						|
    virtual void _physics_process(double delta) override;
 | 
						|
    virtual void damage() override;
 | 
						|
 | 
						|
    void process_transform_camera(double delta);
 | 
						|
    void process_rotate(double delta);
 | 
						|
 | 
						|
    void _on_dir_horizontal(gd::Ref<gd::InputEvent>, float value);
 | 
						|
    void _on_dir_vertical(gd::Ref<gd::InputEvent>, float value);
 | 
						|
    void _on_look_vertical(gd::Ref<gd::InputEvent>, float value);
 | 
						|
    void _on_fire(gd::Ref<gd::InputEvent> event, float);
 | 
						|
    void _on_run(gd::Ref<gd::InputEvent> event, float);
 | 
						|
    void _on_switch_shoulder(gd::Ref<gd::InputEvent> event, float);
 | 
						|
 | 
						|
    gd::Vector2 get_input_directions() const;
 | 
						|
 | 
						|
    static Player *get_player_instance();
 | 
						|
private:
 | 
						|
    PlayerAnimTree *anim_tree{nullptr};
 | 
						|
    gd::Node3D *camera_parent{nullptr};
 | 
						|
    CameraEffects *camera{};
 | 
						|
    float camera_height{0.f};
 | 
						|
    utils::PlayerInput *input{nullptr};
 | 
						|
    gd::Node3D *model_node{nullptr};
 | 
						|
    gd::Vector2 input_directions{0.f, 0.f};
 | 
						|
    float input_look_vertical{0.f};
 | 
						|
 | 
						|
    float const ROTATION_SPEED{1.8f};
 | 
						|
    float const CAMERA_ROTATION_SPEED{2.f};
 | 
						|
    float const CAMERA_VERTICAL_LIMIT{0.1};
 | 
						|
    float const CAMERA_VERTICAL_ROTATION_SPEED{1.5f};
 | 
						|
    float const AIMING_CAMERA_ROTATION_SPEED{1.f};
 | 
						|
    float const AIM_INPUT_THRESHOLD{-0.9f};
 | 
						|
    float const WALK_INPUT_THRESHOLD{0.5f};
 | 
						|
 | 
						|
    static Player *player_instance;
 | 
						|
};
 | 
						|
 | 
						|
#endif // !TR_PLAYER_HPP
 |