feat: now tracking current goal in unit
This commit is contained in:
parent
f2cf79d704
commit
3c75b592d3
|
@ -1,9 +1,9 @@
|
||||||
#include "unit.hpp"
|
#include "unit.hpp"
|
||||||
#include "goap/goal.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 "utils/godot_macros.hpp"
|
||||||
#include <godot_cpp/classes/navigation_agent3d.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() {
|
void Unit::_bind_methods() {
|
||||||
#define CLASSNAME Unit
|
#define CLASSNAME Unit
|
||||||
|
@ -20,8 +20,7 @@ void Unit::_process(double delta_time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::stop_plan() {
|
void Unit::stop_plan() {
|
||||||
if(this->is_queued_for_deletion())
|
this->current_goal.unref();
|
||||||
return;
|
|
||||||
this->current_plan.clear();
|
this->current_plan.clear();
|
||||||
if(this->state && !this->state->is_queued_for_deletion())
|
if(this->state && !this->state->is_queued_for_deletion())
|
||||||
this->destroy_state();
|
this->destroy_state();
|
||||||
|
@ -36,6 +35,7 @@ void Unit::plan_for_marker(GoalMarker *marker) {
|
||||||
|
|
||||||
void Unit::plan_for_goal(gd::Ref<goap::Goal> goal) {
|
void Unit::plan_for_goal(gd::Ref<goap::Goal> goal) {
|
||||||
this->current_plan = this->planner->plan_for_goal(goal);
|
this->current_plan = this->planner->plan_for_goal(goal);
|
||||||
|
this->current_goal = goal;
|
||||||
this->next_action();
|
this->next_action();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ private:
|
||||||
void replan_goal();
|
void replan_goal();
|
||||||
private:
|
private:
|
||||||
goap::Plan current_plan{};
|
goap::Plan current_plan{};
|
||||||
|
gd::Ref<goap::Goal> current_goal{};
|
||||||
goap::State *state{nullptr};
|
goap::State *state{nullptr};
|
||||||
|
|
||||||
gd::Node3D *eyes{nullptr};
|
gd::Node3D *eyes{nullptr};
|
||||||
|
|
Loading…
Reference in a new issue