50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifndef WEAPON_INVENTORY_H
 | 
						|
#define WEAPON_INVENTORY_H
 | 
						|
 | 
						|
#include "scene/main/node.h"
 | 
						|
#include "scene/resources/packed_scene.h"
 | 
						|
class PlayerBody;
 | 
						|
class WeaponBase;
 | 
						|
 | 
						|
class WeaponInventory : public Node {
 | 
						|
	GDCLASS(WeaponInventory, Node);
 | 
						|
	static void _bind_methods();
 | 
						|
	void on_switch_input();
 | 
						|
	void stow_current_weapon();
 | 
						|
	void ready();
 | 
						|
 | 
						|
protected:
 | 
						|
	void _notification(int what);
 | 
						|
 | 
						|
public:
 | 
						|
	void select_weapon(WeaponBase *next);
 | 
						|
	WeaponBase *get_current_weapon() const;
 | 
						|
 | 
						|
	void pickup_weapon(Ref<PackedScene> weapon_scene);
 | 
						|
 | 
						|
	void set_starting_weapon(Ref<PackedScene> weapon_scene);
 | 
						|
	Ref<PackedScene> get_starting_weapon() const;
 | 
						|
 | 
						|
	void deposit_pistol_ammo(int amount);
 | 
						|
	void set_pistol_ammo(int amount);
 | 
						|
	int get_pistol_ammo() const;
 | 
						|
	int withdraw_pistol_ammo(int max_amount);
 | 
						|
	void deposit_rifle_ammo(int amount);
 | 
						|
	void set_rifle_ammo(int amount);
 | 
						|
	int get_rifle_ammo() const;
 | 
						|
	int withdraw_rifle_ammo(int max_amount);
 | 
						|
 | 
						|
private:
 | 
						|
	Node3D *weapon_parent{ nullptr };
 | 
						|
	unsigned current{ 0 };
 | 
						|
	LocalVector<WeaponBase *> weapons{ nullptr, nullptr };
 | 
						|
	WeaponBase *current_weapon{ nullptr };
 | 
						|
 | 
						|
	Ref<PackedScene> starting_weapon{};
 | 
						|
 | 
						|
	int pistol_ammo{ 16 };
 | 
						|
	int rifle_ammo{ 30 };
 | 
						|
};
 | 
						|
 | 
						|
#endif // !WEAPON_INVENTORY_H
 |