#ifndef PLAYER_ANIM_TREE_HPP #define PLAYER_ANIM_TREE_HPP #include "utils/godot_macros.hpp" #include #include #include 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; void death_animation(); private: void update_tags(gd::StringName const &anim); void commit_turn_speed(); void commit_walk_speed(); private: 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}; gd::Ref 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}; float death_blend{0.f}; bool is_dead{false}; Tags current_tags{Tags::None}; gd::StringName last_known_anim{}; }; #endif // !PLAYER_ANIM_HPP