diff --git a/src/unit_world_state.cpp b/src/unit_world_state.cpp index d453a33..8f1fea1 100644 --- a/src/unit_world_state.cpp +++ b/src/unit_world_state.cpp @@ -18,6 +18,8 @@ void UnitWorldState::_bind_methods() { GDFUNCTION(get_is_target_enemy); GDFUNCTION(get_is_in_melee_range); GDFUNCTION(get_is_health_safe); + GDFUNCTION(get_parent_global_position); + GDFUNCTION(get_target_global_position); } void UnitWorldState::_enter_tree() { GDGAMEONLY(); @@ -86,6 +88,14 @@ bool UnitWorldState::get_is_health_safe() const { return float(this->health->get_injury_current()) > (float(this->health->get_injury_max()) / 2.f); } +gd::Vector3 UnitWorldState::get_parent_global_position() const { + return this->parent_unit->get_global_position(); +} + +gd::Vector3 UnitWorldState::get_target_global_position() const { + return this->target_node == nullptr ? gd::Vector3{0.f, 0.f, 0.f} : this->target_node->get_global_position(); +} + void UnitWorldState::set_target_node(gd::Node3D *node) { if(this->target_node != nullptr) this->target_node->disconnect("tree_exited", this->target_node_exited_tree.bind(this->target_node)); diff --git a/src/unit_world_state.hpp b/src/unit_world_state.hpp index bd3db95..a0824ed 100644 --- a/src/unit_world_state.hpp +++ b/src/unit_world_state.hpp @@ -20,6 +20,8 @@ public: bool get_is_target_enemy() const; bool get_is_in_melee_range() const; bool get_is_health_safe() const; + gd::Vector3 get_parent_global_position() const; + gd::Vector3 get_target_global_position() const; void set_target_node(gd::Node3D *node); gd::Node3D *get_target_node() const;