#include "character_unit.hpp"

void CharacterUnit::_bind_methods() {
#define CLASSNAME CharacterUnit
}

void CharacterUnit::_ready() {
    this->parent_type::_ready();
    this->inventory = this->get_node<Inventory>("%Inventory");
}

void CharacterUnit::use_weapon() {
    gd::Node3D *target{this->world_state->get_target_node()};
    Item const *weapon{this->inventory->get_weapon()};
    if(weapon == nullptr) {
        this->parent_type::use_weapon(); // use the default unarmed attack instead
    } else {
        this->inventory->get_weapon()->try_use_on(this, target);
    }
}

