feat: added Goal prerequisites

This commit is contained in:
Sara 2024-03-30 23:01:48 +01:00
parent b12cef310d
commit 325afa7f11
2 changed files with 13 additions and 0 deletions

View file

@ -1,5 +1,6 @@
#include "planner.hpp"
#include "action.hpp"
#include "character_actor.hpp"
#include "global_world_state.hpp"
#include "utils/godot_macros.h"
#include <cstdlib>
@ -18,6 +19,7 @@ typedef HashSet<PlannerNode, PlannerNodeHasher> NodeSet;
void Goal::_bind_methods() {
#define CLASSNAME Goal
GDPROPERTY(goal_state, Variant::DICTIONARY);
GDPROPERTY(prerequisites, Variant::DICTIONARY);
}
void Goal::set_goal_state(Dictionary dict) {
@ -28,6 +30,14 @@ Dictionary Goal::get_goal_state() const {
return Action::property_map_to_dict(this->goal_state);
}
void Goal::set_prerequisites(Dictionary dict) {
Action::dict_to_property_map(dict, this->prerequisites);
}
Dictionary Goal::get_prerequisites() const {
return Action::property_map_to_dict(this->prerequisites);
}
#undef CLASSNAME // !Goal
PlannerNode PlannerNode::goal_node(WorldState const &goal) {

View file

@ -20,8 +20,11 @@ class Goal : public Resource {
void set_goal_state(Dictionary dict);
Dictionary get_goal_state() const;
void set_prerequisites(Dictionary dict);
Dictionary get_prerequisites() const;
public:
WorldState goal_state{};
WorldState prerequisites{};
};
struct PlannerNode {