feat: started work on reloading

This commit is contained in:
Sara 2025-08-05 16:20:55 +02:00
parent 2d720a983a
commit 150231c67c
17 changed files with 63 additions and 33 deletions

View file

@ -26,6 +26,11 @@ void Revolver::queue_idle_anim() {
void Revolver::start_running() {
if (this->run_animation_timer <= 0.0) {
if (this->alt_active) {
get_anim()->queue("single_to_run");
} else {
get_anim()->queue("double_to_run");
}
get_anim()->queue("run");
}
}
@ -36,7 +41,7 @@ void Revolver::stop_running() {
if (current == "run") {
get_anim()->stop();
}
if (current.begins_with("run")) {
if (current.begins_with("run") || current.ends_with("run")) {
if (this->alt_active) {
get_anim()->queue("run_to_single");
} else {
@ -87,10 +92,14 @@ void Revolver::on_alt_mode(bool pressed) {
}
}
void Revolver::on_reload() {
}
void Revolver::ready() {
this->muzzle = cast_to<HitscanMuzzle>(get_node(NodePath("%HitscanMuzzle")));
get_input()->connect(PlayerInput::sig_primary_fire, callable_mp(this, &self_type::on_primary_fire));
get_input()->connect(PlayerInput::sig_alt_mode, callable_mp(this, &self_type::on_alt_mode));
get_input()->connect(PlayerInput::sig_reload, callable_mp(this, &self_type::on_reload));
play_equip_anim();
}

View file

@ -16,6 +16,7 @@ class Revolver : public WeaponBase {
void cock_hammer();
void on_primary_fire(bool pressed);
void on_alt_mode(bool pressed);
void on_reload();
void ready();
void process(double delta);
@ -43,7 +44,7 @@ private:
double recoil_time{ 0.1 };
double recoil_timer{ 0.0 };
double run_animation_delay{ 0.3 };
double run_animation_delay{ 0.8 };
double run_animation_timer{ 0.0 };
};