summaryrefslogtreecommitdiff
path: root/scene/2d/navigation_agent_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/navigation_agent_2d.cpp')
-rw-r--r--scene/2d/navigation_agent_2d.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/scene/2d/navigation_agent_2d.cpp b/scene/2d/navigation_agent_2d.cpp
index 42dabeb488..cb2dbba0fe 100644
--- a/scene/2d/navigation_agent_2d.cpp
+++ b/scene/2d/navigation_agent_2d.cpp
@@ -100,10 +100,11 @@ void NavigationAgent2D::_notification(int p_what) {
Node *p = get_parent();
while (p != nullptr) {
nav = Object::cast_to<Navigation2D>(p);
- if (nav != nullptr)
+ if (nav != nullptr) {
p = nullptr;
- else
+ } else {
p = p->get_parent();
+ }
}
set_navigation(nav);
@@ -145,8 +146,9 @@ NavigationAgent2D::~NavigationAgent2D() {
}
void NavigationAgent2D::set_navigation(Navigation2D *p_nav) {
- if (navigation == p_nav)
+ if (navigation == p_nav) {
return; // Pointless
+ }
navigation = p_nav;
NavigationServer2D::get_singleton()->agent_set_map(agent, navigation == nullptr ? RID() : navigation->get_rid());
@@ -276,12 +278,15 @@ String NavigationAgent2D::get_configuration_warning() const {
}
void NavigationAgent2D::update_navigation() {
- if (agent_parent == nullptr)
+ if (agent_parent == nullptr) {
return;
- if (navigation == nullptr)
+ }
+ if (navigation == nullptr) {
return;
- if (update_frame_id == Engine::get_singleton()->get_physics_frames())
+ }
+ if (update_frame_id == Engine::get_singleton()->get_physics_frames()) {
return;
+ }
update_frame_id = Engine::get_singleton()->get_physics_frames();
@@ -314,8 +319,9 @@ void NavigationAgent2D::update_navigation() {
emit_signal("path_changed");
}
- if (navigation_path.size() == 0)
+ if (navigation_path.size() == 0) {
return;
+ }
// Check if we can advance the navigation path
if (navigation_finished == false) {