feat: reloading withdraws ammo from inventory
This commit is contained in:
parent
a2035e0db0
commit
ed85b557a7
8 changed files with 92 additions and 17 deletions
|
|
@ -4,12 +4,14 @@
|
|||
#include "wave_survival/macros.h"
|
||||
#include "wave_survival/player_body.h"
|
||||
#include "wave_survival/player_input.h"
|
||||
#include "wave_survival/weapon_inventory.h"
|
||||
|
||||
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);
|
||||
ClassDB::bind_method(D_METHOD("reload_full"), &self_type::reload_full);
|
||||
}
|
||||
|
||||
void Rifle::queue_enter_alt() {
|
||||
|
|
@ -53,7 +55,7 @@ void Rifle::shoot() {
|
|||
}
|
||||
|
||||
void Rifle::start_reload_animation() {
|
||||
if (!is_animating() && get_loaded_ammo() != get_max_ammo()) {
|
||||
if (!is_animating() && get_loaded_ammo() < get_max_ammo() && get_inventory()->get_rifle_ammo() > 0) {
|
||||
if (this->in_alt_mode) {
|
||||
get_anim()->queue("aim_to_hip");
|
||||
}
|
||||
|
|
@ -181,6 +183,11 @@ void Rifle::notify_selected() {
|
|||
play_equip_anim();
|
||||
}
|
||||
|
||||
void Rifle::reload_full() {
|
||||
int const available = get_inventory()->withdraw_rifle_ammo(get_max_ammo());
|
||||
reload_num(available);
|
||||
}
|
||||
|
||||
void Rifle::set_ads_factor(float value) {
|
||||
this->ads_factor = value;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue