feat: implemented rifle reload with placeholder anim
This commit is contained in:
parent
150231c67c
commit
68abfdd383
25 changed files with 26775 additions and 3 deletions
|
|
@ -42,7 +42,7 @@ void Rifle::exit_run() {
|
|||
}
|
||||
|
||||
void Rifle::shoot() {
|
||||
if (!is_animating()) {
|
||||
if (!is_animating() && try_use_ammo()) {
|
||||
this->muzzle->shoot();
|
||||
if (this->request_alt_mode) {
|
||||
get_anim()->queue("fire_aim");
|
||||
|
|
@ -52,6 +52,16 @@ void Rifle::shoot() {
|
|||
}
|
||||
}
|
||||
|
||||
void Rifle::start_reload_animation() {
|
||||
if (!is_animating() && get_loaded_ammo() != get_max_ammo()) {
|
||||
if (this->in_alt_mode) {
|
||||
get_anim()->queue("aim_to_hip");
|
||||
}
|
||||
get_anim()->queue("reload");
|
||||
get_anim()->queue("hip");
|
||||
}
|
||||
}
|
||||
|
||||
void Rifle::play_equip_anim() {
|
||||
get_anim()->play("equip", 0.0);
|
||||
get_anim()->queue("hip");
|
||||
|
|
@ -68,6 +78,10 @@ void Rifle::on_alt_mode(bool alt_mode) {
|
|||
this->request_alt_mode = alt_mode;
|
||||
}
|
||||
|
||||
void Rifle::on_reload() {
|
||||
start_reload_animation();
|
||||
}
|
||||
|
||||
void Rifle::on_animation_changed(String new_animation) {
|
||||
if (new_animation == "aim") {
|
||||
this->in_alt_mode = true;
|
||||
|
|
@ -85,6 +99,7 @@ void Rifle::ready() {
|
|||
get_anim()->connect("current_animation_changed", callable_mp(this, &self_type::on_animation_changed));
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@ class Rifle : public WeaponBase {
|
|||
void queue_enter_run();
|
||||
void exit_run();
|
||||
void shoot();
|
||||
void start_reload_animation();
|
||||
void play_equip_anim();
|
||||
void on_primary_fire(bool down);
|
||||
void on_alt_mode(bool alt_mode);
|
||||
void on_reload();
|
||||
void on_animation_changed(String new_anim);
|
||||
void on_run_input(bool run);
|
||||
void ready();
|
||||
void process(double delta);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue