100 lines
2.9 KiB
C++
100 lines
2.9 KiB
C++
#ifndef PLAYER_BODY_H
|
|
#define PLAYER_BODY_H
|
|
|
|
#include "going/checkpoint.h"
|
|
#include "scene/3d/camera_3d.h"
|
|
#include "scene/3d/physics/character_body_3d.h"
|
|
#include "scene/animation/animation_player.h"
|
|
class PlayerStateMachine;
|
|
|
|
class PlayerBody : public CharacterBody3D {
|
|
GDCLASS(PlayerBody, CharacterBody3D);
|
|
static void _bind_methods();
|
|
void _notification(int what);
|
|
void enter_tree();
|
|
void ready();
|
|
virtual void unhandled_input(Ref<InputEvent> const &event) override;
|
|
void process(double delta);
|
|
void physics_process(double delta);
|
|
|
|
public:
|
|
void save_checkpoint();
|
|
void load_checkpoint();
|
|
Vector3 get_desired_direction() const;
|
|
Vector3 get_desired_velocity() const;
|
|
Vector2 get_movement_input() const;
|
|
|
|
AnimationPlayer *get_anim() const;
|
|
Camera3D *get_camera() const;
|
|
Node3D *get_model() const;
|
|
|
|
void set_stopping_deceleration(float value);
|
|
float get_stopping_deceleration() const;
|
|
void set_start_speed(float value);
|
|
float get_start_speed() const;
|
|
void set_step_boost(float value);
|
|
float get_step_boost() const;
|
|
void set_min_step_speed(float value);
|
|
float get_min_step_speed() const;
|
|
void set_acceleration(float value);
|
|
float get_acceleration() const;
|
|
void set_target_speed(float value);
|
|
float get_target_speed() const;
|
|
void set_split_step_time(double value);
|
|
double get_split_step_time() const;
|
|
void set_split_step_stop_time(double value);
|
|
double get_split_step_stop_time() const;
|
|
void set_bash_speed(float value);
|
|
float get_bash_speed() const;
|
|
void set_bash_time(double value);
|
|
double get_bash_time() const;
|
|
void set_extra_bash_time(double value);
|
|
double get_extra_bash_time() const;
|
|
void set_jump_impulse(Vector2 value);
|
|
Vector2 get_jump_impulse() const;
|
|
void set_model_lean(float value);
|
|
float get_model_lean() const;
|
|
void set_model_lean_speed(float value);
|
|
float get_model_lean_speed() const;
|
|
void set_can_jump(bool value);
|
|
bool get_can_jump() const;
|
|
void set_can_bash(bool value);
|
|
bool get_can_bash() const;
|
|
private:
|
|
Vector2 movement{0.f, 0.f};
|
|
|
|
AnimationPlayer *anim{nullptr};
|
|
Node3D *model{nullptr};
|
|
Camera3D *camera{nullptr};
|
|
|
|
float stopping_deceleration{20.f};
|
|
float start_speed{5.f};
|
|
float step_boost{7.f};
|
|
float min_step_speed{15.f};
|
|
float acceleration{8.f};
|
|
float target_speed{30.f};
|
|
double split_step_time{0.5};
|
|
double split_step_stop_time{0.5};
|
|
float bash_speed{100.f};
|
|
double bash_time{0.25};
|
|
double extra_bash_time{0.25};
|
|
Vector2 jump_impulse{5.f, 5.f};
|
|
float max_speed_dist{2.4f};
|
|
float min_dist{2.1f};
|
|
double max_delta_dist{4.f};
|
|
float model_lean{0.25f};
|
|
float model_lean_speed{0.25f};
|
|
bool can_bash{false};
|
|
bool can_jump{false};
|
|
Ref<Checkpoint> last_checkpoint{nullptr};
|
|
PlayerStateMachine *state{nullptr};
|
|
public:
|
|
static char *const split_step_action;
|
|
static char *const move_left_action;
|
|
static char *const move_right_action;
|
|
static char *const move_forward_action;
|
|
static char *const move_back_action;
|
|
};
|
|
|
|
#endif // !PLAYER_BODY_H
|