feat: added Goal prerequisites
This commit is contained in:
parent
b12cef310d
commit
325afa7f11
|
@ -1,5 +1,6 @@
|
||||||
#include "planner.hpp"
|
#include "planner.hpp"
|
||||||
#include "action.hpp"
|
#include "action.hpp"
|
||||||
|
#include "character_actor.hpp"
|
||||||
#include "global_world_state.hpp"
|
#include "global_world_state.hpp"
|
||||||
#include "utils/godot_macros.h"
|
#include "utils/godot_macros.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
@ -18,6 +19,7 @@ typedef HashSet<PlannerNode, PlannerNodeHasher> NodeSet;
|
||||||
void Goal::_bind_methods() {
|
void Goal::_bind_methods() {
|
||||||
#define CLASSNAME Goal
|
#define CLASSNAME Goal
|
||||||
GDPROPERTY(goal_state, Variant::DICTIONARY);
|
GDPROPERTY(goal_state, Variant::DICTIONARY);
|
||||||
|
GDPROPERTY(prerequisites, Variant::DICTIONARY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Goal::set_goal_state(Dictionary dict) {
|
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);
|
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
|
#undef CLASSNAME // !Goal
|
||||||
|
|
||||||
PlannerNode PlannerNode::goal_node(WorldState const &goal) {
|
PlannerNode PlannerNode::goal_node(WorldState const &goal) {
|
||||||
|
|
|
@ -20,8 +20,11 @@ class Goal : public Resource {
|
||||||
|
|
||||||
void set_goal_state(Dictionary dict);
|
void set_goal_state(Dictionary dict);
|
||||||
Dictionary get_goal_state() const;
|
Dictionary get_goal_state() const;
|
||||||
|
void set_prerequisites(Dictionary dict);
|
||||||
|
Dictionary get_prerequisites() const;
|
||||||
public:
|
public:
|
||||||
WorldState goal_state{};
|
WorldState goal_state{};
|
||||||
|
WorldState prerequisites{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PlannerNode {
|
struct PlannerNode {
|
||||||
|
|
Loading…
Reference in a new issue