diff options
| author | Rémi Verschelde | 2017-04-08 22:47:44 +0200 |
|---|---|---|
| committer | GitHub | 2017-04-08 22:47:44 +0200 |
| commit | c9eb0f5f4518e5edd2d867e5ff002c61484cd3c8 (patch) | |
| tree | 457198a3bd5f90f535b948577f8787540f91643e | |
| parent | 4b561e3e04aba9e4a248862c06154e495a56f48f (diff) | |
| parent | c3c0cfd2070c3aec30c1c7dc2392818a8a65ee65 (diff) | |
| download | godot-c9eb0f5f4518e5edd2d867e5ff002c61484cd3c8.tar.gz godot-c9eb0f5f4518e5edd2d867e5ff002c61484cd3c8.tar.zst godot-c9eb0f5f4518e5edd2d867e5ff002c61484cd3c8.zip | |
| -rw-r--r-- | scene/2d/area_2d.cpp | 20 | ||||
| -rw-r--r-- | scene/2d/area_2d.h | 1 | ||||
| -rw-r--r-- | scene/3d/area.cpp | 19 | ||||
| -rw-r--r-- | scene/3d/area.h | 1 |
4 files changed, 23 insertions, 18 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index f5f4ce072..514663a04 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -381,10 +381,6 @@ void Area2D::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { - - is_ready = true; - } break; case NOTIFICATION_EXIT_TREE: { monitoring_stored = monitoring; @@ -392,16 +388,25 @@ void Area2D::_notification(int p_what) { _clear_monitoring(); } break; case NOTIFICATION_ENTER_TREE: { - if (is_ready) - set_enable_monitoring(monitoring_stored); + + if (monitoring_stored) { + set_enable_monitoring(true); + monitoring_stored = false; + } } break; } } void Area2D::set_enable_monitoring(bool p_enable) { + if (!is_inside_tree()) { + monitoring_stored = p_enable; + return; + } + if (p_enable == monitoring) return; + if (locked) { ERR_EXPLAIN("Function blocked during in/out signal. Use call_deferred(\"set_enable_monitoring\",true/false)"); } @@ -423,7 +428,7 @@ void Area2D::set_enable_monitoring(bool p_enable) { bool Area2D::is_monitoring_enabled() const { - return monitoring; + return monitoring || monitoring_stored; } void Area2D::set_monitorable(bool p_enable) { @@ -652,7 +657,6 @@ Area2D::Area2D() collision_mask = 1; layer_mask = 1; monitoring_stored = false; - is_ready = false; set_enable_monitoring(true); set_monitorable(true); } diff --git a/scene/2d/area_2d.h b/scene/2d/area_2d.h index 2c5cea66e..1d6e81a4a 100644 --- a/scene/2d/area_2d.h +++ b/scene/2d/area_2d.h @@ -61,7 +61,6 @@ private: bool monitoring_stored; bool monitorable; bool locked; - bool is_ready; void _body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape); diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 138fd16d3..8792f2d02 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -275,10 +275,6 @@ void Area::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { - - is_ready = true; - } break; case NOTIFICATION_EXIT_TREE: { monitoring_stored = monitoring; @@ -286,8 +282,11 @@ void Area::_notification(int p_what) { _clear_monitoring(); } break; case NOTIFICATION_ENTER_TREE: { - if (is_ready) - set_enable_monitoring(monitoring_stored); + + if (monitoring_stored) { + set_enable_monitoring(true); + monitoring_stored = false; + } } break; } } @@ -299,6 +298,11 @@ void Area::set_enable_monitoring(bool p_enable) { } ERR_FAIL_COND(locked); + if (!is_inside_tree()) { + monitoring_stored = p_enable; + return; + } + if (p_enable == monitoring) return; @@ -419,7 +423,7 @@ void Area::_area_inout(int p_status, const RID &p_area, int p_instance, int p_ar bool Area::is_monitoring_enabled() const { - return monitoring; + return monitoring || monitoring_stored; } Array Area::get_overlapping_bodies() const { @@ -645,7 +649,6 @@ Area::Area() collision_mask = 1; layer_mask = 1; monitoring_stored = false; - is_ready = false; set_ray_pickable(false); set_enable_monitoring(true); set_monitorable(true); diff --git a/scene/3d/area.h b/scene/3d/area.h index 2b94144d3..1a0fcb3f1 100644 --- a/scene/3d/area.h +++ b/scene/3d/area.h @@ -61,7 +61,6 @@ private: bool monitoring_stored; bool monitorable; bool locked; - bool is_ready; void _body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape); |
