feat: reloading withdraws ammo from inventory
This commit is contained in:
parent
a2035e0db0
commit
ed85b557a7
8 changed files with 92 additions and 17 deletions
|
|
@ -6,6 +6,7 @@ class AnimationPlayer;
|
|||
class PlayerCamera;
|
||||
class PlayerBody;
|
||||
class PlayerInput;
|
||||
class WeaponInventory;
|
||||
|
||||
class WeaponBase : public Node3D {
|
||||
GDCLASS(WeaponBase, Node3D);
|
||||
|
|
@ -22,6 +23,8 @@ public:
|
|||
AnimationPlayer *get_anim() const;
|
||||
PlayerInput *get_input() const;
|
||||
PlayerCamera *get_camera() const;
|
||||
WeaponInventory *get_inventory() const;
|
||||
void _set_inventory(WeaponInventory *inventory);
|
||||
|
||||
void set_body(PlayerBody *body);
|
||||
PlayerBody *get_body() const;
|
||||
|
|
@ -32,8 +35,7 @@ public:
|
|||
int get_loaded_ammo() const;
|
||||
bool try_use_ammo(int amount = 1);
|
||||
bool ammo_empty() const;
|
||||
void reload_full();
|
||||
void reload_num(int num);
|
||||
void reload_num(int num); // !< Increase loaded_ammo by num up to a maximum of max_ammo. NOTE: this will _not_ check if the ammo is available. And assumes that the ammo was already subtracted from the weapon inventory's store.
|
||||
|
||||
virtual bool allows_running() const { return false; }
|
||||
virtual bool allows_jumping() const { return true; }
|
||||
|
|
@ -44,6 +46,7 @@ private:
|
|||
AnimationPlayer *anim{ nullptr };
|
||||
PlayerCamera *camera{ nullptr };
|
||||
PlayerBody *body{ nullptr };
|
||||
WeaponInventory *inventory{ nullptr };
|
||||
|
||||
int loaded_ammo{ 0 };
|
||||
int max_ammo{ 1 };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue