feat: implementations of initial weapon inventory interface

This commit is contained in:
Sara 2025-07-15 23:01:28 +02:00
parent 6cdb2cbd4f
commit 6fa9d11af5
12 changed files with 126 additions and 11 deletions

View file

@ -1,6 +1,8 @@
#include "player_body.h"
#include "macros.h"
#include "player_input.h"
#include "weapon_base.h"
#include "weapon_inventory.h"
PlayerBody *PlayerBody::singleton_instance{ nullptr };
@ -13,6 +15,7 @@ void PlayerBody::ready() {
input->connect(PlayerInput::sig_look_input, callable_mp(this, &self_type::on_look_input));
input->connect(PlayerInput::sig_jump, callable_mp(this, &self_type::on_jump_input));
input->connect(PlayerInput::sig_run, callable_mp(this, &self_type::on_run_input));
this->weapons = cast_to<WeaponInventory>(get_node(NodePath("%WeaponInventory")));
}
void PlayerBody::process(double delta) {
@ -85,5 +88,5 @@ PlayerBody *PlayerBody::get_singleton() {
}
bool PlayerBody::get_is_running() const {
return this->try_running && this->movement_input.y > 0.f;
return this->try_running && this->movement_input.y > 0.f && this->weapons->get_current_weapon()->allows_running();
}