summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/NavigationServer2D.xml6
-rw-r--r--doc/classes/NavigationServer3D.xml6
-rw-r--r--modules/navigation/godot_navigation_server.cpp12
-rw-r--r--modules/navigation/godot_navigation_server.h2
-rw-r--r--servers/navigation_server_2d.cpp4
-rw-r--r--servers/navigation_server_2d.h2
-rw-r--r--servers/navigation_server_3d.cpp2
-rw-r--r--servers/navigation_server_3d.h2
8 files changed, 36 insertions, 0 deletions
diff --git a/doc/classes/NavigationServer2D.xml b/doc/classes/NavigationServer2D.xml
index 220c12ce7f..187d916fba 100644
--- a/doc/classes/NavigationServer2D.xml
+++ b/doc/classes/NavigationServer2D.xml
@@ -127,6 +127,12 @@
Destroys the given RID.
</description>
</method>
+ <method name="get_maps" qualifiers="const">
+ <return type="Array" />
+ <description>
+ Returns all created navigation map [RID]s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
+ </description>
+ </method>
<method name="map_create" qualifiers="const">
<return type="RID" />
<description>
diff --git a/doc/classes/NavigationServer3D.xml b/doc/classes/NavigationServer3D.xml
index d2eef49cfd..e605cf6645 100644
--- a/doc/classes/NavigationServer3D.xml
+++ b/doc/classes/NavigationServer3D.xml
@@ -127,6 +127,12 @@
Destroys the given RID.
</description>
</method>
+ <method name="get_maps" qualifiers="const">
+ <return type="Array" />
+ <description>
+ Returns all created navigation map [RID]s on the NavigationServer. This returns both 2D and 3D created navigation maps as there is technically no distinction between them.
+ </description>
+ </method>
<method name="map_create" qualifiers="const">
<return type="RID" />
<description>
diff --git a/modules/navigation/godot_navigation_server.cpp b/modules/navigation/godot_navigation_server.cpp
index 2f8cb6c230..927748dbd9 100644
--- a/modules/navigation/godot_navigation_server.cpp
+++ b/modules/navigation/godot_navigation_server.cpp
@@ -123,6 +123,18 @@ void GodotNavigationServer::add_command(SetCommand *command) const {
}
}
+Array GodotNavigationServer::get_maps() const {
+ Array all_map_rids;
+ List<RID> maps_owned;
+ map_owner.get_owned_list(&maps_owned);
+ if (maps_owned.size()) {
+ for (const RID &E : maps_owned) {
+ all_map_rids.push_back(E);
+ }
+ }
+ return all_map_rids;
+}
+
RID GodotNavigationServer::map_create() const {
GodotNavigationServer *mut_this = const_cast<GodotNavigationServer *>(this);
MutexLock lock(mut_this->operations_mutex);
diff --git a/modules/navigation/godot_navigation_server.h b/modules/navigation/godot_navigation_server.h
index d931dbaee0..d4306e7931 100644
--- a/modules/navigation/godot_navigation_server.h
+++ b/modules/navigation/godot_navigation_server.h
@@ -85,6 +85,8 @@ public:
void add_command(SetCommand *command) const;
+ virtual Array get_maps() const override;
+
virtual RID map_create() const override;
COMMAND_2(map_set_active, RID, p_map, bool, p_active);
virtual bool map_is_active(RID p_map) const override;
diff --git a/servers/navigation_server_2d.cpp b/servers/navigation_server_2d.cpp
index 0442089503..ba64dc607e 100644
--- a/servers/navigation_server_2d.cpp
+++ b/servers/navigation_server_2d.cpp
@@ -159,6 +159,8 @@ void NavigationServer2D::_emit_map_changed(RID p_map) {
}
void NavigationServer2D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_maps"), &NavigationServer2D::get_maps);
+
ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer2D::map_create);
ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer2D::map_set_active);
ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer2D::map_is_active);
@@ -217,6 +219,8 @@ NavigationServer2D::~NavigationServer2D() {
singleton = nullptr;
}
+Array FORWARD_0_C(get_maps);
+
Array FORWARD_1_C(map_get_regions, RID, p_map, rid_to_rid);
Array FORWARD_1_C(map_get_agents, RID, p_map, rid_to_rid);
diff --git a/servers/navigation_server_2d.h b/servers/navigation_server_2d.h
index 30f553d10b..23d833ddcb 100644
--- a/servers/navigation_server_2d.h
+++ b/servers/navigation_server_2d.h
@@ -53,6 +53,8 @@ public:
/// MUST be used in single thread!
static NavigationServer2D *get_singleton_mut() { return singleton; }
+ virtual Array get_maps() const;
+
/// Create a new map.
virtual RID map_create() const;
diff --git a/servers/navigation_server_3d.cpp b/servers/navigation_server_3d.cpp
index 60bbcec8d4..da675133c9 100644
--- a/servers/navigation_server_3d.cpp
+++ b/servers/navigation_server_3d.cpp
@@ -33,6 +33,8 @@
NavigationServer3D *NavigationServer3D::singleton = nullptr;
void NavigationServer3D::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("get_maps"), &NavigationServer3D::get_maps);
+
ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer3D::map_create);
ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer3D::map_set_active);
ClassDB::bind_method(D_METHOD("map_is_active", "nap"), &NavigationServer3D::map_is_active);
diff --git a/servers/navigation_server_3d.h b/servers/navigation_server_3d.h
index 9c04d68622..5bf5d8ecdb 100644
--- a/servers/navigation_server_3d.h
+++ b/servers/navigation_server_3d.h
@@ -56,6 +56,8 @@ public:
/// MUST be used in single thread!
static NavigationServer3D *get_singleton_mut();
+ virtual Array get_maps() const = 0;
+
/// Create a new map.
virtual RID map_create() const = 0;