2024-12-04 15:15:40 +00:00
|
|
|
#ifndef PLAYER_ANIM_TREE_HPP
|
|
|
|
#define PLAYER_ANIM_TREE_HPP
|
|
|
|
|
|
|
|
#include "utils/godot_macros.hpp"
|
|
|
|
#include <godot_cpp/classes/animation_node_state_machine_playback.hpp>
|
2024-12-06 16:12:06 +00:00
|
|
|
#include <godot_cpp/classes/animation_tree.hpp>
|
|
|
|
#include <godot_cpp/classes/node3d.hpp>
|
2024-12-04 15:15:40 +00:00
|
|
|
namespace gd = godot;
|
|
|
|
|
|
|
|
class PlayerAnimTree : public gd::AnimationTree {
|
|
|
|
GDCLASS(PlayerAnimTree, gd::AnimationTree);
|
|
|
|
static void _bind_methods();
|
|
|
|
public:
|
|
|
|
enum Tags : unsigned {
|
|
|
|
None = 0x0,
|
|
|
|
Turn = 0x1,
|
|
|
|
Aim = 0x2
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
virtual void _ready() override;
|
|
|
|
virtual void _process(double delta) override;
|
|
|
|
|
|
|
|
void set_target_turn_speed(float value);
|
|
|
|
float get_target_turn_speed() const;
|
|
|
|
void set_is_walking(bool value);
|
|
|
|
bool get_is_walking() const;
|
|
|
|
void set_walk_speed(float value);
|
|
|
|
float get_walk_speed() const;
|
|
|
|
void set_is_running();
|
|
|
|
bool get_is_running() const;
|
|
|
|
void set_aim_weapon(bool value);
|
|
|
|
bool get_aim_weapon() const;
|
|
|
|
void set_fire_weapon();
|
|
|
|
bool get_fire_weapon();
|
|
|
|
bool match_tags(Tags tags) const;
|
2024-12-06 16:12:06 +00:00
|
|
|
void death_animation();
|
2024-12-04 15:15:40 +00:00
|
|
|
private:
|
|
|
|
void update_tags(gd::StringName const &anim);
|
|
|
|
void commit_turn_speed();
|
|
|
|
void commit_walk_speed();
|
|
|
|
private:
|
2024-12-06 16:12:06 +00:00
|
|
|
double const DEATH_BLEND_SPEED{1. / 0.3}; //!< multiplier for delta_time when blending from state machine to death animation
|
|
|
|
double const FIRE_PARAM_DECAY{0.5}; //!< how many seconds it takes for a fire input to become invalid
|
|
|
|
double const RUN_PARAM_DECAY{0.25}; //!< how many seconds to run every time set_is_running is called
|
|
|
|
|
|
|
|
gd::Node3D *parent_3d{nullptr};
|
2024-12-04 15:15:40 +00:00
|
|
|
gd::Ref<gd::AnimationNodeStateMachinePlayback> fsm;
|
|
|
|
float turn_speed{0.f};
|
|
|
|
float target_turn_speed{0.f};
|
|
|
|
bool is_walking{false};
|
|
|
|
float walk_speed{0.f};
|
|
|
|
double running_time{0.0};
|
|
|
|
bool aim_weapon{false};
|
|
|
|
double fire_weapon{0.0};
|
2024-12-06 16:12:06 +00:00
|
|
|
float death_blend{0.f};
|
|
|
|
bool is_dead{false};
|
2024-12-04 15:15:40 +00:00
|
|
|
Tags current_tags{Tags::None};
|
|
|
|
gd::StringName last_known_anim{};
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // !PLAYER_ANIM_HPP
|