From f02dbf44acc958e033a5953a6ddd6a60b75c8930 Mon Sep 17 00:00:00 2001 From: Sara Date: Sat, 19 Jul 2025 15:26:55 +0200 Subject: [PATCH] feat: added more settings to rifle --- modules/wave_survival/weapons/rifle.cpp | 28 ++++++++++++++++++++----- modules/wave_survival/weapons/rifle.h | 6 ++++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/modules/wave_survival/weapons/rifle.cpp b/modules/wave_survival/weapons/rifle.cpp index 31a48f4e..92bf6060 100644 --- a/modules/wave_survival/weapons/rifle.cpp +++ b/modules/wave_survival/weapons/rifle.cpp @@ -1,10 +1,16 @@ #include "rifle.h" #include "scene/animation/animation_player.h" #include "wave_survival/hitscan_muzzle.h" +#include "wave_survival/macros.h" #include "wave_survival/player_body.h" #include "wave_survival/player_input.h" -void Rifle::_bind_methods() {} +void Rifle::_bind_methods() { + BIND_PROPERTY(Variant::FLOAT, ads_factor); + BIND_PROPERTY(Variant::FLOAT, run_factor); + BIND_PROPERTY(Variant::FLOAT, recoil_force); + BIND_PROPERTY(Variant::FLOAT, recoil_time); +} void Rifle::queue_start_aim() { get_anim()->queue("hip_to_aim"); @@ -71,10 +77,6 @@ void Rifle::on_animation_changed(String new_animation) { } else if (new_animation == "run") { get_camera()->set_fov_factor(this->run_factor); } - - print_line(vformat("playing %s", new_animation)); - Vector queue{ get_anim()->get_queue() }; - print_line(queue); } void Rifle::ready() { @@ -169,3 +171,19 @@ void Rifle::set_run_factor(float value) { float Rifle::get_run_factor() const { return this->run_factor; } + +void Rifle::set_recoil_force(float value) { + this->recoil_force = value; +} + +float Rifle::get_recoil_force() const { + return this->recoil_force; +} + +void Rifle::set_recoil_time(float value) { + this->recoil_time = value; +} + +float Rifle::get_recoil_time() const { + return this->recoil_time; +} diff --git a/modules/wave_survival/weapons/rifle.h b/modules/wave_survival/weapons/rifle.h index b6d40f5d..69f8367e 100644 --- a/modules/wave_survival/weapons/rifle.h +++ b/modules/wave_survival/weapons/rifle.h @@ -30,12 +30,14 @@ public: virtual void notify_selected() override; bool is_animating() const; - void set_recoil_radians(float value); - float get_recoil_radians() const; void set_ads_factor(float value); float get_ads_factor() const; void set_run_factor(float value); float get_run_factor() const; + void set_recoil_force(float value); + float get_recoil_force() const; + void set_recoil_time(float value); + float get_recoil_time() const; private: float ads_factor{ 0.5f };