#include "state.hpp"
#include "goap/action.hpp"
#include "goap/actor_world_state.hpp"
#include "utils/godot_macros.hpp"

namespace goap {
void State::_bind_methods() {
#define CLASSNAME State
    GDSIGNAL("end_state");
}

void State::_enter_tree() {
    this->world_state = this->get_node<ActorWorldState>("../ActorWorldState");
}

void State::_process(double delta_time) {
    if(this->action->is_completed(this->world_state)) {
        this->end_state();
    }
}

Action const *State::get_action() const {
    return this->action;
}

void State::_end_state() {}

void State::end_state() {
    this->_end_state();
    this->queue_free();
    this->emit_signal("end_state");
}
}
