44 lines
1,023 B
C++
44 lines
1,023 B
C++
#ifndef PLAYER_BODY_H
|
|
#define PLAYER_BODY_H
|
|
|
|
#include "scene/3d/physics/character_body_3d.h"
|
|
class WeaponInventory;
|
|
class HealthStatus;
|
|
|
|
class PlayerBody : public CharacterBody3D {
|
|
GDCLASS(PlayerBody, CharacterBody3D);
|
|
static void _bind_methods();
|
|
static PlayerBody *singleton_instance;
|
|
|
|
void on_child_entered(Node *node);
|
|
void physics_process(double delta);
|
|
|
|
void set_movement_input(Vector2 state);
|
|
void on_look_input(Vector2 look);
|
|
void on_jump_input();
|
|
void on_run_input(bool run);
|
|
|
|
protected:
|
|
void _notification(int what);
|
|
virtual PackedStringArray get_configuration_warnings() const override;
|
|
|
|
public:
|
|
static PlayerBody *get_singleton();
|
|
bool get_is_running() const;
|
|
bool get_wants_to_run() const;
|
|
HealthStatus *get_health() const;
|
|
|
|
private:
|
|
bool try_running{ false };
|
|
float walk_speed{ 6.f };
|
|
float run_speed{ 8.f };
|
|
float acceleration{ 40.f };
|
|
float jump_strength{ 4.f };
|
|
Vector2 movement_input{ 0, 0 };
|
|
|
|
WeaponInventory *weapons;
|
|
HealthStatus *health{ nullptr };
|
|
};
|
|
|
|
#endif // !PLAYER_BODY_H
|