feat: now tracking current goal in unit

This commit is contained in:
Sara 2024-06-19 12:53:07 +02:00
parent f2cf79d704
commit 3c75b592d3
2 changed files with 5 additions and 4 deletions

View file

@ -1,9 +1,9 @@
#include "unit.hpp"
#include "goap/goal.hpp"
#include "godot_cpp/variant/callable_method_pointer.hpp"
#include "godot_cpp/variant/utility_functions.hpp"
#include "utils/godot_macros.hpp"
#include <godot_cpp/classes/navigation_agent3d.hpp>
#include <godot_cpp/variant/callable_method_pointer.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
void Unit::_bind_methods() {
#define CLASSNAME Unit
@ -20,8 +20,7 @@ void Unit::_process(double delta_time) {
}
void Unit::stop_plan() {
if(this->is_queued_for_deletion())
return;
this->current_goal.unref();
this->current_plan.clear();
if(this->state && !this->state->is_queued_for_deletion())
this->destroy_state();
@ -36,6 +35,7 @@ void Unit::plan_for_marker(GoalMarker *marker) {
void Unit::plan_for_goal(gd::Ref<goap::Goal> goal) {
this->current_plan = this->planner->plan_for_goal(goal);
this->current_goal = goal;
this->next_action();
}

View file

@ -31,6 +31,7 @@ private:
void replan_goal();
private:
goap::Plan current_plan{};
gd::Ref<goap::Goal> current_goal{};
goap::State *state{nullptr};
gd::Node3D *eyes{nullptr};