Add function to get navigation link iteration id from NavigationServer

Adds function to get navigation link iteration id from NavigationServer.
This commit is contained in:
smix8
2025-04-25 20:48:25 +02:00
parent 931820d33c
commit b002ade3ed
16 changed files with 54 additions and 0 deletions

View File

@@ -644,6 +644,13 @@ RID GodotNavigationServer2D::link_create() {
return rid;
}
uint32_t GodotNavigationServer2D::link_get_iteration_id(RID p_link) const {
NavLink2D *link = link_owner.get_or_null(p_link);
ERR_FAIL_NULL_V(link, 0);
return link->get_iteration_id();
}
COMMAND_2(link_set_map, RID, p_link, RID, p_map) {
NavLink2D *link = link_owner.get_or_null(p_link);
ERR_FAIL_NULL(link);

View File

@@ -177,6 +177,7 @@ public:
virtual Rect2 region_get_bounds(RID p_region) const override;
virtual RID link_create() override;
virtual uint32_t link_get_iteration_id(RID p_link) const override;
/// Set the map of this link.
COMMAND_2(link_set_map, RID, p_link, RID, p_map);

View File

@@ -141,6 +141,10 @@ bool NavLink2D::is_dirty() const {
}
void NavLink2D::sync() {
if (link_dirty) {
iteration_id = iteration_id % UINT32_MAX + 1;
}
link_dirty = false;
}

View File

@@ -57,10 +57,14 @@ class NavLink2D : public NavBase2D {
SelfList<NavLink2D> sync_dirty_request_list_element;
uint32_t iteration_id = 0;
public:
NavLink2D();
~NavLink2D();
uint32_t get_iteration_id() const { return iteration_id; }
void set_map(NavMap2D *p_map);
NavMap2D *get_map() const {
return map;