feat: started work on reloading
This commit is contained in:
parent
2d720a983a
commit
150231c67c
17 changed files with 63 additions and 33 deletions
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
void WeaponBase::_bind_methods() {
|
||||
BIND_HPROPERTY(Variant::OBJECT, anim, PROPERTY_HINT_NODE_TYPE, AnimationPlayer::get_class_static());
|
||||
BIND_PROPERTY(Variant::INT, max_ammo);
|
||||
BIND_PROPERTY(Variant::INT, loaded_ammo);
|
||||
}
|
||||
|
||||
void WeaponBase::ready() {
|
||||
|
|
@ -64,3 +66,28 @@ void WeaponBase::set_body(PlayerBody *body) {
|
|||
PlayerBody *WeaponBase::get_body() const {
|
||||
return this->body;
|
||||
}
|
||||
|
||||
void WeaponBase::set_max_ammo(int amount) {
|
||||
this->max_ammo = amount;
|
||||
}
|
||||
|
||||
int WeaponBase::get_max_ammo() const {
|
||||
return MAX(0, this->max_ammo);
|
||||
}
|
||||
|
||||
void WeaponBase::set_loaded_ammo(int amount) {
|
||||
this->loaded_ammo = CLAMP(amount, 0, this->max_ammo);
|
||||
}
|
||||
|
||||
int WeaponBase::get_loaded_ammo() const {
|
||||
return this->loaded_ammo;
|
||||
}
|
||||
|
||||
bool WeaponBase::try_use_ammo(int amount) {
|
||||
if (this->loaded_ammo >= amount) {
|
||||
loaded_ammo -= amount;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue