wave-survival/modules/wave_survival/weapon_base.h

56 lines
1.5 KiB
C++

#ifndef WEAPON_BASE_H
#define WEAPON_BASE_H
#include "scene/3d/node_3d.h"
class AnimationPlayer;
class PlayerCamera;
class PlayerBody;
class PlayerInput;
class WeaponInventory;
class WeaponBase : public Node3D {
GDCLASS(WeaponBase, Node3D);
static void _bind_methods();
void ready();
protected:
void _notification(int what);
virtual PackedStringArray get_configuration_warnings() const override;
public:
bool is_animating() const;
void set_anim(AnimationPlayer *player);
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;
void set_max_ammo(int amount);
int get_max_ammo() const;
void set_loaded_ammo(int amount);
int get_loaded_ammo() const;
bool try_use_ammo(int amount = 1);
bool ammo_empty() const;
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; }
virtual void notify_selected() {}
private:
PlayerInput *input{ nullptr };
AnimationPlayer *anim{ nullptr };
PlayerCamera *camera{ nullptr };
PlayerBody *body{ nullptr };
WeaponInventory *inventory{ nullptr };
int loaded_ammo{ 0 };
int max_ammo{ 1 };
};
#endif // !WEAPON_BASE_H