feat: implemented full reload for revolver
This commit is contained in:
parent
f40f01a569
commit
905726c862
18 changed files with 81 additions and 7 deletions
|
|
@ -50,6 +50,12 @@ void Revolver::stop_running() {
|
|||
}
|
||||
}
|
||||
|
||||
void Revolver::start_reloading() {
|
||||
this->alt_active = false;
|
||||
get_anim()->queue("double_to_reload");
|
||||
get_anim()->queue("reload_one");
|
||||
}
|
||||
|
||||
void Revolver::play_equip_anim() {
|
||||
get_anim()->play("equip", 0.0);
|
||||
queue_idle_anim();
|
||||
|
|
@ -57,7 +63,7 @@ void Revolver::play_equip_anim() {
|
|||
}
|
||||
|
||||
void Revolver::shoot() {
|
||||
if (animation_is_idle()) {
|
||||
if (animation_is_idle() && try_use_ammo(1)) {
|
||||
stop_running();
|
||||
if (this->alt_active) {
|
||||
this->alt_active = false;
|
||||
|
|
@ -93,10 +99,26 @@ void Revolver::on_alt_mode(bool pressed) {
|
|||
}
|
||||
|
||||
void Revolver::on_reload() {
|
||||
if (get_loaded_ammo() < get_max_ammo() && !is_animating()) {
|
||||
start_reloading();
|
||||
}
|
||||
}
|
||||
|
||||
void Revolver::on_animation_finished(String old_anim) {
|
||||
if (old_anim == "reload_one" && get_anim()->get_queue().is_empty()) {
|
||||
reload_num(1);
|
||||
if (get_loaded_ammo() < get_max_ammo()) {
|
||||
get_anim()->queue("reload_one");
|
||||
} else {
|
||||
get_anim()->queue("reload_to_double");
|
||||
get_anim()->queue("idle_double");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Revolver::ready() {
|
||||
this->muzzle = cast_to<HitscanMuzzle>(get_node(NodePath("%HitscanMuzzle")));
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class Revolver : public WeaponBase {
|
|||
void queue_idle_anim();
|
||||
void start_running();
|
||||
void stop_running();
|
||||
void start_reloading();
|
||||
void interrupt_reloading();
|
||||
void interrupt_running();
|
||||
void play_equip_anim();
|
||||
void shoot();
|
||||
|
|
@ -17,6 +19,7 @@ class Revolver : public WeaponBase {
|
|||
void on_primary_fire(bool pressed);
|
||||
void on_alt_mode(bool pressed);
|
||||
void on_reload();
|
||||
void on_animation_finished(String old_anim);
|
||||
void ready();
|
||||
void process(double delta);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue