Merge pull request #8242 from volzhs/area-monitoring
Fix monitoring status of Area2D and doing same logic on Area too
This commit is contained in:
commit
e10e732bf0
@ -380,6 +380,10 @@ void Area2D::_notification(int p_what) {
|
|||||||
|
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
|
|
||||||
|
case NOTIFICATION_READY: {
|
||||||
|
|
||||||
|
is_ready = true;
|
||||||
|
} break;
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
|
|
||||||
monitoring_stored = monitoring;
|
monitoring_stored = monitoring;
|
||||||
@ -387,8 +391,8 @@ void Area2D::_notification(int p_what) {
|
|||||||
_clear_monitoring();
|
_clear_monitoring();
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
if (is_ready)
|
||||||
set_enable_monitoring(monitoring_stored);
|
set_enable_monitoring(monitoring_stored);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -646,7 +650,8 @@ Area2D::Area2D()
|
|||||||
monitorable = false;
|
monitorable = false;
|
||||||
collision_mask = 1;
|
collision_mask = 1;
|
||||||
layer_mask = 1;
|
layer_mask = 1;
|
||||||
monitoring_stored = true;
|
monitoring_stored = false;
|
||||||
|
is_ready = false;
|
||||||
set_enable_monitoring(true);
|
set_enable_monitoring(true);
|
||||||
set_monitorable(true);
|
set_monitorable(true);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ private:
|
|||||||
bool monitoring_stored;
|
bool monitoring_stored;
|
||||||
bool monitorable;
|
bool monitorable;
|
||||||
bool locked;
|
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);
|
void _body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape);
|
||||||
|
|
||||||
|
@ -227,6 +227,10 @@ void Area::_clear_monitoring() {
|
|||||||
Object *obj = ObjectDB::get_instance(E->key());
|
Object *obj = ObjectDB::get_instance(E->key());
|
||||||
Node *node = obj ? obj->cast_to<Node>() : NULL;
|
Node *node = obj ? obj->cast_to<Node>() : NULL;
|
||||||
ERR_CONTINUE(!node);
|
ERR_CONTINUE(!node);
|
||||||
|
|
||||||
|
node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
|
||||||
|
node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
|
||||||
|
|
||||||
if (!E->get().in_tree)
|
if (!E->get().in_tree)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -236,9 +240,6 @@ void Area::_clear_monitoring() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
|
emit_signal(SceneStringNames::get_singleton()->body_exit, obj);
|
||||||
|
|
||||||
node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_body_enter_tree);
|
|
||||||
node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_body_exit_tree);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +254,10 @@ void Area::_clear_monitoring() {
|
|||||||
Object *obj = ObjectDB::get_instance(E->key());
|
Object *obj = ObjectDB::get_instance(E->key());
|
||||||
Node *node = obj ? obj->cast_to<Node>() : NULL;
|
Node *node = obj ? obj->cast_to<Node>() : NULL;
|
||||||
ERR_CONTINUE(!node);
|
ERR_CONTINUE(!node);
|
||||||
|
|
||||||
|
node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree);
|
||||||
|
node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree);
|
||||||
|
|
||||||
if (!E->get().in_tree)
|
if (!E->get().in_tree)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -262,16 +267,27 @@ void Area::_clear_monitoring() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit_signal(SceneStringNames::get_singleton()->area_exit, obj);
|
emit_signal(SceneStringNames::get_singleton()->area_exit, obj);
|
||||||
|
|
||||||
node->disconnect(SceneStringNames::get_singleton()->enter_tree, this, SceneStringNames::get_singleton()->_area_enter_tree);
|
|
||||||
node->disconnect(SceneStringNames::get_singleton()->exit_tree, this, SceneStringNames::get_singleton()->_area_exit_tree);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Area::_notification(int p_what) {
|
void Area::_notification(int p_what) {
|
||||||
|
|
||||||
if (p_what == NOTIFICATION_EXIT_TREE) {
|
switch (p_what) {
|
||||||
_clear_monitoring();
|
|
||||||
|
case NOTIFICATION_READY: {
|
||||||
|
|
||||||
|
is_ready = true;
|
||||||
|
} break;
|
||||||
|
case NOTIFICATION_EXIT_TREE: {
|
||||||
|
|
||||||
|
monitoring_stored = monitoring;
|
||||||
|
set_enable_monitoring(false);
|
||||||
|
_clear_monitoring();
|
||||||
|
} break;
|
||||||
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
if (is_ready)
|
||||||
|
set_enable_monitoring(monitoring_stored);
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,6 +643,8 @@ Area::Area()
|
|||||||
monitoring = false;
|
monitoring = false;
|
||||||
collision_mask = 1;
|
collision_mask = 1;
|
||||||
layer_mask = 1;
|
layer_mask = 1;
|
||||||
|
monitoring_stored = false;
|
||||||
|
is_ready = false;
|
||||||
set_ray_pickable(false);
|
set_ray_pickable(false);
|
||||||
set_enable_monitoring(true);
|
set_enable_monitoring(true);
|
||||||
set_monitorable(true);
|
set_monitorable(true);
|
||||||
|
@ -57,8 +57,10 @@ private:
|
|||||||
uint32_t layer_mask;
|
uint32_t layer_mask;
|
||||||
int priority;
|
int priority;
|
||||||
bool monitoring;
|
bool monitoring;
|
||||||
|
bool monitoring_stored;
|
||||||
bool monitorable;
|
bool monitorable;
|
||||||
bool locked;
|
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);
|
void _body_inout(int p_status, const RID &p_body, int p_instance, int p_body_shape, int p_area_shape);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user