feat: weapon swapping

This commit is contained in:
Sara 2025-08-11 16:49:49 +02:00
parent 6b7a092961
commit 7a13823c97
6 changed files with 44 additions and 18 deletions

View file

@ -141,10 +141,6 @@ void Revolver::ready() {
this->muzzle = cast_to<HitscanMuzzle>(get_node(NodePath("%HitscanMuzzle")));
get_anim()->connect("animation_changed", callable_mp(this, &self_type::on_animation_changed));
get_anim()->connect("animation_finished", callable_mp(this, &self_type::on_animation_finished));
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();
}
void Revolver::process(double delta) {
@ -187,9 +183,18 @@ void Revolver::_notification(int what) {
}
void Revolver::notify_selected() {
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();
}
void Revolver::notify_deselected() {
get_input()->disconnect(PlayerInput::sig_primary_fire, callable_mp(this, &self_type::on_primary_fire));
get_input()->disconnect(PlayerInput::sig_alt_mode, callable_mp(this, &self_type::on_alt_mode));
get_input()->disconnect(PlayerInput::sig_reload, callable_mp(this, &self_type::on_reload));
}
bool Revolver::allows_running() const {
return true;
}