feat: added parent_ and target_ global_position world props
This commit is contained in:
parent
6c227f6b52
commit
1b8563a5eb
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue