#include "tank_unit.hpp"
#include "entity_health.hpp"

void TankUnit::_bind_methods() {}

void TankUnit::use_weapon() {
    gd::Node3D *target{this->world_state->get_target_node()};
    if(target == nullptr)
        return;
    if(!this->world_state->get_can_see_target())
        return;
    if(1.f < target->get_global_position().distance_squared_to(this->get_global_position()))
        return;
    this->aim_at(target);
    EntityHealth *health = target->get_node<EntityHealth>("EntityHealth");
    if(health == nullptr)
        return;
    health->damaged_by(2, this);
}
