#include "goal.hpp" #include "utils/godot_macros.hpp" #include "utils/util_functions.hpp" namespace goap { void Goal::_bind_methods() { #define CLASSNAME Goal GDPROPERTY(requirements_dict, gd::Variant::DICTIONARY); GDPROPERTY(desired_state_dict, gd::Variant::DICTIONARY); } gd::Ref Goal::create(gd::StringName key, gd::Variant value) { gd::Ref goal = memnew(Goal); goal->desired_state.insert(key, value); return goal; } bool Goal::check_requirements_met(ActorWorldState *world_state) { for(WorldProperty const &prop : this->requirements) { if(!world_state->check_property_match(prop)) { return false; } } return true; } void Goal::set_requirements_dict(gd::Dictionary dict) { this->requirements = utils::dictionary_to_hashmap(dict); } gd::Dictionary Goal::get_requirements_dict() const { return utils::hashmap_to_dictionary(this->requirements); } void Goal::set_desired_state_dict(gd::Dictionary dict) { this->desired_state = utils::dictionary_to_hashmap(dict); } gd::Dictionary Goal::get_desired_state_dict() const { return utils::hashmap_to_dictionary(this->desired_state); } }