Merge pull request #83802 from smix8/navlink_properties

Fix missing NavigationLink property updates in constructor
This commit is contained in:
Rémi Verschelde 2023-12-04 22:58:49 +01:00
commit 9be2f25c57
No known key found for this signature in database
GPG Key ID: C3336907360768E1
6 changed files with 39 additions and 0 deletions

View File

@ -29,6 +29,12 @@
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the [RID] of this link on the [NavigationServer2D].
</description>
</method>
<method name="set_global_end_position">
<return type="void" />
<param index="0" name="position" type="Vector2" />

View File

@ -29,6 +29,12 @@
Returns whether or not the specified layer of the [member navigation_layers] bitmask is enabled, given a [param layer_number] between 1 and 32.
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID" />
<description>
Returns the [RID] of this link on the [NavigationServer3D].
</description>
</method>
<method name="set_global_end_position">
<return type="void" />
<param index="0" name="position" type="Vector3" />

View File

@ -36,6 +36,8 @@
#include "servers/navigation_server_3d.h"
void NavigationLink2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &NavigationLink2D::get_rid);
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationLink2D::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationLink2D::is_enabled);
@ -175,6 +177,10 @@ bool NavigationLink2D::_edit_is_selected_on_click(const Point2 &p_point, double
}
#endif // TOOLS_ENABLED
RID NavigationLink2D::get_rid() const {
return link;
}
void NavigationLink2D::set_enabled(bool p_enabled) {
if (enabled == p_enabled) {
return;
@ -343,7 +349,13 @@ PackedStringArray NavigationLink2D::get_configuration_warnings() const {
NavigationLink2D::NavigationLink2D() {
link = NavigationServer2D::get_singleton()->link_create();
NavigationServer2D::get_singleton()->link_set_owner_id(link, get_instance_id());
NavigationServer2D::get_singleton()->link_set_enter_cost(link, enter_cost);
NavigationServer2D::get_singleton()->link_set_travel_cost(link, travel_cost);
NavigationServer2D::get_singleton()->link_set_navigation_layers(link, navigation_layers);
NavigationServer2D::get_singleton()->link_set_bidirectional(link, bidirectional);
NavigationServer2D::get_singleton()->link_set_enabled(link, enabled);
set_notify_transform(true);
set_hide_clip_children(true);

View File

@ -61,6 +61,7 @@ public:
virtual Rect2 _edit_get_rect() const override;
virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;
#endif
RID get_rid() const;
void set_enabled(bool p_enabled);
bool is_enabled() const { return enabled; }

View File

@ -147,6 +147,8 @@ void NavigationLink3D::_update_debug_mesh() {
#endif // DEBUG_ENABLED
void NavigationLink3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_rid"), &NavigationLink3D::get_rid);
ClassDB::bind_method(D_METHOD("set_enabled", "enabled"), &NavigationLink3D::set_enabled);
ClassDB::bind_method(D_METHOD("is_enabled"), &NavigationLink3D::is_enabled);
@ -263,7 +265,13 @@ void NavigationLink3D::_notification(int p_what) {
NavigationLink3D::NavigationLink3D() {
link = NavigationServer3D::get_singleton()->link_create();
NavigationServer3D::get_singleton()->link_set_owner_id(link, get_instance_id());
NavigationServer3D::get_singleton()->link_set_enter_cost(link, enter_cost);
NavigationServer3D::get_singleton()->link_set_travel_cost(link, travel_cost);
NavigationServer3D::get_singleton()->link_set_navigation_layers(link, navigation_layers);
NavigationServer3D::get_singleton()->link_set_bidirectional(link, bidirectional);
NavigationServer3D::get_singleton()->link_set_enabled(link, enabled);
set_notify_transform(true);
}
@ -284,6 +292,10 @@ NavigationLink3D::~NavigationLink3D() {
#endif // DEBUG_ENABLED
}
RID NavigationLink3D::get_rid() const {
return link;
}
void NavigationLink3D::set_enabled(bool p_enabled) {
if (enabled == p_enabled) {
return;

View File

@ -67,6 +67,8 @@ public:
NavigationLink3D();
~NavigationLink3D();
RID get_rid() const;
void set_enabled(bool p_enabled);
bool is_enabled() const { return enabled; }