feat: added on-target-destroyed callback to unit world state
This commit is contained in:
parent
6dddbced43
commit
58a717aec4
|
@ -44,9 +44,16 @@ bool UnitWorldState::get_is_target_dead() const {
|
|||
|
||||
void UnitWorldState::set_target_node(gd::Node3D *node) {
|
||||
this->target_node = node;
|
||||
if(node != nullptr)
|
||||
node->connect("tree_exited", callable_mp(this, &UnitWorldState::target_destroyed).bind(node));
|
||||
this->emit_signal("attention_changed");
|
||||
}
|
||||
|
||||
gd::Node3D *UnitWorldState::get_target_node() const {
|
||||
return this->target_node;
|
||||
}
|
||||
|
||||
void UnitWorldState::target_destroyed(gd::Node3D *target) {
|
||||
if(target == this->target_node)
|
||||
this->set_target_node(nullptr);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ public:
|
|||
|
||||
void set_target_node(gd::Node3D *node);
|
||||
gd::Node3D *get_target_node() const;
|
||||
private:
|
||||
void target_destroyed(gd::Node3D *target);
|
||||
private:
|
||||
Unit *parent_unit{nullptr};
|
||||
gd::NavigationAgent3D *agent{nullptr};
|
||||
|
|
Loading…
Reference in a new issue